-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.py
108 lines (60 loc) · 1.82 KB
/
example.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
#!/usr/bin/env python
# coding: utf-8
# In[3]:
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.charts import Boxplot
# In[4]:
def boxpolt_base() -> Boxplot:
v1 = [
[850, 740, 900, 1070, 930, 850, 950, 980, 980, 880]
+ [1000, 980, 930, 650, 760, 810, 1000, 1000, 960, 960],
[960, 940, 960, 940, 880, 800, 850, 880, 900]
+ [840, 830, 790, 810, 880, 880, 830, 800, 790, 760, 800],
]
v2 = [
[890, 810, 810, 820, 800, 770, 760, 740, 750, 760]
+ [910, 920, 890, 860, 880, 720, 840, 850, 850, 780],
[890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870]
+ [870, 810, 740, 810, 940, 950, 800, 810, 870],
]
c = Boxplot()
c.add_xaxis(["expr1", "expr2"]).add_yaxis("A", c.prepare_data(v1)).add_yaxis(
"B", c.prepare_data(v2)
).set_global_opts(title_opts=opts.TitleOpts(title="BoxPlot-基本示例"))
return c
# In[6]:
bar = (
Bar()
.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
.set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题"))
)
chart = boxpolt_base()
# In[8]:
#from pyecharts_dashboard.dashboard import Dashboard
from dashboard import Dashboard
# In[10]:
#示例化对象,需设置浏览器类型
dashboard = Dashboard('chrome')
# In[11]:
#添加图纸1
dashboard.add(bar)
# In[12]:
#添加图纸2
dashboard.add(chart)
# In[13]:
#打开UI界面
dashboard.render()
# In[17]:
#预览结果
dashboard.preview()
# In[15]:
#设置分辨率,并刷新
dashboard.resolution = (1920,1080)
dashboard.render()
# In[16]:
#保存当前布局,结果保存在当前文件下的html文件夹中
dashboard.save()
# In[ ]: