-
Notifications
You must be signed in to change notification settings - Fork 293
/
archive_app.py
975 lines (914 loc) · 32.4 KB
/
archive_app.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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
import random
from random import randint
from streamlit_echarts import JsCode
from streamlit_echarts import st_echarts
from streamlit_echarts import st_pyecharts
import pandas as pd
import streamlit as st
import streamlit.components.v1 as components
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.charts import Geo
from pyecharts.charts import Liquid
from pyecharts.charts import Timeline
from pyecharts.charts import WordCloud
from pyecharts.commons.utils import JsCode
from pyecharts.faker import Faker
from pyecharts.globals import ThemeType
def main():
ST_PAGES = {
"Basic line chart": render_basic_line,
"Basic area chart": render_basic_area,
"Stacked area chart": render_stacked_area,
"Mixed line and bar": render_mixed_line_bar,
"Custom pie chart": render_custom_pie,
"Effect scatter chart": render_effect_scatter,
"Calendar heatmap": render_calendar_heatmap,
"Basic treemap": render_treemap,
"Datazoom": render_datazoom,
"Dataset": render_dataset,
"Map": render_map,
"Click event": render_event,
"Liquidfill": render_liquid,
"Wordcloud": render_wordcloud,
}
PY_ST_PAGES = {
"Basic bar chart": render_bar_py,
"Custom themes": render_custom_py,
"Filter with legend": render_filter_legend_py,
"Vertical datazoom": render_vertical_datazoom_py,
"Timeline": render_timeline_py,
"Chart with randomization": render_randomize_py,
"JsCode coloring": render_js_py,
"Map": render_map_py,
"Liquidfill": render_liquid_py,
"Wordcloud": render_wordcloud_py,
}
st.title("Hello ECharts !")
st.sidebar.header("Configuration")
select_lang = st.sidebar.selectbox(
"Choose your preferred API:", ("echarts", "pyecharts", "embedded")
)
if select_lang == "echarts":
page = st.sidebar.selectbox("Choose an example", options=list(ST_PAGES.keys()))
ST_PAGES[page]()
if select_lang == "pyecharts":
page = st.sidebar.selectbox(
"Choose an example", options=list(PY_ST_PAGES.keys())
)
PY_ST_PAGES[page]()
if select_lang == "embedded":
with st.echo("below"):
c = (
Bar()
.add_xaxis(
["Microsoft", "Amazon", "IBM", "Oracle", "Google", "Alibaba"]
)
.add_yaxis(
"2017-2018 Revenue in (billion $)", [21.2, 20.4, 10.3, 6.08, 4, 2.2]
)
.set_global_opts(
title_opts=opts.TitleOpts(
title="Top cloud providers 2018", subtitle="2017-2018 Revenue"
),
toolbox_opts=opts.ToolboxOpts(),
)
.render_embed() # generate a local HTML file
)
components.html(c, width=900, height=550)
def render_basic_line():
with st.echo("below"):
options = {
"xAxis": {
"type": "category",
"data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
},
"yAxis": {"type": "value"},
"series": [
{"data": [820, 932, 901, 934, 1290, 1330, 1320], "type": "line"}
],
}
st_echarts(
options=options, height="400px",
)
st_echarts(
options=options, height="400px", theme="dark",
)
def render_basic_area():
with st.echo("below"):
options = {
"xAxis": {
"type": "category",
"boundaryGap": False,
"data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
},
"yAxis": {"type": "value"},
"series": [
{
"data": [820, 932, 901, 934, 1290, 1330, 1320],
"type": "line",
"areaStyle": {},
}
],
}
st_echarts(options=options)
def render_stacked_area():
with st.echo("below"):
options = {
"title": {"text": "堆叠区域图"},
"tooltip": {
"trigger": "axis",
"axisPointer": {
"type": "cross",
"label": {"backgroundColor": "#6a7985"},
},
},
"legend": {"data": ["邮件营销", "联盟广告", "视频广告", "直接访问", "搜索引擎"]},
"toolbox": {"feature": {"saveAsImage": {}}},
"grid": {"left": "3%", "right": "4%", "bottom": "3%", "containLabel": True},
"xAxis": [
{
"type": "category",
"boundaryGap": False,
"data": ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
}
],
"yAxis": [{"type": "value"}],
"series": [
{
"name": "邮件营销",
"type": "line",
"stack": "总量",
"areaStyle": {},
"data": [120, 132, 101, 134, 90, 230, 210],
},
{
"name": "联盟广告",
"type": "line",
"stack": "总量",
"areaStyle": {},
"data": [220, 182, 191, 234, 290, 330, 310],
},
{
"name": "视频广告",
"type": "line",
"stack": "总量",
"areaStyle": {},
"data": [150, 232, 201, 154, 190, 330, 410],
},
{
"name": "直接访问",
"type": "line",
"stack": "总量",
"areaStyle": {},
"data": [320, 332, 301, 334, 390, 330, 320],
},
{
"name": "搜索引擎",
"type": "line",
"stack": "总量",
"label": {"normal": {"show": True, "position": "top"}},
"areaStyle": {},
"data": [820, 932, 901, 934, 1290, 1330, 1320],
},
],
}
st_echarts(options)
def render_mixed_line_bar():
with st.echo("below"):
options = {
"tooltip": {
"trigger": "axis",
"axisPointer": {"type": "cross", "crossStyle": {"color": "#999"}},
},
"toolbox": {
"feature": {
"dataView": {"show": True, "readOnly": False},
"magicType": {"show": True, "type": ["line", "bar"]},
"restore": {"show": True},
"saveAsImage": {"show": True},
}
},
"legend": {"data": ["蒸发量", "降水量", "平均温度"]},
"xAxis": [
{
"type": "category",
"data": [
"1月",
"2月",
"3月",
"4月",
"5月",
"6月",
"7月",
"8月",
"9月",
"10月",
"11月",
"12月",
],
"axisPointer": {"type": "shadow"},
}
],
"yAxis": [
{
"type": "value",
"name": "水量",
"min": 0,
"max": 250,
"interval": 50,
"axisLabel": {"formatter": "{value} ml"},
},
{
"type": "value",
"name": "温度",
"min": 0,
"max": 25,
"interval": 5,
"axisLabel": {"formatter": "{value} °C"},
},
],
"series": [
{
"name": "蒸发量",
"type": "bar",
"data": [
2.0,
4.9,
7.0,
23.2,
25.6,
76.7,
135.6,
162.2,
32.6,
20.0,
6.4,
3.3,
],
},
{
"name": "降水量",
"type": "bar",
"data": [
2.6,
5.9,
9.0,
26.4,
28.7,
70.7,
175.6,
182.2,
48.7,
18.8,
6.0,
2.3,
],
},
{
"name": "平均温度",
"type": "line",
"yAxisIndex": 1,
"data": [
2.0,
2.2,
3.3,
4.5,
6.3,
10.2,
20.3,
23.4,
23.0,
16.5,
12.0,
6.2,
],
},
],
}
st_echarts(options)
def render_custom_pie():
with st.echo("below"):
pie_options = {
"backgroundColor": "#2c343c",
"title": {
"text": "Customized Pie",
"left": "center",
"top": 20,
"textStyle": {"color": "#ccc"},
},
"tooltip": {"trigger": "item", "formatter": "{a} <br/>{b} : {c} ({d}%)"},
"visualMap": {
"show": False,
"min": 80,
"max": 600,
"inRange": {"colorLightness": [0, 1]},
},
"series": [
{
"name": "Source of interview",
"type": "pie",
"radius": "55%",
"center": ["50%", "50%"],
"data": [
{"value": 235, "name": "Video Ad"},
{"value": 274, "name": "Affiliate Ad"},
{"value": 310, "name": "Email marketing"},
{"value": 335, "name": "Direct access"},
{"value": 400, "name": "Search engine"},
],
"roseType": "radius",
"label": {"color": "rgba(255, 255, 255, 0.3)"},
"labelLine": {
"lineStyle": {"color": "rgba(255, 255, 255, 0.3)"},
"smooth": 0.2,
"length": 10,
"length2": 20,
},
"itemStyle": {
"color": "#c23531",
"shadowBlur": 200,
"shadowColor": "rgba(0, 0, 0, 0.5)",
},
"animationType": "scale",
"animationEasing": "elasticOut",
}
],
}
st_echarts(options=pie_options)
def render_effect_scatter():
with st.echo("below"):
options = {
"xAxis": {"scale": True},
"yAxis": {"scale": True},
"series": [
{
"type": "effectScatter",
"symbolSize": 20,
"data": [[161.2, 51.6], [167.5, 59]],
},
{
"type": "scatter",
"data": [
[161.2, 51.6],
[167.5, 59.0],
[159.5, 49.2],
[157.0, 63.0],
[155.8, 53.6],
[170.0, 59.0],
[159.1, 47.6],
[166.0, 69.8],
[176.2, 66.8],
[160.2, 75.2],
[172.5, 55.2],
[170.9, 54.2],
[172.9, 62.5],
[153.4, 42.0],
[160.0, 50.0],
[176.5, 71.8],
[164.4, 55.5],
[160.7, 48.6],
[174.0, 66.4],
[163.8, 67.3],
],
},
],
}
st_echarts(options)
def render_calendar_heatmap():
with st.echo("below"):
def get_virtual_data(year):
date_list = pd.date_range(
start=f"{year}-01-01", end=f"{year + 1}-01-01", freq="D"
)
return [[d.strftime("%Y-%m-%d"), randint(1, 10000)] for d in date_list]
options = {
"title": {"top": 30, "left": "center", "text": "2016年某人每天的步数"},
"tooltip": {},
"visualMap": {
"min": 0,
"max": 10000,
"type": "piecewise",
"orient": "horizontal",
"left": "center",
"top": 65,
"textStyle": {"color": "#000"},
},
"calendar": {
"top": 120,
"left": 30,
"right": 30,
"cellSize": ["auto", 13],
"range": "2016",
"itemStyle": {"borderWidth": 0.5},
"yearLabel": {"show": False},
},
"series": {
"type": "heatmap",
"coordinateSystem": "calendar",
"data": get_virtual_data(2016),
},
}
st_echarts(options)
def render_treemap():
with st.echo("below"):
options = {
"series": [
{
"type": "treemap",
"data": [
{
"name": "nodeA",
"value": 10,
"children": [
{"name": "nodeAa", "value": 4},
{"name": "nodeAb", "value": 6},
],
},
{
"name": "nodeB",
"value": 20,
"children": [
{
"name": "nodeBa",
"value": 20,
"children": [{"name": "nodeBa1", "value": 20}],
}
],
},
],
}
]
}
st_echarts(options)
def render_datazoom():
with st.echo("below"):
data = [
["14.616", "7.241", "0.896"],
["3.958", "5.701", "0.955"],
["2.768", "8.971", "0.669"],
["9.051", "9.710", "0.171"],
["14.046", "4.182", "0.536"],
["12.295", "1.429", "0.962"],
["4.417", "8.167", "0.113"],
["0.492", "4.771", "0.785"],
["7.632", "2.605", "0.645"],
["14.242", "5.042", "0.368"],
]
option_js = {
"xAxis": {"type": "value"},
"yAxis": {"type": "value"},
"dataZoom": [{"type": "slider", "start": 10, "end": 60}],
"series": [
{
"type": "scatter",
"itemStyle": {"opacity": 0.8},
"symbolSize": JsCode(
"""function (val) { return val[2] * 40; }"""
).js_code,
"data": data,
}
],
}
st_echarts(options=option_js)
def render_dataset():
with st.echo("below"):
options = {
"legend": {},
"tooltip": {},
"dataset": {
"source": [
["product", "2015", "2016", "2017"],
["Matcha Latte", 43.3, 85.8, 93.7],
["Milk Tea", 83.1, 73.4, 55.1],
["Cheese Cocoa", 86.4, 65.2, 82.5],
["Walnut Brownie", 72.4, 53.9, 39.1],
]
},
"xAxis": {"type": "category"},
"yAxis": {},
"series": [{"type": "bar"}, {"type": "bar"}, {"type": "bar"}],
}
st_echarts(options, renderer="svg")
def render_map():
with st.echo("below"):
options = {
"backgroundColor": "#404a59",
"title": {
"text": "全国主要城市空气质量",
"subtext": "data from PM25.in",
"sublink": "http://www.pm25.in",
"left": "center",
"textStyle": {"color": "#fff"},
},
"tooltip": {"trigger": "item"},
"legend": {
"orient": "vertical",
"top": "bottom",
"left": "right",
"data": ["pm2.5"],
"textStyle": {"color": "#fff"},
},
"visualMap": {
"min": 0,
"max": 300,
"splitNumber": 5,
"color": ["#d94e5d", "#eac736", "#50a3ba"],
"textStyle": {"color": "#fff"},
},
"geo": {
"map": "china",
"label": {"emphasis": {"show": False}},
"itemStyle": {
"normal": {"areaColor": "#323c48", "borderColor": "#111"},
"emphasis": {"areaColor": "#2a333d"},
},
},
}
st_echarts(options)
def render_event():
with st.echo("below"):
st.markdown("Click on chart elements")
options = {
"xAxis": {
"data": ["shirt", "cardign", "chiffon shirt", "pants", "heels", "socks"]
},
"yAxis": {},
"series": [
{"name": "sales", "type": "bar", "data": [5, 20, 36, 10, 10, 20]}
],
}
events = {"click": "function(params, echarts) {alert('click detection');}"}
st_echarts(options, events=events)
def render_liquid():
with st.echo("below"):
options = {
"series": [
{
"type": "liquidFill",
"data": [0.5, 0.4, 0.3],
"color": ["red", "#0f0", "rgb(0, 0, 255)"],
"itemStyle": {"opacity": 0.6},
"emphasis": {"itemStyle": {"opacity": 0.9}},
}
]
}
st_echarts(options)
def render_wordcloud():
with st.echo("below"):
options = {
"tooltip": {},
"series": [
{
"type": "wordCloud",
"gridSize": 2,
"sizeRange": [12, 50],
"rotationRange": [-90, 90],
"shape": "pentagon",
"width": 600,
"height": 400,
"drawOutOfBound": True,
"emphasis": {
"textStyle": {"shadowBlur": 10, "shadowColor": "#333"}
},
"data": [
{
"name": "Sam S Club",
"value": 10000,
"textStyle": {"color": "black"},
"emphasis": {"textStyle": {"color": "red"}},
},
{"name": "Macys", "value": 6181},
{"name": "Amy Schumer", "value": 4386},
{"name": "Jurassic World", "value": 4055},
{"name": "Charter Communications", "value": 2467},
{"name": "Chick Fil A", "value": 2244},
{"name": "Planet Fitness", "value": 1898},
{"name": "Pitch Perfect", "value": 1484},
{"name": "Express", "value": 1112},
{"name": "Home", "value": 965},
{"name": "Johnny Depp", "value": 847},
{"name": "Lena Dunham", "value": 582},
{"name": "Lewis Hamilton", "value": 555},
{"name": "KXAN", "value": 550},
{"name": "Mary Ellen Mark", "value": 462},
{"name": "Farrah Abraham", "value": 366},
{"name": "Rita Ora", "value": 360},
{"name": "Serena Williams", "value": 282},
{"name": "NCAA baseball tournament", "value": 273},
{"name": "Point Break", "value": 265},
],
}
],
}
st_echarts(options)
def render_bar_py():
with st.echo("below"):
b = (
Bar()
.add_xaxis(["Microsoft", "Amazon", "IBM", "Oracle", "Google", "Alibaba"])
.add_yaxis(
"2017-2018 Revenue in (billion $)", [21.2, 20.4, 10.3, 6.08, 4, 2.2]
)
.set_global_opts(
title_opts=opts.TitleOpts(
title="Top cloud providers 2018", subtitle="2017-2018 Revenue"
),
toolbox_opts=opts.ToolboxOpts(),
)
)
st_pyecharts(b)
def render_custom_py():
with st.echo("below"):
b = (
Bar()
.add_xaxis(["Microsoft", "Amazon", "IBM", "Oracle", "Google", "Alibaba"])
.add_yaxis(
"2017-2018 Revenue in (billion $)", [21.2, 20.4, 10.3, 6.08, 4, 2.2]
)
.set_global_opts(
title_opts=opts.TitleOpts(
title="Top cloud providers 2018", subtitle="2017-2018 Revenue"
)
)
)
st_pyecharts(b, theme=ThemeType.DARK)
st_pyecharts(
b,
theme={
"backgroundColor": "#f4cccc",
"textStyle": {"color": "rgba(255, 0, 0, 0.8)"},
},
)
def render_filter_legend_py():
with st.echo("below"):
c = (
Bar(
init_opts=opts.InitOpts(
animation_opts=opts.AnimationOpts(
animation_delay=1000, animation_easing="elasticOut"
)
)
)
.add_xaxis(Faker.choose())
.add_yaxis("商家A", Faker.values())
.add_yaxis("商家B", Faker.values())
.set_global_opts(
title_opts=opts.TitleOpts(title="Bar-动画配置基本示例", subtitle="我是副标题")
)
)
st_pyecharts(c)
def render_vertical_datazoom_py():
with st.echo("below"):
c = (
Bar()
.add_xaxis(Faker.days_attrs)
.add_yaxis("商家A", Faker.days_values, color=Faker.rand_color())
.set_global_opts(
title_opts=opts.TitleOpts(title="Bar-DataZoom(slider-垂直)"),
datazoom_opts=opts.DataZoomOpts(orient="vertical"),
)
)
st_pyecharts(c, height="400px")
def render_timeline_py():
with st.echo("below"):
x = Faker.choose()
tl = Timeline()
for i in range(2015, 2020):
bar = (
Bar()
.add_xaxis(x)
.add_yaxis("商家A", Faker.values())
.add_yaxis("商家B", Faker.values())
.set_global_opts(title_opts=opts.TitleOpts("某商店{}年营业额".format(i)))
)
tl.add(bar, "{}年".format(i))
st_pyecharts(tl)
def render_randomize_py():
with st.echo("below"):
b = (
Bar()
.add_xaxis(["Microsoft", "Amazon", "IBM", "Oracle", "Google", "Alibaba"])
.add_yaxis(
"2017-2018 Revenue in (billion $)", random.sample(range(100), 10)
)
.set_global_opts(
title_opts=opts.TitleOpts(
title="Top cloud providers 2018", subtitle="2017-2018 Revenue"
),
toolbox_opts=opts.ToolboxOpts(),
)
)
st_pyecharts(
b, key="echarts"
) # Add key argument to not remount component at every Streamlit run
st.button("Randomize data")
def render_js_py():
with st.echo("below"):
st.markdown(
"""Overwrite chart colors with JS.
Under 50 : red. Between 50 - 100 : blue. Over 100 : green"""
)
color_function = """
function (params) {
if (params.value > 0 && params.value < 50) {
return 'red';
} else if (params.value > 50 && params.value < 100) {
return 'blue';
}
return 'green';
}
"""
c = (
Bar()
.add_xaxis(Faker.choose())
.add_yaxis(
"商家A",
Faker.values(),
itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)),
)
.add_yaxis(
"商家B",
Faker.values(),
itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)),
)
.add_yaxis(
"商家C",
Faker.values(),
itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)),
)
.set_global_opts(title_opts=opts.TitleOpts(title="Bar-自定义柱状颜色"))
)
st_pyecharts(c)
def render_map_py():
with st.echo("below"):
g = (
Geo()
.add_schema(maptype="china")
.add("geo", [list(z) for z in zip(Faker.provinces, Faker.values())])
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(
visualmap_opts=opts.VisualMapOpts(),
title_opts=opts.TitleOpts(title="Geo-基本示例"),
)
)
st_pyecharts(g)
def render_liquid_py():
with st.echo("below"):
c = (
Liquid()
.add("lq", [0.6, 0.7])
.set_global_opts(title_opts=opts.TitleOpts(title="Liquid-基本示例"))
)
st_pyecharts(c)
def render_wordcloud_py():
with st.echo("below"):
data = [
("生活资源", "999"),
("供热管理", "888"),
("供气质量", "777"),
("生活用水管理", "688"),
("一次供水问题", "588"),
("交通运输", "516"),
("城市交通", "515"),
("环境保护", "483"),
("房地产管理", "462"),
("城乡建设", "449"),
("社会保障与福利", "429"),
("社会保障", "407"),
("文体与教育管理", "406"),
("公共安全", "406"),
("公交运输管理", "386"),
("出租车运营管理", "385"),
("供热管理", "375"),
("市容环卫", "355"),
("自然资源管理", "355"),
("粉尘污染", "335"),
("噪声污染", "324"),
("土地资源管理", "304"),
("物业服务与管理", "304"),
("医疗卫生", "284"),
("粉煤灰污染", "284"),
("占道", "284"),
("供热发展", "254"),
("农村土地规划管理", "254"),
("生活噪音", "253"),
("供热单位影响", "253"),
("城市供电", "223"),
("房屋质量与安全", "223"),
("大气污染", "223"),
("房屋安全", "223"),
("文化活动", "223"),
("拆迁管理", "223"),
("公共设施", "223"),
("供气质量", "223"),
("供电管理", "223"),
("燃气管理", "152"),
("教育管理", "152"),
("医疗纠纷", "152"),
("执法监督", "152"),
("设备安全", "152"),
("政务建设", "152"),
("县区、开发区", "152"),
("宏观经济", "152"),
("教育管理", "112"),
("社会保障", "112"),
("生活用水管理", "112"),
("物业服务与管理", "112"),
("分类列表", "112"),
("农业生产", "112"),
("二次供水问题", "112"),
("城市公共设施", "92"),
("拆迁政策咨询", "92"),
("物业服务", "92"),
("物业管理", "92"),
("社会保障保险管理", "92"),
("低保管理", "92"),
("文娱市场管理", "72"),
("城市交通秩序管理", "72"),
("执法争议", "72"),
("商业烟尘污染", "72"),
("占道堆放", "71"),
("地上设施", "71"),
("水质", "71"),
("无水", "71"),
("供热单位影响", "71"),
("人行道管理", "71"),
("主网原因", "71"),
("集中供热", "71"),
("客运管理", "71"),
("国有公交(大巴)管理", "71"),
("工业粉尘污染", "71"),
("治安案件", "71"),
("压力容器安全", "71"),
("身份证管理", "71"),
("群众健身", "41"),
("工业排放污染", "41"),
("破坏森林资源", "41"),
("市场收费", "41"),
("生产资金", "41"),
("生产噪声", "41"),
("农村低保", "41"),
("劳动争议", "41"),
("劳动合同争议", "41"),
("劳动报酬与福利", "41"),
("医疗事故", "21"),
("停供", "21"),
("基础教育", "21"),
("职业教育", "21"),
("物业资质管理", "21"),
("拆迁补偿", "21"),
("设施维护", "21"),
("市场外溢", "11"),
("占道经营", "11"),
("树木管理", "11"),
("农村基础设施", "11"),
("无水", "11"),
("供气质量", "11"),
("停气", "11"),
("市政府工作部门(含部门管理机构、直属单位)", "11"),
("燃气管理", "11"),
("市容环卫", "11"),
("新闻传媒", "11"),
("人才招聘", "11"),
("市场环境", "11"),
("行政事业收费", "11"),
("食品安全与卫生", "11"),
("城市交通", "11"),
("房地产开发", "11"),
("房屋配套问题", "11"),
("物业服务", "11"),
("物业管理", "11"),
("占道", "11"),
("园林绿化", "11"),
("户籍管理及身份证", "11"),
("公交运输管理", "11"),
("公路(水路)交通", "11"),
("房屋与图纸不符", "11"),
("有线电视", "11"),
("社会治安", "11"),
("林业资源", "11"),
("其他行政事业收费", "11"),
("经营性收费", "11"),
("食品安全与卫生", "11"),
("体育活动", "11"),
("有线电视安装及调试维护", "11"),
("低保管理", "11"),
("劳动争议", "11"),
("社会福利及事务", "11"),
("一次供水问题", "11"),
]
c = (
WordCloud()
.add(series_name="热点分析", data_pair=data, word_size_range=[6, 66])
.set_global_opts(
title_opts=opts.TitleOpts(
title="热点分析", title_textstyle_opts=opts.TextStyleOpts(font_size=23)
),
tooltip_opts=opts.TooltipOpts(is_show=True),
)
)
st_pyecharts(c)
if __name__ == "__main__":
st.set_page_config(page_title="Streamlit Echarts Demo", page_icon=":tada:")
main()