Skip to content

Commit 7ebe893

Browse files
committed
gauge
1 parent 92e0895 commit 7ebe893

3 files changed

Lines changed: 142 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,7 +3301,24 @@ def setup_axes():
33013301
main()
33023302
```
33033303

3304+
#### 11 绘制仪表盘
33043305

3306+
使用pip install pyecharts 安装,版本为 v1.6,pyecharts绘制仪表盘,只需要几行代码:
3307+
3308+
```python
3309+
from pyecharts import charts
3310+
3311+
# 仪表盘
3312+
gauge = charts.Gauge()
3313+
gauge.add('Python小例子', [('Python机器学习', 30), ('Python基础', 70.),
3314+
('Python正则', 90)])
3315+
gauge.render(path="./data/仪表盘.html")
3316+
print('ok')
3317+
```
3318+
3319+
仪表盘中共展示三项,每项的比例为30%,70%,90%,如下图默认名称显示第一项:Python机器学习,完成比例为30%
3320+
3321+
![img](https://mmbiz.qpic.cn/sz_mmbiz_png/tdJziaFLKKeSDekiambDPY9lwKibw8MaXMCWBqBTovMIcHEnLLVbF9p1ibEEsAORzp5IzTFLpXP50XpM43FZId3wkA/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1)
33053322

33063323

33073324
### 七、Python实战

data/仪表盘.html

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Awesome-pyecharts</title>
6+
<script type="text/javascript" src="https://assets.pyecharts.org/assets/echarts.min.js"></script>
7+
8+
</head>
9+
<body>
10+
<div id="f5cd32df51c5477eb13923dec3fa265e" class="chart-container" style="width:900px; height:500px;"></div>
11+
<script>
12+
var chart_f5cd32df51c5477eb13923dec3fa265e = echarts.init(
13+
document.getElementById('f5cd32df51c5477eb13923dec3fa265e'), 'white', {renderer: 'canvas'});
14+
var option_f5cd32df51c5477eb13923dec3fa265e = {
15+
"animation": true,
16+
"animationThreshold": 2000,
17+
"animationDuration": 1000,
18+
"animationEasing": "cubicOut",
19+
"animationDelay": 0,
20+
"animationDurationUpdate": 300,
21+
"animationEasingUpdate": "cubicOut",
22+
"animationDelayUpdate": 0,
23+
"color": [
24+
"#c23531",
25+
"#2f4554",
26+
"#61a0a8",
27+
"#d48265",
28+
"#749f83",
29+
"#ca8622",
30+
"#bda29a",
31+
"#6e7074",
32+
"#546570",
33+
"#c4ccd3",
34+
"#f05b72",
35+
"#ef5b9c",
36+
"#f47920",
37+
"#905a3d",
38+
"#fab27b",
39+
"#2a5caa",
40+
"#444693",
41+
"#726930",
42+
"#b2d235",
43+
"#6d8346",
44+
"#ac6767",
45+
"#1d953f",
46+
"#6950a1",
47+
"#918597"
48+
],
49+
"series": [
50+
{
51+
"type": "gauge",
52+
"title": {
53+
"show": true,
54+
"position": "top",
55+
"margin": 8
56+
},
57+
"detail": {
58+
"show": true,
59+
"position": "top",
60+
"margin": 8,
61+
"formatter": "{value}%"
62+
},
63+
"name": "Python\u5c0f\u4f8b\u5b50",
64+
"min": 0,
65+
"max": 100,
66+
"splitNumber": 10,
67+
"startAngle": 225,
68+
"endAngle": -45,
69+
"data": [
70+
{
71+
"name": "Python\u673a\u5668\u5b66\u4e60",
72+
"value": 30
73+
},
74+
{
75+
"name": "Python\u57fa\u7840",
76+
"value": 70.0
77+
},
78+
{
79+
"name": "Python\u6b63\u5219",
80+
"value": 90
81+
}
82+
]
83+
}
84+
],
85+
"legend": [
86+
{
87+
"data": [
88+
"Python\u5c0f\u4f8b\u5b50"
89+
],
90+
"selected": {
91+
"Python\u5c0f\u4f8b\u5b50": true
92+
}
93+
}
94+
],
95+
"tooltip": {
96+
"show": true,
97+
"trigger": "item",
98+
"triggerOn": "mousemove|click",
99+
"axisPointer": {
100+
"type": "line"
101+
},
102+
"textStyle": {
103+
"fontSize": 14
104+
},
105+
"borderWidth": 0
106+
}
107+
};
108+
chart_f5cd32df51c5477eb13923dec3fa265e.setOption(option_f5cd32df51c5477eb13923dec3fa265e);
109+
</script>
110+
</body>
111+
</html>

md/绘制仪表盘.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
使用pip install pyecharts 安装,版本为 v1.6,pyecharts绘制仪表盘,只需要几行代码:
2+
```python
3+
from pyecharts import charts
4+
5+
# 仪表盘
6+
gauge = charts.Gauge()
7+
gauge.add('Python小例子', [('Python机器学习', 30), ('Python基础', 70.),
8+
('Python正则', 90)])
9+
gauge.render(path="./data/仪表盘.html")
10+
print('ok')
11+
```
12+
仪表盘中共展示三项,每项的比例为30%,70%,90%,如下图默认名称显示第一项:Python机器学习,完成比例为30%
13+
14+
![img](https://mmbiz.qpic.cn/sz_mmbiz_png/tdJziaFLKKeSDekiambDPY9lwKibw8MaXMCWBqBTovMIcHEnLLVbF9p1ibEEsAORzp5IzTFLpXP50XpM43FZId3wkA/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1)

0 commit comments

Comments
 (0)