def chart():
# create chart
p = figure(plot_width=1000, plot_height=400, x_axis_type='datetime')
# add a line renderer
x = []
y = []
all_data = get_data()
# refactor
for value in all_data:
date = datetime.datetime.fromtimestamp(value[0])
x.append(date)
y.append(value[1])
p.line(x, y, line_width=2)
# create static files
js_resources = INLINE.render_js()
css_resources = INLINE.render_css()
script, div = components(p)
# render template
return render_template(
'chart.html',
plot_script=script,
plot_div=div,
js_resources=js_resources,
css_resources=css_resources
)
评论列表
文章目录