evui 3.3.47 → 3.3.49
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/dist/evui.common.js +435 -192
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +435 -192
- package/dist/evui.umd.js.map +1 -1
- package/dist/evui.umd.min.js +1 -1
- package/dist/evui.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chart/chart.core.js +23 -2
- package/src/components/chart/element/element.heatmap.js +123 -43
- package/src/components/chart/element/element.tip.js +51 -1
- package/src/components/chart/helpers/helpers.constant.js +1 -0
- package/src/components/chart/helpers/helpers.util.js +1 -1
- package/src/components/chart/model/model.series.js +1 -1
- package/src/components/chart/model/model.store.js +7 -6
- package/src/components/chart/plugins/plugins.interaction.js +48 -5
- package/src/components/chart/plugins/plugins.legend.js +20 -14
- package/src/components/chart/plugins/plugins.tooltip.js +4 -2
- package/src/components/chart/scale/scale.js +1 -1
- package/src/components/chart/scale/scale.step.js +1 -1
- package/src/components/chart/scale/scale.time.category.js +1 -1
- package/src/components/chart/uses.js +18 -2
- package/src/components/treeGrid/TreeGridNode.vue +8 -3
package/package.json
CHANGED
|
@@ -219,12 +219,33 @@ class EvChart {
|
|
|
219
219
|
const series = this.seriesList[chartTypeSet[jx]];
|
|
220
220
|
|
|
221
221
|
switch (chartType) {
|
|
222
|
-
case 'line':
|
|
222
|
+
case 'line': {
|
|
223
|
+
const legendHitInfo = hitInfo?.legend;
|
|
224
|
+
|
|
225
|
+
series.draw({
|
|
226
|
+
legendHitInfo,
|
|
227
|
+
...opt,
|
|
228
|
+
});
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
223
231
|
case 'heatMap': {
|
|
224
232
|
const legendHitInfo = hitInfo?.legend;
|
|
225
233
|
|
|
234
|
+
let selectInfo;
|
|
235
|
+
const defaultSelectInfo = this.defaultSelectItemInfo;
|
|
236
|
+
if (defaultSelectInfo?.dataIndex || defaultSelectInfo?.dataIndex === 0) {
|
|
237
|
+
selectInfo = { ...defaultSelectInfo };
|
|
238
|
+
} else {
|
|
239
|
+
selectInfo = null;
|
|
240
|
+
}
|
|
241
|
+
|
|
226
242
|
series.draw({
|
|
227
243
|
legendHitInfo,
|
|
244
|
+
selectInfo,
|
|
245
|
+
selectItem: {
|
|
246
|
+
option: selectItem,
|
|
247
|
+
selected: selectInfo,
|
|
248
|
+
},
|
|
228
249
|
...opt,
|
|
229
250
|
});
|
|
230
251
|
break;
|
|
@@ -718,7 +739,7 @@ class EvChart {
|
|
|
718
739
|
|
|
719
740
|
if (options.legend.show) {
|
|
720
741
|
const useTable = !!options.legend?.table?.use
|
|
721
|
-
&& options.type !== '
|
|
742
|
+
&& options.type !== 'heatMap'
|
|
722
743
|
&& options.type !== 'scatter';
|
|
723
744
|
|
|
724
745
|
if (!this.isInitLegend) {
|
|
@@ -4,12 +4,13 @@ import { HEAT_MAP_OPTION } from '../helpers/helpers.constant';
|
|
|
4
4
|
import { convertToPercent } from '../../../common/utils';
|
|
5
5
|
|
|
6
6
|
class HeatMap {
|
|
7
|
-
constructor(sId, opt, colorOpt, isGradient) {
|
|
7
|
+
constructor(sId, opt, colorOpt, isHorizontal, isGradient) {
|
|
8
8
|
const merged = merge({}, HEAT_MAP_OPTION, opt);
|
|
9
9
|
Object.keys(merged).forEach((key) => {
|
|
10
10
|
this[key] = merged[key];
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
+
this.isHorizontal = isHorizontal;
|
|
13
14
|
this.isGradient = isGradient;
|
|
14
15
|
this.createColorState(colorOpt);
|
|
15
16
|
|
|
@@ -35,7 +36,7 @@ class HeatMap {
|
|
|
35
36
|
createColorState(colorOpt) {
|
|
36
37
|
const colorState = [];
|
|
37
38
|
const regex = /[^0-9]&[^,]/g;
|
|
38
|
-
const { min, max,
|
|
39
|
+
const { min, max, rangeCount, colorsByRange, error, stroke } = colorOpt;
|
|
39
40
|
|
|
40
41
|
const minColor = min.includes('#') ? Util.hexToRgb(min) : min.replace(regex, '');
|
|
41
42
|
const maxColor = max.includes('#') ? Util.hexToRgb(max) : max.replace(regex, '');
|
|
@@ -47,17 +48,27 @@ class HeatMap {
|
|
|
47
48
|
colorState.push({
|
|
48
49
|
minColor: { minR, minG, minB },
|
|
49
50
|
maxColor: { maxR, maxG, maxB },
|
|
50
|
-
|
|
51
|
+
rangeCount,
|
|
51
52
|
start: 0,
|
|
52
53
|
end: 100,
|
|
53
54
|
selectedValue: null,
|
|
54
55
|
});
|
|
56
|
+
} else if (colorsByRange.length) {
|
|
57
|
+
colorsByRange.forEach(({ color, label }, ix) => {
|
|
58
|
+
colorState.push({
|
|
59
|
+
id: `color#${ix}`,
|
|
60
|
+
color,
|
|
61
|
+
label,
|
|
62
|
+
state: 'normal',
|
|
63
|
+
show: true,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
55
66
|
} else {
|
|
56
|
-
const unitR = Math.floor((minR - maxR) / (
|
|
57
|
-
const unitG = Math.floor((minG - maxG) / (
|
|
58
|
-
const unitB = Math.floor((minB - maxB) / (
|
|
67
|
+
const unitR = Math.floor((minR - maxR) / (rangeCount - 1));
|
|
68
|
+
const unitG = Math.floor((minG - maxG) / (rangeCount - 1));
|
|
69
|
+
const unitB = Math.floor((minB - maxB) / (rangeCount - 1));
|
|
59
70
|
|
|
60
|
-
for (let ix = 0; ix <
|
|
71
|
+
for (let ix = 0; ix < rangeCount; ix++) {
|
|
61
72
|
const r = +minR - (unitR * ix);
|
|
62
73
|
const g = +minG - (unitG * ix);
|
|
63
74
|
const b = +minB - (unitB * ix);
|
|
@@ -89,7 +100,7 @@ class HeatMap {
|
|
|
89
100
|
return `rgb(${r},${g},${b})`;
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
|
|
103
|
+
getColorIndexByValue(value) {
|
|
93
104
|
const { existError, min, interval, decimalPoint } = this.valueOpt;
|
|
94
105
|
const maxIndex = this.colorState.length - 1;
|
|
95
106
|
if (existError && value < 0) {
|
|
@@ -109,7 +120,7 @@ class HeatMap {
|
|
|
109
120
|
const { min, max } = this.valueOpt;
|
|
110
121
|
const itemInfo = {
|
|
111
122
|
show: false,
|
|
112
|
-
opacity:
|
|
123
|
+
opacity: 1,
|
|
113
124
|
dataColor: null,
|
|
114
125
|
id: null,
|
|
115
126
|
isHighlight: null,
|
|
@@ -121,12 +132,11 @@ class HeatMap {
|
|
|
121
132
|
itemInfo.show = true;
|
|
122
133
|
itemInfo.isHighlight = selectedValue !== null
|
|
123
134
|
&& (Math.floor(value) === Math.floor(min + ((max - min) * (selectedValue / 100))));
|
|
124
|
-
itemInfo.opacity = 1;
|
|
125
135
|
itemInfo.dataColor = value < 0
|
|
126
136
|
? this.errorColor : this.getColorForGradient(ratio);
|
|
127
137
|
}
|
|
128
138
|
} else {
|
|
129
|
-
const colorIndex = this.
|
|
139
|
+
const colorIndex = this.getColorIndexByValue(value);
|
|
130
140
|
const { show, state, color, id } = this.colorState[colorIndex];
|
|
131
141
|
itemInfo.show = show;
|
|
132
142
|
itemInfo.opacity = state === 'downplay' ? 0.1 : 1;
|
|
@@ -136,16 +146,22 @@ class HeatMap {
|
|
|
136
146
|
return itemInfo;
|
|
137
147
|
}
|
|
138
148
|
|
|
139
|
-
drawItem(ctx, x, y, w, h) {
|
|
149
|
+
drawItem(ctx, x, y, w, h, borderOpt) {
|
|
140
150
|
ctx.beginPath();
|
|
141
|
-
if (
|
|
142
|
-
const { radius } =
|
|
143
|
-
if (radius > 0
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
if (borderOpt.show) {
|
|
152
|
+
const { radius } = borderOpt;
|
|
153
|
+
if (radius > 0) {
|
|
154
|
+
const minSize = Math.min(w, h);
|
|
155
|
+
let r = radius;
|
|
156
|
+
if (r > (minSize / 2)) {
|
|
157
|
+
r = Math.floor(minSize / 2);
|
|
158
|
+
}
|
|
159
|
+
ctx.moveTo(x + r, y);
|
|
160
|
+
ctx.arcTo(x + w, y, x + w, y + h, r);
|
|
161
|
+
ctx.arcTo(x + w, y + h, x, y + h, r);
|
|
162
|
+
ctx.arcTo(x, y + h, x, y, r);
|
|
163
|
+
ctx.arcTo(x, y, x + w, y, r);
|
|
164
|
+
ctx.stroke();
|
|
149
165
|
ctx.fill();
|
|
150
166
|
} else {
|
|
151
167
|
ctx.strokeRect(x, y, w, h);
|
|
@@ -193,7 +209,15 @@ class HeatMap {
|
|
|
193
209
|
return;
|
|
194
210
|
}
|
|
195
211
|
|
|
196
|
-
const {
|
|
212
|
+
const {
|
|
213
|
+
ctx,
|
|
214
|
+
chartRect,
|
|
215
|
+
labelOffset,
|
|
216
|
+
overlayCtx,
|
|
217
|
+
selectLabel,
|
|
218
|
+
legendHitInfo,
|
|
219
|
+
selectItem,
|
|
220
|
+
} = param;
|
|
197
221
|
|
|
198
222
|
const xArea = chartRect.chartWidth - (labelOffset.left + labelOffset.right);
|
|
199
223
|
const yArea = chartRect.chartHeight - (labelOffset.top + labelOffset.bottom);
|
|
@@ -204,34 +228,80 @@ class HeatMap {
|
|
|
204
228
|
this.size.w = xArea / this.labels.x.length;
|
|
205
229
|
this.size.h = yArea / this.labels.y.length;
|
|
206
230
|
|
|
207
|
-
|
|
208
|
-
|
|
231
|
+
const getOpacity = (item, opacity, index) => {
|
|
232
|
+
const selectLabelOption = selectLabel?.option;
|
|
233
|
+
const useSelectLabel = selectLabelOption?.use && selectLabelOption?.useSeriesOpacity;
|
|
234
|
+
const selectItemOption = selectItem?.option;
|
|
235
|
+
const useSelectItem = selectItemOption?.use && selectItemOption?.useSeriesOpacity;
|
|
236
|
+
if (!legendHitInfo) {
|
|
237
|
+
let isDownplay = false;
|
|
238
|
+
if (useSelectItem) {
|
|
239
|
+
isDownplay = selectItem?.selected && index !== selectItem?.selected?.dataIndex;
|
|
240
|
+
} else if (useSelectLabel) {
|
|
241
|
+
const selectedLabelList = selectLabel?.selected?.label;
|
|
242
|
+
isDownplay = selectedLabelList.length
|
|
243
|
+
&& !selectedLabelList.includes(this.isHorizontal ? item.y : item.x);
|
|
244
|
+
}
|
|
245
|
+
return isDownplay ? 0.1 : 1;
|
|
246
|
+
}
|
|
247
|
+
return opacity;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
this.data.forEach((item, index) => {
|
|
251
|
+
const axisLineWidth = 1;
|
|
252
|
+
let xp = this.calculateXY('x', item.x, xsp) + axisLineWidth;
|
|
209
253
|
let yp = this.calculateXY('y', item.y, ysp);
|
|
210
254
|
let w = this.size.w;
|
|
211
255
|
let h = this.size.h;
|
|
256
|
+
|
|
212
257
|
const value = item.o;
|
|
213
258
|
|
|
214
259
|
if (xp !== null && yp !== null
|
|
215
260
|
&& (value !== null && value !== undefined)) {
|
|
216
|
-
const {
|
|
261
|
+
const {
|
|
262
|
+
show,
|
|
263
|
+
opacity,
|
|
264
|
+
dataColor,
|
|
265
|
+
id,
|
|
266
|
+
isHighlight,
|
|
267
|
+
} = this.getItemInfo(value);
|
|
268
|
+
|
|
269
|
+
const itemOpacity = getOpacity(item, opacity, index);
|
|
270
|
+
|
|
217
271
|
item.dataColor = dataColor;
|
|
218
272
|
item.cId = id;
|
|
219
273
|
ctx.save();
|
|
274
|
+
|
|
220
275
|
if (show) {
|
|
221
|
-
ctx.fillStyle = Util.colorStringToRgba(item.dataColor,
|
|
222
|
-
|
|
223
|
-
|
|
276
|
+
ctx.fillStyle = Util.colorStringToRgba(item.dataColor, itemOpacity);
|
|
277
|
+
|
|
278
|
+
let borderOpt = this.stroke;
|
|
279
|
+
const selectItemOption = selectItem?.option;
|
|
280
|
+
const useSelectItem = selectItemOption?.use && selectItemOption?.showBorder;
|
|
281
|
+
const isHit = (index === selectItem?.selected?.dataIndex);
|
|
282
|
+
if (useSelectItem && isHit) {
|
|
283
|
+
borderOpt = {
|
|
284
|
+
show: selectItemOption?.showBorder,
|
|
285
|
+
...selectItemOption?.borderStyle,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (borderOpt.show) {
|
|
290
|
+
const { color, lineWidth, opacity: borderOpacity } = borderOpt;
|
|
224
291
|
ctx.strokeStyle = Util.colorStringToRgba(
|
|
225
292
|
color,
|
|
226
|
-
|
|
293
|
+
itemOpacity === 1 ? borderOpacity : itemOpacity,
|
|
227
294
|
);
|
|
295
|
+
|
|
228
296
|
ctx.lineWidth = lineWidth;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
297
|
+
|
|
298
|
+
xp += (lineWidth * 0.5);
|
|
299
|
+
yp += (lineWidth * 0.5);
|
|
300
|
+
w -= (lineWidth);
|
|
301
|
+
h -= (lineWidth);
|
|
233
302
|
}
|
|
234
|
-
|
|
303
|
+
|
|
304
|
+
this.drawItem(ctx, xp, yp, w, h, borderOpt);
|
|
235
305
|
ctx.restore();
|
|
236
306
|
|
|
237
307
|
item.xp = xp;
|
|
@@ -358,10 +428,10 @@ class HeatMap {
|
|
|
358
428
|
const gdata = item.data;
|
|
359
429
|
const ctx = context;
|
|
360
430
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
431
|
+
let x = gdata.xp;
|
|
432
|
+
let y = gdata.yp;
|
|
433
|
+
let w = gdata.w;
|
|
434
|
+
let h = gdata.h;
|
|
365
435
|
const cId = gdata.cId;
|
|
366
436
|
|
|
367
437
|
let isShow;
|
|
@@ -374,16 +444,24 @@ class HeatMap {
|
|
|
374
444
|
isShow = this.colorState.find(({ id }) => id === cId)?.show;
|
|
375
445
|
}
|
|
376
446
|
ctx.save();
|
|
377
|
-
ctx.shadowOffsetX =
|
|
378
|
-
ctx.shadowOffsetY =
|
|
447
|
+
ctx.shadowOffsetX = 0;
|
|
448
|
+
ctx.shadowOffsetY = 0;
|
|
379
449
|
ctx.shadowBlur = 4;
|
|
380
450
|
|
|
381
451
|
if (x !== null && y !== null && isShow) {
|
|
382
452
|
const color = gdata.dataColor;
|
|
383
|
-
ctx.shadowColor = Util.colorStringToRgba('#
|
|
453
|
+
ctx.shadowColor = Util.colorStringToRgba('#959494');
|
|
384
454
|
ctx.strokeStyle = Util.colorStringToRgba(color);
|
|
385
455
|
ctx.fillStyle = Util.colorStringToRgba(color);
|
|
386
|
-
|
|
456
|
+
|
|
457
|
+
if (this.stroke.show) {
|
|
458
|
+
const { lineWidth } = this.stroke;
|
|
459
|
+
x += (lineWidth * 0.5);
|
|
460
|
+
y += (lineWidth * 0.5);
|
|
461
|
+
w -= (lineWidth);
|
|
462
|
+
h -= (lineWidth);
|
|
463
|
+
}
|
|
464
|
+
this.drawItem(ctx, x - 0.5, y - 0.5, w + 1, h + 1, this.stroke);
|
|
387
465
|
|
|
388
466
|
ctx.restore();
|
|
389
467
|
|
|
@@ -413,7 +491,7 @@ class HeatMap {
|
|
|
413
491
|
};
|
|
414
492
|
const gdata = this.data;
|
|
415
493
|
|
|
416
|
-
const
|
|
494
|
+
const itemIndex = gdata.findIndex((data) => {
|
|
417
495
|
const { xp: x, yp: y, w: wSize, h: hSize } = data;
|
|
418
496
|
|
|
419
497
|
return (x <= xp)
|
|
@@ -422,9 +500,11 @@ class HeatMap {
|
|
|
422
500
|
&& (yp <= y + hSize);
|
|
423
501
|
});
|
|
424
502
|
|
|
425
|
-
if (
|
|
503
|
+
if (itemIndex > -1) {
|
|
504
|
+
const foundItem = gdata[itemIndex];
|
|
426
505
|
item.data = foundItem;
|
|
427
506
|
item.color = foundItem.dataColor;
|
|
507
|
+
item.index = itemIndex;
|
|
428
508
|
item.hit = true;
|
|
429
509
|
}
|
|
430
510
|
|
|
@@ -19,7 +19,8 @@ const modules = {
|
|
|
19
19
|
let isExistSelectedLabel;
|
|
20
20
|
|
|
21
21
|
if (labelTipOpt.use && labelTipOpt.showTip) {
|
|
22
|
-
|
|
22
|
+
const isHeatMap = opt.type === 'heatMap';
|
|
23
|
+
isExistSelectedLabel = isHeatMap ? this.drawLabelTipForHeatMap() : this.drawLabelTip();
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
const executeDrawIndicator = (tipOpt) => {
|
|
@@ -365,6 +366,55 @@ const modules = {
|
|
|
365
366
|
|
|
366
367
|
return drawTip;
|
|
367
368
|
},
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Draw Selected Label Tip
|
|
372
|
+
* @returns {boolean} Whether drew at least one tip
|
|
373
|
+
*/
|
|
374
|
+
drawLabelTipForHeatMap() {
|
|
375
|
+
const opt = this.options;
|
|
376
|
+
const isHorizontal = !!opt.horizontal;
|
|
377
|
+
const labelTipOpt = opt.selectLabel;
|
|
378
|
+
const { dataIndex } = this.defaultSelectInfo;
|
|
379
|
+
let drawTip = false;
|
|
380
|
+
|
|
381
|
+
if (dataIndex) {
|
|
382
|
+
drawTip = true;
|
|
383
|
+
|
|
384
|
+
const chartRect = this.chartRect;
|
|
385
|
+
const labelOffset = this.labelOffset;
|
|
386
|
+
const aPos = {
|
|
387
|
+
x1: chartRect.x1 + labelOffset.left,
|
|
388
|
+
x2: chartRect.x2 - labelOffset.right,
|
|
389
|
+
y1: chartRect.y1 + labelOffset.top,
|
|
390
|
+
y2: chartRect.y2 - labelOffset.bottom,
|
|
391
|
+
};
|
|
392
|
+
const labelAxes = isHorizontal ? this.axesY[0] : this.axesX[0];
|
|
393
|
+
const labelStartPoint = aPos[labelAxes.units.rectStart];
|
|
394
|
+
const labelEndPoint = aPos[labelAxes.units.rectEnd];
|
|
395
|
+
const labelGap = (labelEndPoint - labelStartPoint) / labelAxes.labels.length;
|
|
396
|
+
|
|
397
|
+
const valueAxes = isHorizontal ? this.axesX[0] : this.axesY[0];
|
|
398
|
+
const offset = 6 * (isHorizontal ? 1 : -1);
|
|
399
|
+
const gp = aPos[valueAxes.units.rectEnd] + offset;
|
|
400
|
+
|
|
401
|
+
dataIndex?.forEach((index) => {
|
|
402
|
+
const labelCenter = Math.round(labelStartPoint + (labelGap * index));
|
|
403
|
+
const dp = labelCenter + (labelGap / 2);
|
|
404
|
+
|
|
405
|
+
this.showTip({
|
|
406
|
+
context: this.bufferCtx,
|
|
407
|
+
x: isHorizontal ? gp : dp,
|
|
408
|
+
y: isHorizontal ? dp : gp,
|
|
409
|
+
opt: labelTipOpt,
|
|
410
|
+
isSamePos: false,
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return drawTip;
|
|
416
|
+
},
|
|
417
|
+
|
|
368
418
|
/**
|
|
369
419
|
* Calculate x, y position to draw text tip
|
|
370
420
|
* @param {object} param object for drawing text tip
|
|
@@ -56,7 +56,7 @@ const modules = {
|
|
|
56
56
|
this.seriesInfo.charts.heatMap.push(id);
|
|
57
57
|
const { heatMapColor, legend } = this.options;
|
|
58
58
|
const isGradient = legend.type === 'gradient';
|
|
59
|
-
return new HeatMap(id, opt, heatMapColor, isGradient);
|
|
59
|
+
return new HeatMap(id, opt, heatMapColor, isHorizontal, isGradient);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return false;
|
|
@@ -420,7 +420,7 @@ const modules = {
|
|
|
420
420
|
getSeriesValueOptForHeatMap(series) {
|
|
421
421
|
const { data, colorState, isGradient } = series;
|
|
422
422
|
const colorOpt = this.options.heatMapColor;
|
|
423
|
-
const
|
|
423
|
+
const rangeCount = colorOpt.colorsByRange.length || colorOpt.rangeCount;
|
|
424
424
|
const decimalPoint = colorOpt.decimalPoint;
|
|
425
425
|
|
|
426
426
|
let minValue;
|
|
@@ -444,20 +444,21 @@ const modules = {
|
|
|
444
444
|
if (
|
|
445
445
|
isExistError
|
|
446
446
|
&& !isGradient
|
|
447
|
-
&& colorState.length ===
|
|
447
|
+
&& colorState.length === rangeCount
|
|
448
448
|
) {
|
|
449
449
|
colorState.push({
|
|
450
|
-
id: `color#${
|
|
450
|
+
id: `color#${rangeCount}`,
|
|
451
451
|
color: colorOpt.error,
|
|
452
452
|
state: 'normal',
|
|
453
|
+
label: 'Error',
|
|
453
454
|
show: true,
|
|
454
455
|
});
|
|
455
456
|
}
|
|
456
457
|
|
|
457
|
-
let interval = maxValue > minValue ? Math.floor((maxValue - minValue) /
|
|
458
|
-
if ((maxValue - minValue) <=
|
|
458
|
+
let interval = maxValue > minValue ? Math.floor((maxValue - minValue) / rangeCount) : 1;
|
|
459
|
+
if ((maxValue - minValue) <= rangeCount) {
|
|
459
460
|
if (decimalPoint > 0) {
|
|
460
|
-
interval = +((maxValue - minValue) /
|
|
461
|
+
interval = +((maxValue - minValue) / rangeCount).toFixed(decimalPoint);
|
|
461
462
|
} else {
|
|
462
463
|
interval = 1;
|
|
463
464
|
}
|
|
@@ -121,10 +121,6 @@ const modules = {
|
|
|
121
121
|
const offset = this.getMousePosition(e);
|
|
122
122
|
const hitInfo = this.getItemByPosition(offset, false);
|
|
123
123
|
|
|
124
|
-
if (hitInfo.label !== null) {
|
|
125
|
-
this.render(hitInfo);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
124
|
({
|
|
129
125
|
label: args.label,
|
|
130
126
|
value: args.value,
|
|
@@ -132,6 +128,14 @@ const modules = {
|
|
|
132
128
|
maxIndex: args.dataIndex,
|
|
133
129
|
acc: args.acc,
|
|
134
130
|
} = hitInfo);
|
|
131
|
+
|
|
132
|
+
if (this.options.type === 'heatMap') {
|
|
133
|
+
args.deselect = this.setDeselectItem(hitInfo);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (hitInfo.label !== null) {
|
|
137
|
+
this.render(hitInfo);
|
|
138
|
+
}
|
|
135
139
|
} else if (this.options.selectLabel.use && this.options.selectLabel.useClick) {
|
|
136
140
|
const offset = this.getMousePosition(e);
|
|
137
141
|
const clickedLabelInfo = this.getLabelInfoByPosition(offset);
|
|
@@ -619,10 +623,16 @@ const modules = {
|
|
|
619
623
|
*/
|
|
620
624
|
initSelectedInfo() {
|
|
621
625
|
if (this.options.selectLabel.use) {
|
|
622
|
-
const { limit } = this.options.selectLabel;
|
|
623
626
|
if (!this.defaultSelectInfo) {
|
|
624
627
|
this.defaultSelectInfo = { dataIndex: [] };
|
|
625
628
|
}
|
|
629
|
+
|
|
630
|
+
if (this.options.type === 'heatMap') {
|
|
631
|
+
this.initSelectedInfoForHeatMap();
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
const { limit } = this.options.selectLabel;
|
|
626
636
|
const infoObj = this.defaultSelectInfo;
|
|
627
637
|
infoObj.dataIndex.splice(limit);
|
|
628
638
|
infoObj.label = infoObj.dataIndex.map(i => this.data.labels[i]);
|
|
@@ -636,6 +646,26 @@ const modules = {
|
|
|
636
646
|
}
|
|
637
647
|
},
|
|
638
648
|
|
|
649
|
+
/**
|
|
650
|
+
* init defaultSelectInfo object for HeatMap.
|
|
651
|
+
* - at selectLabel using: set each series data and label text
|
|
652
|
+
*/
|
|
653
|
+
initSelectedInfoForHeatMap() {
|
|
654
|
+
const { limit } = this.options.selectLabel;
|
|
655
|
+
const isHorizontal = this.options.horizontal;
|
|
656
|
+
|
|
657
|
+
const infoObj = this.defaultSelectInfo;
|
|
658
|
+
infoObj.dataIndex.splice(limit);
|
|
659
|
+
|
|
660
|
+
const targetLabel = isHorizontal ? 'y' : 'x';
|
|
661
|
+
infoObj.label = infoObj.dataIndex.map(i => this.data.labels[targetLabel][i]);
|
|
662
|
+
|
|
663
|
+
const dataValues = Object.values(this.data.data)[0];
|
|
664
|
+
infoObj.data = dataValues.filter(({ x, y }) =>
|
|
665
|
+
(infoObj.label.includes(isHorizontal ? y : x)),
|
|
666
|
+
);
|
|
667
|
+
},
|
|
668
|
+
|
|
639
669
|
/**
|
|
640
670
|
* Add or delete selected label index, according to policy and option
|
|
641
671
|
* (set each series data and label text)
|
|
@@ -788,6 +818,19 @@ const modules = {
|
|
|
788
818
|
yMax: yMax ?? dataRangeY.graphMax,
|
|
789
819
|
};
|
|
790
820
|
},
|
|
821
|
+
|
|
822
|
+
setDeselectItem(hitInfo) {
|
|
823
|
+
let deselect = false;
|
|
824
|
+
if (this.options.selectItem.useDeselectItem) {
|
|
825
|
+
const isEqualSelectItem = hitInfo?.maxIndex === this.defaultSelectItemInfo?.dataIndex;
|
|
826
|
+
if (!isNaN(hitInfo?.maxIndex) && isEqualSelectItem) {
|
|
827
|
+
deselect = true;
|
|
828
|
+
this.defaultSelectItemInfo = null;
|
|
829
|
+
return true;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
return deselect;
|
|
833
|
+
},
|
|
791
834
|
};
|
|
792
835
|
|
|
793
836
|
export default modules;
|
|
@@ -147,8 +147,9 @@ const modules = {
|
|
|
147
147
|
const { min, max, interval, existError, decimalPoint } = valueOpt;
|
|
148
148
|
const length = colorState.length;
|
|
149
149
|
const endIndex = existError ? length - 2 : length - 1;
|
|
150
|
+
|
|
150
151
|
for (let index = 0; index < length; index++) {
|
|
151
|
-
const
|
|
152
|
+
const { id, color, label = '' } = colorState[index];
|
|
152
153
|
const minValue = min + (interval * index);
|
|
153
154
|
let maxValue = minValue + interval;
|
|
154
155
|
if (index < endIndex) {
|
|
@@ -157,24 +158,25 @@ const modules = {
|
|
|
157
158
|
maxValue = max + (0.1 ** decimalPoint);
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
let name =
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
let name = label;
|
|
162
|
+
if (!name) {
|
|
163
|
+
name = `${minValue.toFixed(decimalPoint)} - ${maxValue.toFixed(decimalPoint)}`;
|
|
164
|
+
if (min === undefined || max === undefined) {
|
|
165
|
+
if (index === 0) {
|
|
166
|
+
name = '0';
|
|
167
|
+
} else {
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
} else if (minValue > max) {
|
|
165
171
|
break;
|
|
172
|
+
} else if (interval <= 1 && decimalPoint === 0) {
|
|
173
|
+
name = minValue;
|
|
166
174
|
}
|
|
167
|
-
} else if (existError && index === endIndex + 1) {
|
|
168
|
-
name = 'error';
|
|
169
|
-
} else if (minValue > max) {
|
|
170
|
-
break;
|
|
171
|
-
} else if (interval <= 1 && decimalPoint === 0) {
|
|
172
|
-
name = minValue;
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
this.addLegend({
|
|
176
|
-
cId:
|
|
177
|
-
color
|
|
178
|
+
cId: id,
|
|
179
|
+
color,
|
|
178
180
|
name,
|
|
179
181
|
show: true,
|
|
180
182
|
});
|
|
@@ -425,6 +427,7 @@ const modules = {
|
|
|
425
427
|
}
|
|
426
428
|
|
|
427
429
|
const targetId = targetDOM?.series?.cId;
|
|
430
|
+
const legendHitInfo = { sId: targetId, type: this.options.type };
|
|
428
431
|
|
|
429
432
|
series.colorState.forEach((colorItem) => {
|
|
430
433
|
colorItem.state = colorItem.id === targetId ? 'highlight' : 'downplay';
|
|
@@ -433,6 +436,9 @@ const modules = {
|
|
|
433
436
|
this.update({
|
|
434
437
|
updateSeries: false,
|
|
435
438
|
updateSelTip: { update: false, keepDomain: false },
|
|
439
|
+
hitInfo: {
|
|
440
|
+
legend: legendHitInfo,
|
|
441
|
+
},
|
|
436
442
|
});
|
|
437
443
|
};
|
|
438
444
|
|
|
@@ -349,6 +349,7 @@ const modules = {
|
|
|
349
349
|
const series = Object.values(this.seriesList)[0];
|
|
350
350
|
|
|
351
351
|
let isShow = false;
|
|
352
|
+
let valueText = hitItem.formatted;
|
|
352
353
|
const { colorState, isGradient } = series;
|
|
353
354
|
if (isGradient) {
|
|
354
355
|
const { min, max } = series.valueOpt;
|
|
@@ -356,7 +357,9 @@ const modules = {
|
|
|
356
357
|
const { start, end } = colorState[0];
|
|
357
358
|
isShow = (start <= ratio && ratio <= end) || hitItem.o === -1;
|
|
358
359
|
} else {
|
|
359
|
-
|
|
360
|
+
const colorItem = colorState.find(({ id }) => id === hitItem.cId);
|
|
361
|
+
isShow = colorItem?.show;
|
|
362
|
+
valueText = colorItem?.label ?? valueText;
|
|
360
363
|
}
|
|
361
364
|
|
|
362
365
|
if (!isShow) {
|
|
@@ -392,7 +395,6 @@ const modules = {
|
|
|
392
395
|
|
|
393
396
|
const itemX = boxPadding.l + 2;
|
|
394
397
|
const itemY = boxPadding.t + TEXT_HEIGHT + 2;
|
|
395
|
-
const valueText = hitItem.formatted;
|
|
396
398
|
|
|
397
399
|
ctx.font = fontStyle;
|
|
398
400
|
|