app.py 文件源码

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

项目:blog-code-examples 作者: fullstackpython 项目源码 文件源码
def chart(num_bars):
    """Creates a bar chart with the desired number of bars in a chart."""
    if num_bars <= 0:
        num_bars = 1
    data = {"days": [], "bugs": [], "costs": []}
    for i in range(1, num_bars + 1):
        data['days'].append(i)
        data['bugs'].append(random.randint(1,100))
        data['costs'].append(random.uniform(1.00, 1000.00))

    hover = create_hover_tool()
    plot = create_bar_chart(data, "Bugs found per day", "days",
                            "bugs", hover)
    script, div = components(plot)
    return template(TEMPLATE_STRING, bars_count=num_bars,
                      the_div=div, the_script=script)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号