@travel-screen/l-module-components 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/package.json +34 -0
- package/src/index.js +60 -0
- package/src/l-bar-chart/README.md +302 -0
- package/src/l-bar-chart/index.vue +405 -0
- package/src/l-bar-chart/interface/index.js +210 -0
- package/src/l-data-panel/README.md +331 -0
- package/src/l-data-panel/img/images.js +47 -0
- package/src/l-data-panel/img/l-data-panel_bg_1.png +0 -0
- package/src/l-data-panel/img/l-data-panel_bg_2.png +0 -0
- package/src/l-data-panel/img/l-data-panel_bg_3.png +0 -0
- package/src/l-data-panel/index.vue +150 -0
- package/src/l-data-panel/interface/index.js +249 -0
- package/src/l-data-ring/README.md +292 -0
- package/src/l-data-ring/img/images.js +21 -0
- package/src/l-data-ring/img/l-data-ring_bg.png +0 -0
- package/src/l-data-ring/index.vue +93 -0
- package/src/l-data-ring/interface/index.js +116 -0
- package/src/l-date-picker/README.md +276 -0
- package/src/l-date-picker/index.vue +185 -0
- package/src/l-date-picker/interface/index.js +128 -0
- package/src/l-icon-label/README.md +356 -0
- package/src/l-icon-label/img/images.js +28 -0
- package/src/l-icon-label/img/l-icon-label_bg.png +0 -0
- package/src/l-icon-label/img/l-icon-label_icon.png +0 -0
- package/src/l-icon-label/index.vue +162 -0
- package/src/l-icon-label/interface/index.js +234 -0
- package/src/l-label-value/README.md +358 -0
- package/src/l-label-value/img/images.js +19 -0
- package/src/l-label-value/img/l-label-value_line.png +0 -0
- package/src/l-label-value/index.vue +132 -0
- package/src/l-label-value/interface/index.js +116 -0
- package/src/l-metric-tile/README.md +391 -0
- package/src/l-metric-tile/img/images.js +19 -0
- package/src/l-metric-tile/img/l-metric-tile_bg_1.png +0 -0
- package/src/l-metric-tile/index.vue +138 -0
- package/src/l-metric-tile/interface/index.js +241 -0
- package/src/l-module-box/README.md +289 -0
- package/src/l-module-box/img/images.js +28 -0
- package/src/l-module-box/img/l-module-box_bg.png +0 -0
- package/src/l-module-box/img/l-module-box_icon.png +0 -0
- package/src/l-module-box/index.vue +125 -0
- package/src/l-module-box/interface/index.js +93 -0
- package/src/l-module-tag/README.md +243 -0
- package/src/l-module-tag/index.vue +137 -0
- package/src/l-module-tag/interface/index.js +91 -0
- package/src/l-rank-list/README.md +553 -0
- package/src/l-rank-list/img/images.js +34 -0
- package/src/l-rank-list/img/l-rank-list_icon_line.png +0 -0
- package/src/l-rank-list/img/l-rank-list_icon_rank_1.png +0 -0
- package/src/l-rank-list/img/l-rank-list_icon_rank_2.png +0 -0
- package/src/l-rank-list/img/l-rank-list_icon_rank_other.png +0 -0
- package/src/l-rank-list/index.vue +610 -0
- package/src/l-rank-list/interface/index.js +343 -0
- package/src/l-stat-card/README.md +309 -0
- package/src/l-stat-card/img/images.js +36 -0
- package/src/l-stat-card/img/img-bg.png +0 -0
- package/src/l-stat-card/img/l-stat-card_img_1.png +0 -0
- package/src/l-stat-card/index.vue +136 -0
- package/src/l-stat-card/interface/index.js +159 -0
- package/src/l-tabs/README.md +285 -0
- package/src/l-tabs/img/images.js +19 -0
- package/src/l-tabs/img/l-tabs_bg.png +0 -0
- package/src/l-tabs/index.vue +97 -0
- package/src/l-tabs/interface/index.js +115 -0
- package/src/l-trend-card/README.md +415 -0
- package/src/l-trend-card/img/images.js +41 -0
- package/src/l-trend-card/img/l-trend-card_bg.png +0 -0
- package/src/l-trend-card/img/l-trend-card_icon_1.png +0 -0
- package/src/l-trend-card/img/l-trend-card_icon_down.png +0 -0
- package/src/l-trend-card/img/l-trend-card_icon_up.png +0 -0
- package/src/l-trend-card/index.vue +181 -0
- package/src/l-trend-card/interface/index.js +243 -0
- package/src/utils/tooltip.js +30 -0
- package/src/utils/util.js +27 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="echartsBox" class="l-bar-chart" :style="{ height: height, width: width }" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import * as echarts from 'echarts'
|
|
7
|
+
import interfaceObj from './interface/index'
|
|
8
|
+
import { tooltipItemsHtmlString } from '../../utils/tooltip'
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
name: 'LBarChart',
|
|
12
|
+
props: interfaceObj,
|
|
13
|
+
data() {
|
|
14
|
+
return {
|
|
15
|
+
chart: null
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
watch: {
|
|
19
|
+
dataList: {
|
|
20
|
+
handler() {
|
|
21
|
+
this.initChart()
|
|
22
|
+
},
|
|
23
|
+
deep: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
beforeDestroy() {
|
|
27
|
+
if (!this.chart) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
this.chart.dispose()
|
|
31
|
+
this.chart = null
|
|
32
|
+
},
|
|
33
|
+
mounted() {
|
|
34
|
+
if (this.dataList.length > 0) {
|
|
35
|
+
this.initChart()
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
methods: {
|
|
39
|
+
// 销毁图表实例
|
|
40
|
+
cDispose() {
|
|
41
|
+
this.chart.dispose()
|
|
42
|
+
this.chart = null
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// 导出图表为图片(可供外部调用)
|
|
46
|
+
exportChartImage(options = {}) {
|
|
47
|
+
if (!this.chart) return null
|
|
48
|
+
const fileName = options.fileName || this.exportFileName
|
|
49
|
+
const pixelRatio = options.pixelRatio || this.exportPixelRatio
|
|
50
|
+
const type = options.type || this.exportType
|
|
51
|
+
const url = this.chart.getDataURL({
|
|
52
|
+
type: `image/${type}`,
|
|
53
|
+
pixelRatio: pixelRatio,
|
|
54
|
+
backgroundColor: '#fff'
|
|
55
|
+
})
|
|
56
|
+
const link = document.createElement('a')
|
|
57
|
+
link.download = `${fileName}.${type}`
|
|
58
|
+
link.href = url
|
|
59
|
+
link.click()
|
|
60
|
+
return url
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// 导出数据为CSV格式
|
|
64
|
+
exportDataCSV(fileName = this.exportFileName) {
|
|
65
|
+
const [..._temp] = this.dataList || []
|
|
66
|
+
const [_type, xData, sData] = [..._temp]
|
|
67
|
+
if (!_type || !xData || !sData) return
|
|
68
|
+
|
|
69
|
+
// 构建CSV头部
|
|
70
|
+
let csv = '\uFEFF' // BOM头,解决中文乱码
|
|
71
|
+
csv += '时间,' + _type.join(',') + '\n'
|
|
72
|
+
|
|
73
|
+
// 构建数据行
|
|
74
|
+
xData.forEach((x, i) => {
|
|
75
|
+
const row = ['\t' + x]
|
|
76
|
+
sData.forEach(series => {
|
|
77
|
+
row.push(series[i] ?? '')
|
|
78
|
+
})
|
|
79
|
+
csv += row.join(',') + '\n'
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
// 下载文件
|
|
83
|
+
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })
|
|
84
|
+
const link = document.createElement('a')
|
|
85
|
+
link.href = URL.createObjectURL(blob)
|
|
86
|
+
link.download = `${fileName}.csv`
|
|
87
|
+
link.click()
|
|
88
|
+
URL.revokeObjectURL(link.href)
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// 初始化图表
|
|
92
|
+
initChart() {
|
|
93
|
+
this.chart = echarts.init(this.$el, 'macarons')
|
|
94
|
+
this.setOption()
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
// 设置图表配置项
|
|
98
|
+
setOption() {
|
|
99
|
+
const _this = this
|
|
100
|
+
const fontColor = this.fontColor
|
|
101
|
+
const [..._temp] = _this.dataList || []
|
|
102
|
+
const [_type, xData, sData] = [..._temp]
|
|
103
|
+
|
|
104
|
+
// 判断是否需要显示滚动条
|
|
105
|
+
const xDataCount = xData ? xData.length : 0
|
|
106
|
+
let shouldShowDataZoom = false
|
|
107
|
+
if (this.showDataZoom === true) {
|
|
108
|
+
shouldShowDataZoom = true
|
|
109
|
+
} else if (this.showDataZoom === 'auto') {
|
|
110
|
+
shouldShowDataZoom = xDataCount > this.dataZoomThreshold
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 如果显示滚动条,需要增加 bottom 空间
|
|
114
|
+
const extraBottom = shouldShowDataZoom ? this.dataZoomHeight + 10 : 0
|
|
115
|
+
|
|
116
|
+
// 合并网格配置
|
|
117
|
+
const grid = Object.assign({}, {
|
|
118
|
+
left: 40,
|
|
119
|
+
right: 20,
|
|
120
|
+
top: 100,
|
|
121
|
+
bottom: 22 + extraBottom,
|
|
122
|
+
containLabel: true
|
|
123
|
+
}, this.grid)
|
|
124
|
+
|
|
125
|
+
// 合并渐变色配置
|
|
126
|
+
let colorList = [
|
|
127
|
+
{ color1: 'rgba(255, 199, 61, 1)', color2: 'rgba(255, 199, 61, .5)', color3: 'rgba(255, 199, 61, .1)' },
|
|
128
|
+
{ color1: 'rgba(154, 252, 135, 1)', color2: 'rgba(154, 252, 135, .5)', color3: 'rgba(154, 252, 135, .1)' }
|
|
129
|
+
]
|
|
130
|
+
colorList = [..._this.lineColor, ...colorList]
|
|
131
|
+
|
|
132
|
+
// 构建 series 数据
|
|
133
|
+
const dataSeries = []
|
|
134
|
+
sData.forEach(function(item, i, arr) {
|
|
135
|
+
dataSeries.push({
|
|
136
|
+
name: _type[i],
|
|
137
|
+
type: 'bar',
|
|
138
|
+
yAxisIndex: 0,
|
|
139
|
+
data: item,
|
|
140
|
+
barWidth: _this.barWidth,
|
|
141
|
+
barGap: 1,
|
|
142
|
+
color: colorList[i].color1,
|
|
143
|
+
itemStyle: {
|
|
144
|
+
barBorderRadius: _this.barBorderRadius,
|
|
145
|
+
color: function(params) {
|
|
146
|
+
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
147
|
+
{ offset: 0, color: colorList[i].color1 }, // 0% 处的颜色
|
|
148
|
+
{ offset: 1, color: colorList[i].color3 } // 100% 处的颜色
|
|
149
|
+
])
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
// 当 showToolbox 为 true 时,legend 和 toolbox 都在右侧,legend 向左偏移空出 toolbox 空间
|
|
156
|
+
// toolbox 大约需要 80px 宽度(3个图标 + 间距)
|
|
157
|
+
const toolboxWidth = 80
|
|
158
|
+
const legendRight = this.showToolbox ? toolboxWidth : 0
|
|
159
|
+
const legendPadding = this.showToolbox ? [15, 0, 0, 0] : [15, 20, 0, 0]
|
|
160
|
+
|
|
161
|
+
const option = {
|
|
162
|
+
grid: grid,
|
|
163
|
+
legend: {
|
|
164
|
+
icon: this.legendIcon,
|
|
165
|
+
top: this.legendTop,
|
|
166
|
+
right: legendRight,
|
|
167
|
+
itemWidth: this.itemWidth,
|
|
168
|
+
itemHeight: this.itemHeight,
|
|
169
|
+
padding: legendPadding,
|
|
170
|
+
textStyle: {
|
|
171
|
+
color: fontColor,
|
|
172
|
+
fontSize: this.fontSize,
|
|
173
|
+
fontFamily: 'SourceHanSerifCN-Regular'
|
|
174
|
+
},
|
|
175
|
+
show: this.legendIsShow
|
|
176
|
+
},
|
|
177
|
+
tooltip: {
|
|
178
|
+
show: true,
|
|
179
|
+
trigger: 'axis',
|
|
180
|
+
confine: true,
|
|
181
|
+
backgroundColor: 'rgba(0, 0, 0, 1)',
|
|
182
|
+
textStyle: {
|
|
183
|
+
fontSize: this.toolSize || this.fontSize
|
|
184
|
+
},
|
|
185
|
+
formatter(params) {
|
|
186
|
+
return `<div>
|
|
187
|
+
<p class="tooltip-title">${params[0].name}</p>
|
|
188
|
+
${tooltipItemsHtmlString(params)}
|
|
189
|
+
</div>`
|
|
190
|
+
},
|
|
191
|
+
className: 'echarts-tooltip-diy'
|
|
192
|
+
},
|
|
193
|
+
xAxis: {
|
|
194
|
+
type: 'category',
|
|
195
|
+
data: xData,
|
|
196
|
+
splitLine: {
|
|
197
|
+
show: false,
|
|
198
|
+
lineStyle: {
|
|
199
|
+
color: '#203A6F',
|
|
200
|
+
width: 1
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
axisLine: {
|
|
204
|
+
show: false,
|
|
205
|
+
lineStyle: {
|
|
206
|
+
color: '#233D80'
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
axisTick: {
|
|
210
|
+
show: false
|
|
211
|
+
},
|
|
212
|
+
axisLabel: {
|
|
213
|
+
interval: this.interval,
|
|
214
|
+
color: fontColor,
|
|
215
|
+
fontSize: this.fontSize,
|
|
216
|
+
formatter: (value) => {
|
|
217
|
+
if (this.interval === 0) {
|
|
218
|
+
return value.length > 2 ? value.substring(0, 2) + '...' : value
|
|
219
|
+
} else {
|
|
220
|
+
return value
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
yAxis: [
|
|
226
|
+
{
|
|
227
|
+
type: 'value',
|
|
228
|
+
name: this.title,
|
|
229
|
+
min: 0,
|
|
230
|
+
max: this.yMax,
|
|
231
|
+
interval: this.yInterval,
|
|
232
|
+
nameTextStyle: {
|
|
233
|
+
color: '#F7F7F7',
|
|
234
|
+
fontSize: this.fontSize,
|
|
235
|
+
fontWeight: 400,
|
|
236
|
+
padding: [0, 0, 0, 50]
|
|
237
|
+
},
|
|
238
|
+
splitLine: {
|
|
239
|
+
show: true,
|
|
240
|
+
lineStyle: {
|
|
241
|
+
color: 'rgba(243, 244, 244, 0.3)',
|
|
242
|
+
type: 'dashed'
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
axisLine: {
|
|
246
|
+
show: false,
|
|
247
|
+
lineStyle: {
|
|
248
|
+
color: '#233D80'
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
axisTick: {
|
|
252
|
+
show: false
|
|
253
|
+
},
|
|
254
|
+
axisLabel: {
|
|
255
|
+
show: this.axisLabelShow,
|
|
256
|
+
color: fontColor,
|
|
257
|
+
fontSize: this.fontSize ? this.fontSize : 'inherit'
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
series: dataSeries
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// 添加 toolbox 配置
|
|
265
|
+
if (this.showToolbox) {
|
|
266
|
+
option.toolbox = {
|
|
267
|
+
show: true,
|
|
268
|
+
right: 20,
|
|
269
|
+
top: 10,
|
|
270
|
+
itemSize: 12,
|
|
271
|
+
itemGap: 10,
|
|
272
|
+
// 图标样式 - 设置为白色
|
|
273
|
+
iconStyle: {
|
|
274
|
+
borderColor: fontColor,
|
|
275
|
+
color: fontColor
|
|
276
|
+
},
|
|
277
|
+
// 鼠标悬停样式
|
|
278
|
+
emphasis: {
|
|
279
|
+
iconStyle: {
|
|
280
|
+
borderColor: '#409EFF',
|
|
281
|
+
color: '#409EFF'
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
feature: {
|
|
285
|
+
saveAsImage: {
|
|
286
|
+
show: true,
|
|
287
|
+
title: '保存为图片',
|
|
288
|
+
pixelRatio: this.exportPixelRatio,
|
|
289
|
+
type: this.exportType,
|
|
290
|
+
name: this.exportFileName,
|
|
291
|
+
backgroundColor: 'transparent',
|
|
292
|
+
iconStyle: {
|
|
293
|
+
borderColor: '#fff'
|
|
294
|
+
},
|
|
295
|
+
emphasis: {
|
|
296
|
+
iconStyle: {
|
|
297
|
+
borderColor: '#409EFF'
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
dataView: {
|
|
302
|
+
show: this.showDataView,
|
|
303
|
+
title: '数据视图',
|
|
304
|
+
lang: ['数据视图', '关闭', '刷新'],
|
|
305
|
+
optionToContent: () => {
|
|
306
|
+
let table = '<table style="width:100%;text-align:center;border-collapse:collapse;"><tbody>'
|
|
307
|
+
table += '<tr style="background:#f5f5f5;"><th style="padding:8px;border:1px solid #ddd;">时间</th>'
|
|
308
|
+
_type.forEach(t => {
|
|
309
|
+
table += `<th style="padding:8px;border:1px solid #ddd;">${t}</th>`
|
|
310
|
+
})
|
|
311
|
+
table += '</tr>'
|
|
312
|
+
xData.forEach((x, i) => {
|
|
313
|
+
table += `<tr><td style="padding:8px;border:1px solid #ddd;">${x}</td>`
|
|
314
|
+
sData.forEach(series => {
|
|
315
|
+
table += `<td style="padding:8px;border:1px solid #ddd;">${series[i] ?? ''}</td>`
|
|
316
|
+
})
|
|
317
|
+
table += '</tr>'
|
|
318
|
+
})
|
|
319
|
+
table += '</tbody></table>'
|
|
320
|
+
return table
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
myExportCSV: {
|
|
324
|
+
show: true,
|
|
325
|
+
title: '导出CSV',
|
|
326
|
+
icon: 'path://M432.45,595.55c-43.55,0-78.85,35.35-78.85,78.85s35.35,78.85,78.85,78.85c43.55,0,78.85-35.35,78.85-78.85S475.95,595.55,432.45,595.55z M512,128H128v512h64v-448h320v192h192v256h64V256L512,128z M480,256V128l128,128H480z M224,640h64v128h-64V640z M320,576h64v192h-64V576z M416,608h64v160h-64V608z',
|
|
327
|
+
onclick: () => {
|
|
328
|
+
_this.exportDataCSV()
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// 添加 X 轴滚动条配置
|
|
336
|
+
if (shouldShowDataZoom) {
|
|
337
|
+
option.dataZoom = [
|
|
338
|
+
{
|
|
339
|
+
type: 'slider',
|
|
340
|
+
show: true,
|
|
341
|
+
xAxisIndex: 0,
|
|
342
|
+
start: this.dataZoomStart,
|
|
343
|
+
end: this.dataZoomEnd,
|
|
344
|
+
height: this.dataZoomHeight,
|
|
345
|
+
bottom: 5,
|
|
346
|
+
borderColor: 'transparent',
|
|
347
|
+
backgroundColor: 'rgba(35, 61, 128, 0.3)',
|
|
348
|
+
fillerColor: 'rgba(64, 158, 255, 0.3)',
|
|
349
|
+
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
|
|
350
|
+
handleSize: '80%',
|
|
351
|
+
handleStyle: {
|
|
352
|
+
color: '#4CE27E',
|
|
353
|
+
borderColor: '#4CE27E'
|
|
354
|
+
},
|
|
355
|
+
moveHandleSize: 5,
|
|
356
|
+
textStyle: {
|
|
357
|
+
color: fontColor,
|
|
358
|
+
fontSize: 12
|
|
359
|
+
},
|
|
360
|
+
dataBackground: {
|
|
361
|
+
lineStyle: {
|
|
362
|
+
color: 'rgba(64, 158, 255, 0.5)'
|
|
363
|
+
},
|
|
364
|
+
areaStyle: {
|
|
365
|
+
color: 'rgba(64, 158, 255, 0.2)'
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
selectedDataBackground: {
|
|
369
|
+
lineStyle: {
|
|
370
|
+
color: '#4CE27E'
|
|
371
|
+
},
|
|
372
|
+
areaStyle: {
|
|
373
|
+
color: 'rgba(64, 158, 255, 0.3)'
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
realtime: true,
|
|
377
|
+
brushSelect: true,
|
|
378
|
+
zoomLock: false
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
type: 'inside',
|
|
382
|
+
xAxisIndex: 0,
|
|
383
|
+
start: this.dataZoomStart,
|
|
384
|
+
end: this.dataZoomEnd,
|
|
385
|
+
zoomOnMouseWheel: true,
|
|
386
|
+
moveOnMouseMove: true,
|
|
387
|
+
moveOnMouseWheel: true,
|
|
388
|
+
preventDefaultMouseMove: false,
|
|
389
|
+
zoomLock: false
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
this.chart.setOption(option, true)
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
</script>
|
|
399
|
+
|
|
400
|
+
<style lang="scss" scoped>
|
|
401
|
+
.l-bar-chart {
|
|
402
|
+
height: 100%;
|
|
403
|
+
width: 100%;
|
|
404
|
+
}
|
|
405
|
+
</style>
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
const interfaceObj = {
|
|
2
|
+
// ========== 基础配置 ==========
|
|
3
|
+
// 容器宽度:图表容器的宽度
|
|
4
|
+
width: {
|
|
5
|
+
type: String,
|
|
6
|
+
default: '100%'
|
|
7
|
+
},
|
|
8
|
+
// 容器高度:图表容器的高度
|
|
9
|
+
height: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: '100%'
|
|
12
|
+
},
|
|
13
|
+
// 图表标题:Y轴名称
|
|
14
|
+
title: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: ''
|
|
17
|
+
},
|
|
18
|
+
// 提示框单位:tooltip 显示的单位文字
|
|
19
|
+
tooltips: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: ''
|
|
22
|
+
},
|
|
23
|
+
// 图表数据列表:格式为 [类型数组, X轴数据, 多系列数据]
|
|
24
|
+
// 例如:[['旅游人次'], ['3.10', '3.11'], [[212, 302]]]
|
|
25
|
+
dataList: {
|
|
26
|
+
type: Array,
|
|
27
|
+
default: () => {
|
|
28
|
+
return [['旅游人次'], [3.10, 3.11, 3.12, 3.13, 3.14, 3.15, 3.16], [[212, 302, 222, 112, 102, 222, 282]]]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
// 是否开启动画:图表加载时的动画效果
|
|
32
|
+
animation: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// ========== 柱状图样式 ==========
|
|
38
|
+
// 柱状图宽度:单个柱子的宽度(像素)
|
|
39
|
+
barWidth: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 7
|
|
42
|
+
},
|
|
43
|
+
// 柱状图圆角:[上左, 上右, 下右, 下左] 的圆角大小
|
|
44
|
+
barBorderRadius: {
|
|
45
|
+
type: [Array, Object],
|
|
46
|
+
default: () => {
|
|
47
|
+
return [5, 5, 0, 0]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
// 柱状图渐变色:每个系列的渐变色配置
|
|
51
|
+
// 每项包含 color1(顶部颜色)、color2(中间颜色)、color3(底部颜色)
|
|
52
|
+
lineColor: {
|
|
53
|
+
type: Array,
|
|
54
|
+
default: () => {
|
|
55
|
+
return [
|
|
56
|
+
{ color1: 'rgba(131, 255, 153, .1)', color2: 'rgba(131, 255, 153, .5)', color3: 'rgba(51, 204, 115, 1)' },
|
|
57
|
+
{ color1: 'rgba(154, 252, 135, 1)', color2: 'rgba(154, 252, 135, .5)', color3: 'rgba(154, 252, 135, .1)' },
|
|
58
|
+
{ color1: 'rgba(255, 199, 61, 1)', color2: 'rgba(255, 199, 61, .5)', color3: 'rgba(255, 199, 61, .1)' }
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
// 是否显示渐变区域:柱子是否使用渐变填充
|
|
63
|
+
showAreaStyle: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: true
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
// ========== 图例配置 ==========
|
|
69
|
+
// 是否显示图例:控制图例的显示/隐藏
|
|
70
|
+
legendIsShow: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: true
|
|
73
|
+
},
|
|
74
|
+
// 图例顶部偏移:图例距离顶部的距离(可为负数)
|
|
75
|
+
legendTop: {
|
|
76
|
+
type: Number,
|
|
77
|
+
default: -15
|
|
78
|
+
},
|
|
79
|
+
// 图例图标:图例项的图标形状(circle、rect、roundRect 等)
|
|
80
|
+
legendIcon: {
|
|
81
|
+
type: [String, Boolean],
|
|
82
|
+
default: 'circle'
|
|
83
|
+
},
|
|
84
|
+
// 图例图标宽度:图例项图标的宽度
|
|
85
|
+
itemWidth: {
|
|
86
|
+
type: Number,
|
|
87
|
+
default: 10
|
|
88
|
+
},
|
|
89
|
+
// 图例图标高度:图例项图标的高度
|
|
90
|
+
itemHeight: {
|
|
91
|
+
type: Number,
|
|
92
|
+
default: 10
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
// ========== 字体样式 ==========
|
|
96
|
+
// 字体颜色:坐标轴、图例等文字的颜色
|
|
97
|
+
fontColor: {
|
|
98
|
+
type: String,
|
|
99
|
+
default: 'rgba(188, 205, 235, 1)'
|
|
100
|
+
},
|
|
101
|
+
// 字体大小:坐标轴、图例、提示框等文字的大小
|
|
102
|
+
fontSize: {
|
|
103
|
+
type: Number,
|
|
104
|
+
default: 14
|
|
105
|
+
},
|
|
106
|
+
// 提示框字体大小:tooltip 文字的字体大小(优先级高于 fontSize)
|
|
107
|
+
toolSize: {
|
|
108
|
+
type: Number,
|
|
109
|
+
default: null
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
// ========== 网格配置 ==========
|
|
113
|
+
// 图表边距:图表的上下左右边距
|
|
114
|
+
// 包含 left、right、top、bottom 四个属性
|
|
115
|
+
grid: {
|
|
116
|
+
type: Object,
|
|
117
|
+
default: () => {
|
|
118
|
+
return {
|
|
119
|
+
left: 50,
|
|
120
|
+
right: 20,
|
|
121
|
+
top: 25,
|
|
122
|
+
bottom: 91
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
// ========== X轴配置 ==========
|
|
128
|
+
// X轴标签间隔:坐标轴刻度标签的显示间隔
|
|
129
|
+
// 'auto' 自动判断,0 显示全部,其他数字为间隔值
|
|
130
|
+
interval: {
|
|
131
|
+
type: [Number, String],
|
|
132
|
+
default: 'auto'
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
// ========== Y轴配置 ==========
|
|
136
|
+
// Y轴最大值:Y轴的最大刻度值(null 为自动计算)
|
|
137
|
+
yMax: {
|
|
138
|
+
type: Number,
|
|
139
|
+
default: null
|
|
140
|
+
},
|
|
141
|
+
// Y轴刻度间隔:Y轴刻度的间隔值(null 为自动计算)
|
|
142
|
+
yInterval: {
|
|
143
|
+
type: Number,
|
|
144
|
+
default: null
|
|
145
|
+
},
|
|
146
|
+
// 是否显示Y轴标签:控制Y轴刻度标签的显示/隐藏
|
|
147
|
+
axisLabelShow: {
|
|
148
|
+
type: Boolean,
|
|
149
|
+
default: true
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
// ========== 工具箱配置 ==========
|
|
153
|
+
// 是否显示工具箱:控制工具箱的显示/隐藏
|
|
154
|
+
showToolbox: {
|
|
155
|
+
type: Boolean,
|
|
156
|
+
default: false
|
|
157
|
+
},
|
|
158
|
+
// 是否显示数据视图:工具箱中的数据视图按钮
|
|
159
|
+
showDataView: {
|
|
160
|
+
type: Boolean,
|
|
161
|
+
default: false
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
// ========== 导出配置 ==========
|
|
165
|
+
// 导出文件名:导出图片/CSV 时的文件名(不含扩展名)
|
|
166
|
+
exportFileName: {
|
|
167
|
+
type: String,
|
|
168
|
+
default: 'chart-export'
|
|
169
|
+
},
|
|
170
|
+
// 导出图片像素比:导出图片的分辨率倍数
|
|
171
|
+
exportPixelRatio: {
|
|
172
|
+
type: Number,
|
|
173
|
+
default: 2
|
|
174
|
+
},
|
|
175
|
+
// 导出图片类型:导出图片的格式(png 或 jpeg)
|
|
176
|
+
exportType: {
|
|
177
|
+
type: String,
|
|
178
|
+
default: 'png'
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
// ========== 滚动条配置 ==========
|
|
182
|
+
// 是否显示滚动条:X轴滚动条的显示控制
|
|
183
|
+
// 'auto' 自动判断,true 始终显示,false 始终隐藏
|
|
184
|
+
showDataZoom: {
|
|
185
|
+
type: [Boolean, String],
|
|
186
|
+
default: 'auto'
|
|
187
|
+
},
|
|
188
|
+
// 滚动条阈值:数据点超过此值时自动显示滚动条(仅 auto 模式生效)
|
|
189
|
+
dataZoomThreshold: {
|
|
190
|
+
type: Number,
|
|
191
|
+
default: 15
|
|
192
|
+
},
|
|
193
|
+
// 滚动条起始位置:初始显示的起始百分比(0-100)
|
|
194
|
+
dataZoomStart: {
|
|
195
|
+
type: Number,
|
|
196
|
+
default: 0
|
|
197
|
+
},
|
|
198
|
+
// 滚动条结束位置:初始显示的结束百分比(0-100)
|
|
199
|
+
dataZoomEnd: {
|
|
200
|
+
type: Number,
|
|
201
|
+
default: 50
|
|
202
|
+
},
|
|
203
|
+
// 滚动条高度:滑动滚动条的高度
|
|
204
|
+
dataZoomHeight: {
|
|
205
|
+
type: Number,
|
|
206
|
+
default: 20
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export default interfaceObj
|