Example #1
0
def time_window_selector(base: alt.Chart, interpolate: bool) -> alt.LayerChart:
    if interpolate is True:
        tws = base.mark_area(interpolate="monotone")
    else:
        tws = base.mark_bar().encode(x2=alt.X2("event_end:T"))
    tws = tws.encode(
        x=alt.X("event_start", title=""),
        y=alt.Y(
            "reference_value",
            title="",
            axis=alt.Axis(values=[], domain=False, ticks=False),
        ),
        color=alt.ColorValue(idle_color),
        tooltip=alt.TooltipValue("Click and drag to select time window"),
    ).properties(height=30, title="Select time window")
    tws = tws.add_selection(time_selection_brush) + tws.transform_filter(
        time_selection_brush).encode(
            color=alt.condition(time_selection_brush, alt.ColorValue(
                "#c21431"), alt.ColorValue(idle_color)))
    return tws
    start_price = line[4]

x_vals = range(0, 1000)
y_vals = []
for price in day_change:
    y_vals.append(price)

data = Data(X=x_vals, Y=y_vals)
chart = Chart(data)
mark = chart.mark_point()
enc = mark.encode(x='X', y='Y')
enc.display()

data = Data(change=day_change)
chart = Chart(data)
mark = chart.mark_bar()
X = Axis('change:Q', bin=True)
Y = Axis('count()')
enc = mark.encode(x=X, y=Y)
enc.display()

print(mean(day_change))
print(stdev(day_change))

# predictions
# print(lines2[999][4])
# 306.730011

change = 0
change_guess = []
start_price = 306.730011