File size: 2,008 Bytes
0c62912
 
 
 
 
 
 
 
 
 
c2f20b2
 
0c62912
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Project      : AI.  @by PyCharm
# @File         : echarts
# @Time         : 2023/4/7 11:02
# @Author       : betterme
# @WeChat       : meutils
# @Software     : PyCharm
# @Description  : 

from _pyecharts import options as opts
from _pyecharts.charts import Bar, WordCloud
from streamlit_echarts import st_pyecharts
import streamlit as st

# st.markdown(open('xx.html').read(), unsafe_allow_html=True)

tab1, tab2, tab3 = st.tabs(["Bar", "WordCloud", "Owl"])

with tab1:
    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)

with tab2:
    pairs = [('中国', 33),
             ('苹果', 24),
             ('奚梦瑶', 20),
             ('美国', 16),
             ('特朗普', 16),
             ('何猷君', 15),
             ('戛纳', 13),
             ('红毯', 12),
             ('iPhone', 12),
             ('车队', 9),
             ('车祸', 9),
             ('优衣', 9),
             ('信息', 9),
             ('李亚鹏', 9),
             ('恋情', 9),
             ('任素', 9),
             ('男孩', 9),
             ('亚洲', 8),
             ('孩子', 8),
             ('大学生', 8)]
    shapes = ['circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star']

    wc = (
        WordCloud()
        .add("WordCloud", data_pair=pairs, shape=shapes[0], width='900px', height='500px')

        .set_global_opts(
            title_opts=opts.TitleOpts(
                title="WordCloud", subtitle="WordCloud"
            ),
            toolbox_opts=opts.ToolboxOpts(), )
    )

    st_pyecharts(wc)