-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
233 lines (214 loc) · 8.19 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
from pyecharts import options as opts
from pyecharts.charts import Bar, Grid, Line, Liquid, Page, Pie, Map, Geo, Radar
from pyecharts.commons.utils import JsCode
from pyecharts.components import Table
from pyecharts.globals import ThemeType
import random
def b_right1():
pie_Energyanalysis = Pie(init_opts=opts.InitOpts(
theme=ThemeType.CHALK, width='754px', height='310px'))
pie_Energyanalysis.add(
'',
[["煤炭", 9.26], ["电", 18.52], ["蒸汽", 25.93], ["天然气", 46.3]],
radius=["30%", "70%"],
center=["50%", "50%"],
rosetype="radius"
)
pie_Energyanalysis.set_global_opts(
title_opts=opts.TitleOpts(
title="重点用能单位的能耗分析(单位:吨 标准煤)",
pos_left="27",
pos_top="10",
title_textstyle_opts=opts.TextStyleOpts(
font_size=20,
color="#000"
)
),
legend_opts=opts.LegendOpts(
orient="vertical", pos_top="15%", pos_left="2%"),
tooltip_opts=opts.TooltipOpts(
trigger="item", formatter="{a} <br/>{b}: {c} ({d}%)")
)
pie_Energyanalysis.set_series_opts(
label_opts=opts.LabelOpts(formatter="{b}: {c}"))
return pie_Energyanalysis
def b_right2(): # UnFinish_Style##
bar_energyconsumption = Bar(init_opts=opts.InitOpts(
theme=ThemeType.CHALK, width='754px', height='310px'))
# 添加 X 轴数据
bar_energyconsumption.add_xaxis(["电", "煤炭", "天然气", "蒸汽"])
# 添加 Y 轴数据,这里需要您提供实际的数据值
bar_energyconsumption.add_yaxis(["电", "煤炭", "天然气", "蒸汽"], [
312, 614, 880, 300], bar_width=13)
bar_energyconsumption.add_yaxis(["电", "煤炭", "天然气", "蒸汽"], [
356, 550, 200, 400], bar_width=13)
# 设置全局配置项
bar_energyconsumption.set_global_opts(
title_opts=opts.TitleOpts(
title="规上工业增量存量能耗对比",
title_textstyle_opts=opts.TextStyleOpts(
font_size=20,
color="#000"
),
pos_left="27",
pos_top="10"
),
# 根据需要添加更多配置项
)
return bar_energyconsumption
def b_right3_1():
pie_industryanalysis1 = Pie(init_opts=opts.InitOpts(
theme=ThemeType.CHALK, width='377px', height='400px'))
pie_industryanalysis1.add(
'',
[["蒸汽", 21.43], ["电", 21.43], ["天然气", 14.29], ["煤炭", 42.86]],
radius=["20%", "70%"],
rosetype='rose_type'
)
pie_industryanalysis1.set_series_opts(
label_opts=opts.LabelOpts(
font_size=14,
color="#fff",
formatter="{b}\n{c}%",
position="inside"
),
)
pie_industryanalysis1.set_global_opts(
title_opts=opts.TitleOpts(
title=['行业能耗结构分析(单位:标准煤)'],
pos_left="27",
pos_top="10",
title_textstyle_opts=opts.TextStyleOpts(
font_size=20,
color="#000"
),
),
legend_opts=opts.LegendOpts(pos_bottom="1%"),
)
return pie_industryanalysis1
def b_right3_2():
pie_industryanalysis2 = Pie(init_opts=opts.InitOpts(
theme=ThemeType.CHALK, width='400px', height='400px'))
pie_industryanalysis2.add(
'',
[["限上批零业", 7.04], ["规上服务业", 42.25], ["非化工企业", 21.13], ["化工企业", 29.58]],
radius=["20%", "70%"],
rosetype='rose_type'
)
pie_industryanalysis2.set_series_opts(
label_opts=opts.LabelOpts(
font_size=14,
color="#fff",
formatter="{b}\n{c}%",
position="inside"
),
)
pie_industryanalysis2.set_global_opts(
title_opts=opts.TitleOpts(
title=['能耗结构分析'],
pos_left="27",
pos_top="10",
title_textstyle_opts=opts.TextStyleOpts(
font_size=20,
color="#000"
),
),
legend_opts=opts.LegendOpts(pos_bottom="1%"),
)
return pie_industryanalysis2
def b_left3(): # 再议###
line_energyconsumptionthismonth = Line(init_opts=opts.InitOpts(
theme=ThemeType.CHALK, width='568px', height='311px'))
# 添加 X 轴数据
line_energyconsumptionthismonth.add_xaxis([])
line_energyconsumptionthismonth.add_xaxis(["电", "煤炭", "天然气", "蒸汽"])
# 添加 Y 轴数据,这里需要您提供实际的数据值
line_energyconsumptionthismonth.add_yaxis(["电", "煤炭", "天然气", "蒸汽"], [
50, 21, 32, 42, 31, 26, 28, 37, 45, 12, 36, 36, 39, 42, 50, 32,],)
line_energyconsumptionthismonth.add_yaxis([], [])
line_energyconsumptionthismonth.set_series_opts(
areastyle_opts=opts.AreaStyleOpts(
color="rgba(13,120,214,0.8)",
)
)
# 设置全局配置项
line_energyconsumptionthismonth.set_global_opts(
title_opts=opts.TitleOpts(
title="园区本月能耗",
title_textstyle_opts=opts.TextStyleOpts(
font_size=20,
color="#000"
),
pos_left="27",
pos_top="9"
),
# 根据需要添加更多配置项
)
return line_energyconsumptionthismonth
def b_left1_Map(): # TODO##
data_prov_city = [["兴化市", [119.930721, 32.826721]],
["靖江市", [120.135391, 31.997629]]]
Map_m = Map(init_opts=opts.InitOpts(
theme=ThemeType.CHALK, width='1053px', height='634px'))
Map_m.add("",
data_prov_city,
"泰州"
)
Map_m.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
# Map_m.set_global_opts(
# title_opts=opts.TitleOpts(title='Provinces of China'),
# visualmap_opts=opts.VisualMapOpts(
# min_=100,
# max_=200,
# is_piecewise=True)
# )
return Map_m
def b_left2(): # UnFinish##
bar_energyconsumptionthisday = Bar(init_opts=opts.InitOpts(
theme=ThemeType.CHALK, width='465px', height='311px'))
bar_energyconsumptionthisday.add_xaxis([90, 74, 50, 40])
bar_energyconsumptionthisday.add_yaxis(
["当日原煤量", "当日蒸汽量", "当日天然气量", "当月用电量"], [90, 74, 50, 40], bar_width=13)
bar_energyconsumptionthisday.reversal_axis()
bar_energyconsumptionthisday.set_global_opts(
title_opts=opts.TitleOpts(
title="园区当日能耗",
title_textstyle_opts=opts.TextStyleOpts(
font_size=20,
color="#000",
),
pos_left='27',
pos_top='9',
)
)
return bar_energyconsumptionthisday
def b_left1_Radar():
v1 = [[4000, 10000, 20000, 30000, 20000, 20000]]
c = (
Radar(init_opts=opts.InitOpts(
theme=ThemeType.CHALK, width='465px', height='311px'))
.add_schema(
schema=[
opts.RadarIndicatorItem(name="临时访客", max_=6500),
opts.RadarIndicatorItem(name="危废车辆", max_=16000),
opts.RadarIndicatorItem(name="职工车辆", max_=30000),
opts.RadarIndicatorItem(name="危化品车辆", max_=38000),
opts.RadarIndicatorItem(name="普通车辆", max_=52000),
]
)
.add("统计值", v1)
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(
title_opts=opts.TitleOpts(
title="入园申报统计", pos_right='27', pos_top='9'),
legend_opts=opts.LegendOpts(is_show=False),
)
)
return c
# page = Page(layout=Page.DraggablePageLayout).add_js_funcs(
# "document.body.style.backgroundColor = \"#101341\";")
# # 需要自行调整每个 chart 的 height/width,显示效果在不同的显示器上可能不同
# page.add(b_right1(), b_right2(), b_right3_1(),
# b_right3_2(), b_left3(), b_left1_Map(), b_left2(), b_left1_Radar())
# page.render()
Page.save_resize_html("render.html", cfg_file="./json/chart_config.json")