会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132476个问题
Python 全系列/第七阶段:网页编程基础/CSS 样式 15076楼
Python 全系列/第四阶段:函数式编程和核心特性/正则表达式 15077楼
Python 全系列/第一阶段:Python入门/面向对象 15081楼
Python 全系列/第六阶段:生产环境部署与协同开发/Linux基本命令 15083楼
Python 全系列/第一阶段:Python入门/序列 15084楼

from flask import Flask,render_template

app=Flask(__name__)
def creat_charts01():
    from pyecharts.charts import Bar,Line
    from pyecharts import options as opt
    ba=Bar()
    x=['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
    ba.add_xaxis(x)
    ba.add_yaxis('蒸发量',[2.0,4.9,7.0,23.2,25.2,76.7,135.6,162.2,32.6,20,6.4,4.3],label_opts=opt.LabelOpts(is_show=False))
    ba.add_yaxis('降水量',[2.6,5.9,9,26.4,28.7,70.7,175.6,182.2,48.7,18.8,6,2.3],label_opts=opt.LabelOpts(is_show=False))
    ba.set_global_opts(title_opts=opt.TitleOpts('组合图'),
    tooltip_opts=opt.TooltipOpts(is_show=True,trigger='axis',axis_pointer_type='cross'),
    xaxis_opts=opt.AxisOpts(type_='category',axispointer_opts=opt.AxisPointerOpts(is_show=True,type_='shadow'))
    )
    ba.extend_axis(yaxis=opt.AxisOpts(name='温度',min_=0,max_=25,interval=5,
    axislabel_opts=opt.LabelOpts(formatter='{value} ℃')
    ))#分割
    lin=Line()
    lin.add_xaxis(x)
    lin.add_yaxis('平均温度',[2.0,2.2,2.3,4.5,6.3,10.2,20.3,23.4,23,16.5,12.0,6],yaxis_index=1,label_opts=opt.LabelOpts(is_show=False))
    ba.overlap(lin)#合并图
    ba.render('./templates/chart01.html')
# # 1.返回跳转文件
@app.route('/show_bar01')
def show_bar01():
    creat_charts01()
    return render_template('chart01.html')
#2.返回一个模板
#3.前后分类

if __name__=='__main__':
    app.run(debug=True)

    为什么我这个代码生成url后打开说找不到文件为什么啊?

image.png

Python 全系列/第十八阶段:数据分析-数据可视化/pyecharts(旧) 15085楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/网络编程(旧) 15087楼
Python 全系列/第六阶段:生产环境部署与协同开发/docker容器扩展 15088楼
JAVA 全系列/第十八阶段:亿级高并发电商项目_架构/编码(旧)/电商:基于SpringSecurity实现后台登录功能 15089楼
JAVA 全系列/第三阶段:数据库编程/MySQL数据库的使用 15090楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637