print(“Hello,菜鸟实战”)
print(“实战场景: 如何绘制预算开销雷达图 \n”)
web = Flask(name)
构建数据
v1 = [[4300, 10000, 28000, 35000, 50000, 19000]]
v2 = [[5000, 14000, 28000, 31000, 42000, 21000]]
def radar_charts() -> Radar():
# 实例化对象
radar = Radar()
radar.add_schema(
schema=[
opts.RadarIndicatorItem(name=“销售”, max_=6500, color=“#000000”),
opts.RadarIndicatorItem(name=“管理”, max_=16000, color=“#000000”),
opts.RadarIndicatorItem(name=“信息技术”, max_=30000, color=“#000000”),
opts.RadarIndicatorItem(name=“客服”, max_=38000, color=“#000000”),
opts.RadarIndicatorItem(name=“研发”, max_=52000, color=“#000000”),
opts.RadarIndicatorItem(name=“市场”, max_=25000, color=“#000000”),
]
)
radar.add(
series_name=“预算分配”,
data=v1,
linestyle_opts=opts.LineStyleOpts(color=“#ff0000”),
),
radar.add(
series_name=“实际开销”,
data=v2,
linestyle_opts=opts.LineStyleOpts(color=“#0000ff”),
),
# 隐藏数值
radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)),
# 全局置标题、标签
radar.set_global_opts(
title_opts=opts.TitleOpts(title="如何绘制预算开销雷达图", subtitle="菜鸟实战,坚持学习!"),
)
return radar
获取对象
p = radar_charts()
绘制图形。path为指定路径,生成HTML文件的一个路径
p.render(‘./templates/radar_charts.html’)
添加路由显示图表
@web.route(‘/’)
def index():
return render_template(‘radar_charts.html’)
if name == “main”:
# 运行项目
web.run(debug=False)
print(“Python 版本”, platform.python_version())
### 2、运行结果
>
> Hello,菜鸟实战
> 实战场景: 如何绘制预算开销雷达图
>
>
> \* Serving Flask app 'py040' (lazy loading)
> \* Environment: production
> WARNING: This is a development server. Do not use it in a production deployment.
> Use a production WSGI server instead.
> \* Debug mode: off
> \* Running on http://127.0.0.1:5000 (Press CTRL+C to quit)
>
>
>
> ![](https://img-blog.csdnimg.cn/35f869f8e034499999d73248d4159d94.png)
>
>
>
![img](https://img-blog.csdnimg.cn/img_convert/52e40d802c177de91d08aaa857cdab21.png)
![img](https://img-blog.csdnimg.cn/img_convert/72782b3d72486b6a2e1f19d789975379.png)
**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)**
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**