betterme
commited on
Commit
•
0c62912
1
Parent(s):
9317d88
update
Browse files- pages/echarts.py +70 -0
pages/echarts.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
# @Project : AI. @by PyCharm
|
4 |
+
# @File : echarts
|
5 |
+
# @Time : 2023/4/7 11:02
|
6 |
+
# @Author : betterme
|
7 |
+
# @WeChat : meutils
|
8 |
+
# @Software : PyCharm
|
9 |
+
# @Description :
|
10 |
+
|
11 |
+
from pyecharts import options as opts
|
12 |
+
from pyecharts.charts import Bar, WordCloud
|
13 |
+
from streamlit_echarts import st_pyecharts
|
14 |
+
import streamlit as st
|
15 |
+
|
16 |
+
# st.markdown(open('xx.html').read(), unsafe_allow_html=True)
|
17 |
+
|
18 |
+
tab1, tab2, tab3 = st.tabs(["Bar", "WordCloud", "Owl"])
|
19 |
+
|
20 |
+
with tab1:
|
21 |
+
b = (
|
22 |
+
Bar()
|
23 |
+
.add_xaxis(["Microsoft", "Amazon", "IBM", "Oracle", "Google", "Alibaba"])
|
24 |
+
.add_yaxis(
|
25 |
+
"2017-2018 Revenue in (billion $)", [21.2, 20.4, 10.3, 6.08, 4, 2.2]
|
26 |
+
)
|
27 |
+
.set_global_opts(
|
28 |
+
title_opts=opts.TitleOpts(
|
29 |
+
title="Top cloud providers 2018", subtitle="2017-2018 Revenue"
|
30 |
+
),
|
31 |
+
toolbox_opts=opts.ToolboxOpts(),
|
32 |
+
)
|
33 |
+
)
|
34 |
+
st_pyecharts(b)
|
35 |
+
|
36 |
+
with tab2:
|
37 |
+
pairs = [('中国', 33),
|
38 |
+
('苹果', 24),
|
39 |
+
('奚梦瑶', 20),
|
40 |
+
('美国', 16),
|
41 |
+
('特朗普', 16),
|
42 |
+
('何猷君', 15),
|
43 |
+
('戛纳', 13),
|
44 |
+
('红毯', 12),
|
45 |
+
('iPhone', 12),
|
46 |
+
('车队', 9),
|
47 |
+
('车祸', 9),
|
48 |
+
('优衣', 9),
|
49 |
+
('信息', 9),
|
50 |
+
('李亚鹏', 9),
|
51 |
+
('恋情', 9),
|
52 |
+
('任素', 9),
|
53 |
+
('男孩', 9),
|
54 |
+
('亚洲', 8),
|
55 |
+
('孩子', 8),
|
56 |
+
('大学生', 8)]
|
57 |
+
shapes = ['circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star']
|
58 |
+
|
59 |
+
wc = (
|
60 |
+
WordCloud()
|
61 |
+
.add("WordCloud", data_pair=pairs, shape=shapes[0], width='900px', height='500px')
|
62 |
+
|
63 |
+
.set_global_opts(
|
64 |
+
title_opts=opts.TitleOpts(
|
65 |
+
title="WordCloud", subtitle="WordCloud"
|
66 |
+
),
|
67 |
+
toolbox_opts=opts.ToolboxOpts(), )
|
68 |
+
)
|
69 |
+
|
70 |
+
st_pyecharts(wc)
|