我是靠谱客的博主 明理裙子,这篇文章主要介绍带字圆环的vue组件,现在分享给大家,希望可以做个参考。

复制代码
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
<template> <div class="my-echarts"> <div :class="dataList.length>0 ? 'my-echarts-div':''" :id="id" v-if="dataList.length" @focus="canvasFocus()" @blur="canvasBlur()"></div> <div v-else class="no-data-box"> <c-no-data class="my-echarts-div" title="数据抓取中,暂无数据"></c-no-data> </div> </div> </template> <script> import EChartss from 'echarts' import CNoData from '@/components/frontZone/CNoData' import {numToMyriad} from '@/utils/tools' export default { components: { CNoData }, data () { return { options: {}, // 设置 id: `echart${Math.ceil(Math.random() * 1000)}`, colorObj: { // 表的颜色 item: this.item, area: this.area } } }, props: { dataList: { // 数据源 纵坐标 数组 type: Array, // 数组类型,也可以是Object default: () => [0, 1, 2, 3, 4, 5, 67] }, item: { // 表的颜色 type: String, default: '#724CFE' }, color: { type: Array, default: () => ['#cabffe', '#efefef'] }, text: { type: Number, default: 0 }, name: { type: String, default: 'name' } }, created () { }, mounted () { this.init() }, methods: { init () { this.$nextTick(() => { if (this.dataList.length > 0) { this.chart = EChartss.init(document.getElementById(this.id)) this.setChart() } }) }, canvasFocus () { this.options.dataZoom[0].zoomOnMouseWheel = true this.chart.setOption(this.options) }, canvasBlur () { this.options.dataZoom[0].zoomOnMouseWheel = false this.chart.setOption(this.options) }, /* * 需要数据原和名字 * */ setChart () { let max = _.max(this.dataList) let min = _.min(this.dataList) let delta = max - min let colorObj = this.colorObj let nightRange = [[{xAxis: 0}, {xAxis: 0}]] let dataList dataList = this.rowList let data = this.dataList this.options = this.getCommonOptions({ dataList, // 横坐标 delta, isScale: delta > 10, seriesName: this.name, nightRange, colorObj, data }) this.$nextTick(() => { this.chart.setOption(this.options) }) }, getCommonOptions (obj) { return { legend: { // 配置图例 itemWidth: 5, // 图例大小 我这里用的是圆 itemGap: 30, // 图例之间的间隔 orient: 'horizontal', // 布局方式,默认水平布局,另可选vertical y: '80%', // 垂直放的位置,可以写top,center,bottom,也可以写px或者百分比。x轴方向同理,默认center icon: 'circle', // 图例的形状,选择类型有:"circle"(圆形)、"rectangle"(长方形)、"triangle"(三角形)、"diamond"(菱形)、"emptyCircle"(空心圆)、 show: false, selectedMode: true, // 选中哪个图例 false后图例不可点击 textStyle: { fontSize: 14, fontFamily: 'Microsoft YaHei' } }, color: ['#35dae6', '#7848f4'], // 环形图两部分的颜色 graphic: [{// 环形图中间添加文字 type: 'text', // 通过不同top值可以设置上下显示 left: 'center', top: '40%', style: { text: '赚钱能力(流水)', textAlign: 'center', fill: '#000', // 文字的颜色 width: 30, height: 40, fontSize: 18, color: '#4d4f5c', fontFamily: 'Microsoft YaHei' } }, { type: 'text', left: 'center', top: '55%', style: { text: numToMyriad(this.text), textAlign: 'center', fill: '#000', width: 30, height: 40, fontSize: 18 } }], series: [// 配置数据啥的 { name: '达标率', type: 'pie', // 设为饼图 radius: ['68%', '90%'], // 设置内半径和外半径,形成环状 minAngle: 5, // 设置最小角度 startAngle: 90, // 设置起始角度 clockWise: true, // 默认逆时针 avoidLabelOverlap: false, // 避免标注重叠 hoverAnimation: true, // 移入放大 silent: true, center: ['50%', '50%'], label: { normal: { show: false, position: 'center' }, emphasis: { show: false, textStyle: { fontSize: '30', fontWeight: 'bold' } } }, labelLine: { normal: { show: false } }, data: this.dataList } ] } } }, watch: { dataList: { handler (newV, oldV) { this.dataList = newV this.init() }, deep: true }, rowList: { handler (newV, oldV) { this.rowList = newV this.init() }, deep: true } } } </script> <style lang="scss"> .el-loading-mask { z-index: 9; } @media screen and (max-width: 1640px) { .no-data { padding: 80px 0 40px 0; } } </style> <style lang="scss" scoped> @import 'assets/styles/monitor-report.scss'; .my-echarts-div { width: 250px; height: 250px; } .my-echarts { width: 250px; height: 250px; /*padding-bottom: 50px;*/ } </style>

在这里插入图片描述
带字圆环的vue组件

最后

以上就是明理裙子最近收集整理的关于带字圆环的vue组件的全部内容,更多相关带字圆环内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(56)

评论列表共有 0 条评论

立即
投稿
返回
顶部