app.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:web-dev-for-data-scientists 作者: realpython 项目源码 文件源码
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
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号