def histogram_lines(pop_data, x_axis, y_axis):
    histo_lines = []
    for cn in pop_data:
        y = y_scale(pop_data[cn], y_axis)
        x = scale(cn, x_axis)
        histo_lines.append(
            svg.line(x,
                     y,
                     x,
                     y_scale(0, y_axis),
                     color=colors["grey"],
                     opacity=0.5))
    return histo_lines
def sample_lines(sample_data, x_axis, y_axis):
    lines = []
    samples = iter(sample_data)
    for idx, key in enumerate(samples):
        x = scale(sample_data[key], x_axis)
        lines.append(
            svg.line(x,
                     y_scale(0, y_axis),
                     x,
                     y_scale(y_axis["max"], y_axis),
                     color=color_arr[idx % len(color_arr)]))

    return lines
Example #3
0
def x_axis_tics(x_axis, y_axis):
    tics = [
        line(scale(x_axis["min"], x_axis), y_scale(y_axis["min"], y_axis),
             scale(x_axis["min"], x_axis), y_scale(y_axis["max"], y_axis))
    ]

    for tic in x_axis["tics"]:
        tics.append(
            line(scale(tic, x_axis), y_scale(y_axis["min"], y_axis),
                 scale(tic, x_axis),
                 y_scale(y_axis["min"], y_axis) + 6))

    return tics
Example #4
0
def x_axis_lines(x_axis, y_axis):
    lines = []
    for tic in x_axis["tics"]:
        x = scale(tic, x_axis)
        lines.append(
            line(x,
                 y_scale(y_axis["min"], y_axis),
                 x,
                 y_scale(y_axis["max"], y_axis),
                 opacity=0.5,
                 dashes=3))

    return lines
Example #5
0
def y_axis_title(x_axis, y_axis, side):
    if side == "left":
        y = 45
        x = -(y_scale(y_axis["min"], y_axis))
        transform = "rotate(270)"
    else:
        y = -35 - scale(x_axis["max"], x_axis)
        x = y_scale(y_axis["max"], y_axis)
        transform = "rotate(90)"
    return [
        text(x,
             y,
             y_axis["title"],
             style="font: 18px sans-serif",
             transform=transform)
    ]
Example #6
0
def y_axis_tics(x_axis, y_axis, side):
    if side == "left":
        x1 = scale(x_axis["min"], x_axis) - 6
        x2 = scale(x_axis["min"], x_axis)
    else:
        x1 = scale(x_axis["max"], x_axis)
        x2 = scale(x_axis["max"], x_axis) + 4

    tics = [
        line(scale(x_axis["min"], x_axis), y_scale(y_axis["min"], y_axis),
             scale(x_axis["max"], x_axis), y_scale(y_axis["min"], y_axis))
    ]
    for tic in y_axis["tics"]:
        tics.append(line(x1, y_scale(tic, y_axis), x2, y_scale(tic, y_axis)))

    return tics
Example #7
0
def x_axis_title(x_axis, y_axis):
    x = ((x_axis["max"] - x_axis["min"]) / 2) + x_axis["min"]
    return [
        text(scale(x, x_axis) - (len(x_axis["title"]) * 6),
             y_scale(y_axis["min"], y_axis) + 34,
             x_axis["title"],
             style="font: 18px sans-serif")
    ]
Example #8
0
def x_axis_text(x_axis, y_axis):
    txt = []
    for tic in x_axis["tics"]:
        txt.append(
            text(
                scale(tic, x_axis) - 4,
                y_scale(y_axis["min"], y_axis) + 18, "%s" % tic))

    return txt
def sample_paths(data, x_axis, y_axis):
    paths = []
    for idx, key in enumerate(data):
        points = []
        for x_idx, value in enumerate(data[key]):
            points.append("%s,%s" %
                          (scale(value[0], x_axis), y_scale(value[1], y_axis)))
        color = color_arr[idx % len(color_arr)]
        paths.append(svg.path(points, color=color))

    return paths
Example #10
0
def get_keys(key_items, x_axis, y_axis, element_type="line"):
    keys = []
    x = scale(x_axis["max"], x_axis) + 60
    y = y_scale(y_axis["max"], y_axis)

    for idx, key in enumerate(key_items):
        color = color_arr[idx % len(color_arr)]
        y_val = y + (15 * (idx + 1))
        keys.append(get_key_symbol(x, y_val, element_type, color))
        keys.append(text(x + 20, y_val, key.split('_')[0]))

    return keys
Example #11
0
def y_axis_lines(x_axis, y_axis):
    lines = []
    for tic in y_axis["tics"]:
        y = y_scale(tic, y_axis)
        lines.append(
            line(scale(x_axis["min"], x_axis),
                 y,
                 scale(x_axis["max"], x_axis),
                 y,
                 opacity=0.5,
                 dashes=3))

    return lines
Example #12
0
def y_axis_text(x_axis, y_axis, side):
    if side == "left":
        x = scale(x_axis["min"], x_axis) - 8
    else:
        x = scale(x_axis["max"], x_axis) + 6
    txt = []
    for tic in y_axis["tics"]:
        z = zeroes(tic)
        r = x
        if side == "left":
            r = x - (z * 8)
        txt.append(text(r, y_scale(tic, y_axis) + 3, "%s" % tic))

    return txt
def circles(data, x_axis, y_axis):
    spots = []

    for idx, group in enumerate(data):
        colour = color_arr[idx % len(color_arr)]
        for x_val, y_val in data[group]:
            circle = svg.circle(scale(x_val, x_axis),
                                y_scale(y_val, y_axis),
                                4,
                                fill_color=colour,
                                border_color=colour)
            circle = svg.add_tooltip(
                circle, "%s\n%s: %s\nValue: %s" %
                (group, x_axis["title"], x_val + 1, y_val))
            spots.append(circle)
    return spots
Example #14
0
def get_bar(i, val, x_axis, y_axis, color):
    width = scale(2, x_axis) - scale(1.6, x_axis)
    y = y_scale(val, y_axis)
    height = y_scale(y_axis["min"], y_axis) - y
    x = scale(i, x_axis)
    return svg.rect(x, y, width, height, border_color=color, fill_color=color, opacity=0.7)
Example #15
0
def add_star_to_13(x_axis, y_axis):
    x = scale(13, x_axis) - 10
    y = y_scale(y_axis["min"], y_axis) + 22
    return [text(x, y, "*", style="font: 18px sans-serif")]
Example #16
0
def right_axis_line(x_axis, y_axis):
    return [
        line(scale(x_axis["max"], x_axis), y_scale(y_axis["min"], y_axis),
             scale(x_axis["max"], x_axis), y_scale(y_axis["max"], y_axis))
    ]