@ecan-bi/tools 1.0.62 → 1.0.64
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/lib/index.es.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +5 -2
- package/src/indicator.ts +35 -12
- package/src/utils/chartTransProps/bar.ts +378 -0
- package/src/utils/chartTransProps/comboGraph.ts +407 -0
- package/src/utils/chartTransProps/common.ts +68 -0
- package/src/utils/chartTransProps/line.ts +249 -0
- package/src/utils/chartTransProps/pie.ts +106 -0
- package/src/utils/chartTransProps/radar.ts +229 -0
- package/src/utils/chartTransProps/scatter.ts +472 -0
- package/src/utils/transformProps.ts +19 -886
- package/src/utils/util.ts +31 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { computed, unref, ref } from 'vue'
|
|
2
|
+
import useVariablesInText from '../../hooks/useVariablesInText'
|
|
3
|
+
import useValueFormatter from '../../hooks/useValueFormatter'
|
|
4
|
+
import { getLegendFormat } from '../util'
|
|
5
|
+
export default function getBarTransformProps(props, chartData, fontSize, fontFamily = null, callBackMethodMap:any = {}) {
|
|
6
|
+
const yAxisLabelFormatter = props.yAxisLabelFormatter
|
|
7
|
+
const xAxisLabelFormatter = props.xAxisLabelFormatter
|
|
8
|
+
const dataSource = ref(chartData.dataset)
|
|
9
|
+
const dimensions = ref(chartData.dimensions)
|
|
10
|
+
const series = computed(() => {
|
|
11
|
+
const { gradientShow, gradientColors, gradientOffset, barBorderRadius } = props
|
|
12
|
+
const ds = unref(dataSource)
|
|
13
|
+
const len = ds.length
|
|
14
|
+
const series = []
|
|
15
|
+
for (let i = 0; i < len; i++) {
|
|
16
|
+
const item = {
|
|
17
|
+
...ds[i],
|
|
18
|
+
type: 'bar',
|
|
19
|
+
barWidth: props.barWidth.value + props.barWidth.suffix,
|
|
20
|
+
showBackground: props.showBarBackground
|
|
21
|
+
} as { [key: string]: any }
|
|
22
|
+
if (props.isStack) {
|
|
23
|
+
item.stack = 'stack'
|
|
24
|
+
}
|
|
25
|
+
item.label = {
|
|
26
|
+
show: props.labelShow,
|
|
27
|
+
fontSize: props.labelFontSize,
|
|
28
|
+
position: props.labelPosition,
|
|
29
|
+
color: props.labelColor,
|
|
30
|
+
width: props.labelWidth,
|
|
31
|
+
overflow: props.labelOverflow,
|
|
32
|
+
formatter: (params) => {
|
|
33
|
+
let formatter = ''
|
|
34
|
+
let labelFormatter = props.labelFormatter
|
|
35
|
+
if (labelFormatter === '') {
|
|
36
|
+
labelFormatter = '{c}'
|
|
37
|
+
}
|
|
38
|
+
const { seriesName, name, value, data } = params || {}
|
|
39
|
+
formatter += useVariablesInText(
|
|
40
|
+
labelFormatter,
|
|
41
|
+
{
|
|
42
|
+
textData: {
|
|
43
|
+
name,
|
|
44
|
+
value,
|
|
45
|
+
a: seriesName,
|
|
46
|
+
b: name,
|
|
47
|
+
c: value || 0,
|
|
48
|
+
...data
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
useNewline: true,
|
|
53
|
+
useSpace: true
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
return formatter
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
item.itemStyle = {}
|
|
60
|
+
if (gradientShow) {
|
|
61
|
+
let gcolor = props.colors[i]
|
|
62
|
+
if (!gcolor && props.colors.length) {
|
|
63
|
+
const colorIndex = ((i + 1) % props.colors.length) - 1
|
|
64
|
+
gcolor = colorIndex > 0 ? props.colors[colorIndex] : props.colors[0]
|
|
65
|
+
}
|
|
66
|
+
if (!gcolor) {
|
|
67
|
+
gcolor = '#5470C6'
|
|
68
|
+
}
|
|
69
|
+
item.itemStyle = {
|
|
70
|
+
color: {
|
|
71
|
+
x: props.isUseHorizontalAxis ? 1 : 0,
|
|
72
|
+
y: 0,
|
|
73
|
+
x2: 0,
|
|
74
|
+
y2: props.isUseHorizontalAxis ? 0 : 1,
|
|
75
|
+
colorStops: [
|
|
76
|
+
{
|
|
77
|
+
offset: 0,
|
|
78
|
+
color: gcolor
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
offset: gradientOffset,
|
|
82
|
+
color: gradientColors[i]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
offset: 1,
|
|
86
|
+
color: gradientColors[i]
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (barBorderRadius) {
|
|
93
|
+
const radius = barBorderRadius.split(',')
|
|
94
|
+
if (radius?.length) {
|
|
95
|
+
const radiusItems = []
|
|
96
|
+
for (const rs of radius) {
|
|
97
|
+
const value = parseFloat(rs)
|
|
98
|
+
if (!isNaN(value)) {
|
|
99
|
+
radiusItems.push(value)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
item.itemStyle.borderRadius = radiusItems
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (props.isShowMarkLine) {
|
|
106
|
+
item.markLine = {
|
|
107
|
+
data: [{ type: props.markLineType }]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
series.push(item)
|
|
111
|
+
}
|
|
112
|
+
return series
|
|
113
|
+
})
|
|
114
|
+
const xAxisData = computed(() => {
|
|
115
|
+
return unref(dimensions).map((item) => {
|
|
116
|
+
let result = {}
|
|
117
|
+
if (item && typeof item === 'object') {
|
|
118
|
+
result = {
|
|
119
|
+
...item,
|
|
120
|
+
textStyle: {
|
|
121
|
+
fontSize: fontSize
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
result = {
|
|
126
|
+
value: item,
|
|
127
|
+
textStyle: {
|
|
128
|
+
fontSize: fontSize
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return result
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
return {
|
|
136
|
+
textStyle: {
|
|
137
|
+
fontFamily: unref(fontFamily)
|
|
138
|
+
},
|
|
139
|
+
toolbox: {
|
|
140
|
+
show: props.toolboxShow,
|
|
141
|
+
left: props.toolboxLeft,
|
|
142
|
+
top: props.toolboxTop,
|
|
143
|
+
itemSize: props.toolboxItemSize,
|
|
144
|
+
itemGap: props.toolboxItemGap,
|
|
145
|
+
feature: {
|
|
146
|
+
myLocation: {
|
|
147
|
+
show: props.toolboxLocation,
|
|
148
|
+
title: '快速定位',
|
|
149
|
+
icon: 'path://M512 512m-80 0a80 80 0 1 0 160 0 80 80 0 1 0-160 0Z, M960 480h-33.632C910.752 276.16 747.84 113.248 544 97.632V64a32 32 0 1 0-64 0v33.632C276.16 113.248 113.248 276.16 97.632 480H64a32 32 0 0 0 0 64h33.632C113.248 747.84 276.16 910.752 480 926.368V960a32 32 0 1 0 64 0v-33.632C747.84 910.752 910.752 747.84 926.368 544H960a32 32 0 1 0 0-64zM544 862.368V800a32 32 0 1 0-64 0v62.368C311.424 847.104 176.896 712.576 161.632 544H224a32 32 0 1 0 0-64H161.632C176.896 311.424 311.424 176.896 480 161.632V224a32 32 0 0 0 64 0V161.632c168.576 15.296 303.104 149.792 318.368 318.368H800a32 32 0 1 0 0 64h62.368c-15.264 168.576-149.792 303.104-318.368 318.368z',
|
|
150
|
+
onclick() {
|
|
151
|
+
callBackMethodMap.toolboxLocationFun && callBackMethodMap.toolboxLocationFun(props)
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
myDownload: {
|
|
155
|
+
show: props.toolboxDownloadShow,
|
|
156
|
+
title: '数据下载',
|
|
157
|
+
icon: 'path://M502.010485 765.939573c3.773953 3.719718 8.686846 5.573949 13.596669 5.573949 0.075725 0 0.151449-0.010233 0.227174-0.011256 0.329505 0.016373 0.654916 0.050142 0.988514 0.050142 0.706081 0 1.400906-0.042979 2.087545-0.116657 4.352121-0.366344 8.607028-2.190899 11.961426-5.496178l335.053985-330.166675c7.619538-7.509021 7.709589-19.773346 0.200568-27.393907s-19.774369-7.711636-27.39493-0.201591L536.193005 706.304358 536.193005 50.019207c0-10.698666-8.67252-19.371186-19.371186-19.371186s-19.371186 8.67252-19.371186 19.371186l0 657.032164-306.881342-302.44838c-7.618515-7.509021-19.883863-7.419993-27.393907 0.199545-7.509021 7.619538-7.419993 19.884886 0.199545 27.393907L502.010485 765.939573z, M867.170139 711.020776c-10.698666 0-19.371186 8.67252-19.371186 19.371186l0 165.419494c0 13.054317-10.620895 23.675212-23.676236 23.675212L205.182103 919.486668c-13.054317 0-23.676236-10.620895-23.676236-23.675212L181.505867 730.391962c0-10.698666-8.67252-19.371186-19.371186-19.371186s-19.371186 8.67252-19.371186 19.371186l0 165.419494c0 34.416857 28.000728 62.416562 62.417585 62.416562l618.941638 0c34.417881 0 62.417585-27.999704 62.417585-62.416562L886.540302 730.391962C886.541325 719.693296 877.868805 711.020776 867.170139 711.020776z',
|
|
158
|
+
onclick() {
|
|
159
|
+
callBackMethodMap.toolboxDownloadShowFun && callBackMethodMap.toolboxDownloadShowFun(props)
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
myDataZoom: {
|
|
163
|
+
show: props.toolboxDataZoomShow,
|
|
164
|
+
title: '放大',
|
|
165
|
+
icon: 'path://M932.42 902.246667L792 761.793333A403.84 403.84 0 0 0 896 490.666667c0-223.86-181.473333-405.333333-405.333333-405.333334S85.333333 266.806667 85.333333 490.666667s181.473333 405.333333 405.333334 405.333333a403.84 403.84 0 0 0 271.126666-104l140.453334 140.453333a21.333333 21.333333 0 0 0 30.173333-30.173333zM128 490.666667c0-200.293333 162.373333-362.666667 362.666667-362.666667s362.666667 162.373333 362.666666 362.666667-162.373333 362.666667-362.666666 362.666666-362.666667-162.373333-362.666667-362.666666z m512 0a21.333333 21.333333 0 0 1-21.333333 21.333333H512v106.666667a21.333333 21.333333 0 0 1-42.666667 0V512H362.666667a21.333333 21.333333 0 0 1 0-42.666667h106.666666V362.666667a21.333333 21.333333 0 0 1 42.666667 0v106.666666h106.666667a21.333333 21.333333 0 0 1 21.333333 21.333334z',
|
|
166
|
+
onclick() {
|
|
167
|
+
callBackMethodMap.toolboxDataZoomShowFun && callBackMethodMap.toolboxDataZoomShowFun(props)
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
myInfo: {
|
|
171
|
+
show: props.toolboxInfoShow,
|
|
172
|
+
title: '详情',
|
|
173
|
+
icon: 'path://M512.50142 958.397886c-119.320573 0-231.499491-46.465265-315.871087-130.837884C112.258737 743.188406 65.792449 631.010511 65.792449 511.688915c0-119.319549 46.466288-231.499491 130.837884-315.871087C281.002952 111.445208 393.180847 64.979944 512.50142 64.979944s231.499491 46.465265 315.871087 130.837884c84.372619 84.372619 130.837884 196.551538 130.837884 315.871087 0 119.321596-46.465265 231.499491-130.837884 315.871087C744.000911 911.932622 631.821993 958.397886 512.50142 958.397886zM512.50142 105.962334c-223.718271 0-405.726581 182.00831-405.726581 405.726581s182.00831 405.726581 405.726581 405.726581c223.718271 0 405.727605-182.00831 405.727605-405.726581S736.220714 105.962334 512.50142 105.962334z M510.150886 775.953647c-18.107403 0-32.745798-14.678304-32.745798-32.785707L477.405087 452.191846c0-18.108426 14.638395-32.785707 32.745798-32.785707 18.107403 0 32.745798 14.678304 32.745798 32.785707l0 290.976094C542.896684 761.275343 528.258289 775.953647 510.150886 775.953647z M511.357364 296.458969m-45.080731 0a44.054 44.054 0 1 0 90.161463 0 44.054 44.054 0 1 0-90.161463 0Z',
|
|
174
|
+
onclick() {
|
|
175
|
+
callBackMethodMap.toolboxInfoShowFun && callBackMethodMap.toolboxInfoShowFun(props)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
title: {
|
|
181
|
+
text: props.titleText,
|
|
182
|
+
subtext: props.titleSubtext,
|
|
183
|
+
textStyle: {
|
|
184
|
+
fontSize: props.titleFontSize,
|
|
185
|
+
fontWeight: props.fontWeight,
|
|
186
|
+
color: props.titleColor
|
|
187
|
+
},
|
|
188
|
+
left: props.textAlign
|
|
189
|
+
},
|
|
190
|
+
grid: {
|
|
191
|
+
top: props.gridTop,
|
|
192
|
+
bottom: props.gridBottom,
|
|
193
|
+
left: props.gridLeft,
|
|
194
|
+
right: props.gridRight,
|
|
195
|
+
containLabel: props.gridContainLabel
|
|
196
|
+
},
|
|
197
|
+
color: props.colors,
|
|
198
|
+
tooltip: {
|
|
199
|
+
trigger: 'axis',
|
|
200
|
+
show: props.tooltipShow,
|
|
201
|
+
formatter: (params) => {
|
|
202
|
+
const len = params.length
|
|
203
|
+
let formatter = ''
|
|
204
|
+
let tooltipFormatter = props.tooltipFormatter
|
|
205
|
+
// currentData = params[0]?.data
|
|
206
|
+
if (tooltipFormatter === '') {
|
|
207
|
+
tooltipFormatter = '{marker} {a} {c}'
|
|
208
|
+
}
|
|
209
|
+
for (let i = 0; i < len; i++) {
|
|
210
|
+
const { marker, seriesName, name, value, data } = params[i] || {}
|
|
211
|
+
if (i === 0) {
|
|
212
|
+
let formatName = name
|
|
213
|
+
if (typeof name === 'string' && name[0] === '0' && !isNaN(+name)) {
|
|
214
|
+
formatName = (+name).toString()
|
|
215
|
+
}
|
|
216
|
+
formatter += `${useValueFormatter(xAxisLabelFormatter, formatName)}<br/>`
|
|
217
|
+
}
|
|
218
|
+
formatter += useVariablesInText(
|
|
219
|
+
tooltipFormatter,
|
|
220
|
+
{
|
|
221
|
+
textData: {
|
|
222
|
+
marker,
|
|
223
|
+
name,
|
|
224
|
+
value,
|
|
225
|
+
a: seriesName,
|
|
226
|
+
b: name,
|
|
227
|
+
c: data.sourceValue || value || 0,
|
|
228
|
+
...data
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
useNewline: true,
|
|
233
|
+
useSpace: true
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
formatter += '<br/>'
|
|
237
|
+
}
|
|
238
|
+
return formatter
|
|
239
|
+
},
|
|
240
|
+
// valueFormatter: (value) => {
|
|
241
|
+
// return useVariablesInText(props.tooltipValueFormatter as string, { value })
|
|
242
|
+
// },
|
|
243
|
+
textStyle: {
|
|
244
|
+
color: props.tooltipTextStyleColor,
|
|
245
|
+
fontSize: fontSize.value
|
|
246
|
+
},
|
|
247
|
+
position: props.tooltipPosition || undefined
|
|
248
|
+
},
|
|
249
|
+
legend: {
|
|
250
|
+
type: props.legendScroll ? 'scroll' : 'plain',
|
|
251
|
+
width: props.legendWidth,
|
|
252
|
+
height: props.legendHeight,
|
|
253
|
+
show: props.legendShow,
|
|
254
|
+
orient: props.legendOrient,
|
|
255
|
+
top: props.legendTop,
|
|
256
|
+
left: props.legendLeft,
|
|
257
|
+
textStyle: {
|
|
258
|
+
// lineHeight: (visible.value ? ZOOM_FONT_SIZE : parseFloat(props.legendFontSize)) + 8,
|
|
259
|
+
rich: {
|
|
260
|
+
text: {
|
|
261
|
+
width: props.legendTextWidth,
|
|
262
|
+
color: props.legendTextStyleColor
|
|
263
|
+
// fontSize: visible.value ? ZOOM_FONT_SIZE : props.legendFontSize
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
itemHeight: props.legendItemHeight,
|
|
268
|
+
itemWidth: props.legendItemWidth,
|
|
269
|
+
itemGap: props.legendItemGap,
|
|
270
|
+
data: unref(dataSource).map((value, index) => {
|
|
271
|
+
return {
|
|
272
|
+
name: value.name,
|
|
273
|
+
itemStyle: {
|
|
274
|
+
color: props.colors[index]
|
|
275
|
+
},
|
|
276
|
+
icon: props.legendType
|
|
277
|
+
}
|
|
278
|
+
}),
|
|
279
|
+
formatter: (name: string) => {
|
|
280
|
+
return getLegendFormat(props.legendFormatter, {
|
|
281
|
+
name
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
xAxis: {
|
|
286
|
+
type: props.isUseHorizontalAxis ? 'value' : 'category',
|
|
287
|
+
data: props.isUseHorizontalAxis ? null : unref(xAxisData),
|
|
288
|
+
inverse: props.isUseHorizontalAxis ? props.xAxisInverse : props.axisInverse,
|
|
289
|
+
minInterval: props.xAxisMinInterval,
|
|
290
|
+
splitLine: {
|
|
291
|
+
show: props.xAxisSplitLineShow,
|
|
292
|
+
lineStyle: {
|
|
293
|
+
color: props.xAxisSplitLineStyleColor,
|
|
294
|
+
type: props.xAxisSplitLineType
|
|
295
|
+
},
|
|
296
|
+
interval: props.xAxisSplitLineInterval
|
|
297
|
+
},
|
|
298
|
+
splitArea: {
|
|
299
|
+
show: props.xAxisSplitAreaShow
|
|
300
|
+
},
|
|
301
|
+
axisLabel: {
|
|
302
|
+
show: props.xAxisLabelShow,
|
|
303
|
+
color: props.xAxisLabelColor,
|
|
304
|
+
interval: props.xAxisLabelInterval || 0,
|
|
305
|
+
rotate: props.xAxisLabelRotate,
|
|
306
|
+
width: props.xAxisLabelWidth,
|
|
307
|
+
overflow: props.xAxisLabelOverflow,
|
|
308
|
+
fontSize: props.xAxisLabelFontSize,
|
|
309
|
+
formatter(value: string) {
|
|
310
|
+
if (typeof value === 'string' && value[0] === '0' && !isNaN(+value)) {
|
|
311
|
+
value = (+value).toString()
|
|
312
|
+
}
|
|
313
|
+
return useValueFormatter(xAxisLabelFormatter, value)
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
axisLine: {
|
|
317
|
+
show: props.xAxisLineShow,
|
|
318
|
+
lineStyle: {
|
|
319
|
+
color: props.xAxisLineStyleColor
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
axisTick: {
|
|
323
|
+
show: props.xAxisTickShow
|
|
324
|
+
},
|
|
325
|
+
name: props.xAxisName,
|
|
326
|
+
nameTextStyle: {
|
|
327
|
+
fontSize: props.xAxisLabelFontSize,
|
|
328
|
+
color: props.xAxisLabelColor,
|
|
329
|
+
align: 'left'
|
|
330
|
+
},
|
|
331
|
+
max: props.xAxisMaxValue || null
|
|
332
|
+
},
|
|
333
|
+
yAxis: {
|
|
334
|
+
type: props.isUseHorizontalAxis ? 'category' : 'value',
|
|
335
|
+
data: props.isUseHorizontalAxis ? unref(dimensions) : null,
|
|
336
|
+
inverse: props.isUseHorizontalAxis ? props.axisInverse : props.yAxisInverse,
|
|
337
|
+
minInterval: props.yAxisMinInterval,
|
|
338
|
+
splitLine: {
|
|
339
|
+
show: props.yAxisSplitLineShow,
|
|
340
|
+
lineStyle: {
|
|
341
|
+
color: props.yAxisSplitLineStyleColor,
|
|
342
|
+
type: props.yAxisSplitLineType
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
splitArea: {
|
|
346
|
+
show: props.yAxisSplitAreaShow
|
|
347
|
+
},
|
|
348
|
+
axisTick: {
|
|
349
|
+
show: props.yAxisTickShow
|
|
350
|
+
},
|
|
351
|
+
axisLabel: {
|
|
352
|
+
show: props.yAxisLabelShow,
|
|
353
|
+
fontSize: props.yAxisLabelFontSize,
|
|
354
|
+
color: props.yAxisLabelColor,
|
|
355
|
+
rotate: props.yAxisLabelRotate,
|
|
356
|
+
width: props.yAxisLabelWidth,
|
|
357
|
+
overflow: props.yAxisLabelOverflow,
|
|
358
|
+
formatter(value: string) {
|
|
359
|
+
return useValueFormatter(yAxisLabelFormatter, value)
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
axisLine: {
|
|
363
|
+
show: props.yAxisLineAlwaysDisplay,
|
|
364
|
+
lineStyle: {
|
|
365
|
+
color: props.yAxisLineStyleColor
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
name: props.yAxisName,
|
|
369
|
+
nameTextStyle: {
|
|
370
|
+
fontSize: props.yAxisLabelFontSize,
|
|
371
|
+
color: props.yAxisLabelColor,
|
|
372
|
+
align: 'right'
|
|
373
|
+
},
|
|
374
|
+
max: props.yAxisMaxValue || null
|
|
375
|
+
},
|
|
376
|
+
series: unref(series)
|
|
377
|
+
}
|
|
378
|
+
}
|