# 9.3 饼状图
此组件为APP内置组件,不需要前端import导入, 可直接在template里使用。
# 实例 :
饼状图
扫码预览
# 基础用法
<template>
<div class="wrapper">
<dof-minibar title="饼状图"></dof-minibar>
<scroller>
<div class="title">
<text class="title_text">基本环形图</text>
</div>
<div class="content_box">
<text class="content_text">数据详情</text>
<div class="content">
<midea-piechart-view class="chart" :data="chartData"></midea-piechart-view>
<div class="piechart_inner">
<text class="inner_text">Cost today</text>
<text class="inner_val">25度</text>
</div>
<div class="tip_right">
<div v-for="(item, i) in right_data" :key="i" class="tip_item_box">
<div class="tip_item">
<div class="tip_color" :style="{ backgroundColor: item.color }"></div>
<text class="tip_text">{{ item.text }}</text>
</div>
<text class="tip_val">{{ item.val }}</text>
</div>
</div>
</div>
<text class="content_text m-t-32">数据详情-数据加载中</text>
<div class="content">
<midea-piechart-view class="chart" :data="chartData2"></midea-piechart-view>
<div class="piechart_inner">
<text class="inner_text">Cost today</text>
<text class="inner_val">- -</text>
</div>
<div class="tip_right">
<div v-for="(item, i) in right_data2" :key="i" class="tip_item_box">
<div class="tip_item">
<div class="tip_color" :style="{ backgroundColor: item.color }"></div>
<text class="tip_text">{{ item.text }}</text>
</div>
<text class="tip_val">{{ item.val }}</text>
</div>
</div>
</div>
</div>
</scroller>
</div>
</template>
<style scoped>
.wrapper {
background-color: #f2f2f2;
}
.title {
background-color: #e5e5e8;
height: 104px;
padding: 0 32px;
display: flex;
flex-direction: row;
align-items: center;
}
.title_text {
font-family: PingFangSC-Medium;
font-size: 36px;
color: #000000;
}
.content_box {
padding: 48px 32px;
}
.content_text {
font-family: PingFangSC-Semibold;
font-size: 36px;
color: #333333;
font-weight: 600;
margin-bottom: 20px;
}
.content {
background: #ffffff;
box-shadow: 0 1px 10px 0 rgba(0, 0, 0, 0.04);
border-radius: 32px;
min-height: 600px;
display: flex;
flex-direction: row;
align-items: center;
position: relative;
}
.chart {
width: 500px;
height: 500px;
}
.piechart_inner {
position: absolute;
width: 180px;
height: 180px;
border-radius: 90px;
background-color: #f9f9f9;
left: 160px;
top: 210px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.inner_text {
font-family: PingFangSC-Regular;
font-size: 24px;
color: rgba(94, 94, 94, 0.58);
}
.inner_val {
font-family: PingFangSC-Regular;
font-size: 36px;
color: #5e5e5e;
margin-top: 10px;
}
.tip_item_box {
margin-bottom: 20px;
}
.tip_item {
display: flex;
flex-direction: row;
align-items: center;
}
.tip_color {
width: 16px;
height: 16px;
border-radius: 8px;
margin-right: 8px;
}
.tip_text {
font-family: PingFangSC-Regular;
font-size: 28px;
color: rgba(94, 94, 94, 0.58);
}
.tip_val {
font-family: PingFangSC-Regular;
font-size: 32px;
color: #5e5e5e;
}
.m-t-32 {
margin-top: 32px;
}
</style>
<script>
import { DofMinibar } from 'dolphin-weex-ui'
export default {
components: { DofMinibar },
data: () => ({
chartData: {
data: {
piechartdata: {
unit: '',
piename: '',
total: '',
totalnumber: '',
datalist: [
{
numdata: '45',
colorvalue: '#10C2FF'
},
{
numdata: '45',
colorvalue: '#FF6A4C'
},
{
numdata: '10',
colorvalue: '#6575FF'
},
{
numdata: '20',
colorvalue: '#267AFF'
},
{
numdata: '60',
colorvalue: '#FEAC15'
}
]
}
}
},
right_data: [
{ color: '#6575FF', text: 'TBH', val: '100kWh' },
{ color: '#10C2FF', text: 'Cooling', val: '52kWh' },
{ color: '#267AFF', text: 'IBH', val: '100kWh' },
{ color: '#FEAC15', text: 'Heating', val: '100kWh' },
{ color: '#FF6A4C', text: 'DHW', val: '53kWh' }
],
chartData2: {
data: {
piechartdata: {
unit: '',
piename: '',
total: '',
totalnumber: '',
totalNumberColor: '#6575FF',
totalNumberTextSize: 14,
nameColor: '',
nameTextSize: 14,
itemLabelShow: false,
itemLabelTextColor: '',
bgColor: '',
radius: 10,
innerRadiusPercent: 0.8,
lineWidth: 0,
innerBgColor: '',
rotationAngle: 110,
needSort: true,
datalist: [
{
eachname: '',
numdata: '1',
colorvalue: '#F9F9F9'
}
]
}
}
},
right_data2: [
{ color: '#6575FF', text: 'TBH', val: '- -' },
{ color: '#10C2FF', text: 'Cooling', val: '- -' },
{ color: '#267AFF', text: 'IBH', val: '- -' },
{ color: '#FEAC15', text: 'Heating', val: '- -' },
{ color: '#FF6A4C', text: 'DHW', val: '- -' }
]
}),
methods: {}
}
</script>
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
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
# Attributes
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
piechartdata | Object | Y | {} | 配置参数 |
# 参数详情: piechartdata (注 1)
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
unit | string | N | `` | 单位 |
piename | string | N | `` | 柱状图中间文字 |
nameColor | string | N | `` | 柱状图中间文字颜色 |
nameTextSize | number | N | `` | 柱状图中间文字大小 |
total | number | N | `` | 总分段数 |
totalnumber | number | N | `` | 饼状图中间数字 |
totalNumberColor | string | N | `` | 饼状图中间数字颜色 |
totalNumberTextSize | number | N | `` | 饼状图中间数字大小 |
itemLabelShow | boolean | N | `` | 外层文本是否显示 |
itemLabelTextColor | string | N | `` | 外层文本颜色 |
bgColor | string | N | `` | 背景颜色 |
radius | number | N | `` | 饼图半径 |
innerRadiusPercent | number | N | `` | 内圆半径 取值0-1 |
lineWidth | number | N | `` | 外圈宽度 |
innerBgColor | string | N | `` | 内圆背景色 |
rotationAngle | number | N | `` | 开始角度 默认110度 |
needSort | boolean | N | `` | 是否需要排序 Android之前会对数据排序,为了和ios一致新增加这个字段,默认是true, 改成false就和ios一致了 |
datalist | array | N | [] | 饼状图分段配置 |
# 参数详情:datalist (注 1)
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
eachname | string | N | `` | 分段名称 |
numdata | number | Y | `` | 分段占比权重 |
colorvalue | string | Y | `` | 分段颜色 |