evui 3.3.48 → 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 +311 -100
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +311 -100
- 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 +115 -46
- package/src/components/chart/element/element.tip.js +51 -1
- package/src/components/chart/helpers/helpers.constant.js +1 -0
- package/src/components/chart/model/model.series.js +1 -1
- package/src/components/chart/model/model.store.js +6 -6
- package/src/components/chart/plugins/plugins.interaction.js +48 -5
- package/src/components/chart/plugins/plugins.legend.js +4 -0
- 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 -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,14 +48,13 @@ 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
|
});
|
|
55
|
-
} else if (
|
|
56
|
-
|
|
57
|
-
categoryColors.forEach(({ color, label }, ix) => {
|
|
56
|
+
} else if (colorsByRange.length) {
|
|
57
|
+
colorsByRange.forEach(({ color, label }, ix) => {
|
|
58
58
|
colorState.push({
|
|
59
59
|
id: `color#${ix}`,
|
|
60
60
|
color,
|
|
@@ -64,11 +64,11 @@ class HeatMap {
|
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
} else {
|
|
67
|
-
const unitR = Math.floor((minR - maxR) / (
|
|
68
|
-
const unitG = Math.floor((minG - maxG) / (
|
|
69
|
-
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));
|
|
70
70
|
|
|
71
|
-
for (let ix = 0; ix <
|
|
71
|
+
for (let ix = 0; ix < rangeCount; ix++) {
|
|
72
72
|
const r = +minR - (unitR * ix);
|
|
73
73
|
const g = +minG - (unitG * ix);
|
|
74
74
|
const b = +minB - (unitB * ix);
|
|
@@ -100,7 +100,7 @@ class HeatMap {
|
|
|
100
100
|
return `rgb(${r},${g},${b})`;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
getColorIndexByValue(value) {
|
|
104
104
|
const { existError, min, interval, decimalPoint } = this.valueOpt;
|
|
105
105
|
const maxIndex = this.colorState.length - 1;
|
|
106
106
|
if (existError && value < 0) {
|
|
@@ -120,7 +120,7 @@ class HeatMap {
|
|
|
120
120
|
const { min, max } = this.valueOpt;
|
|
121
121
|
const itemInfo = {
|
|
122
122
|
show: false,
|
|
123
|
-
opacity:
|
|
123
|
+
opacity: 1,
|
|
124
124
|
dataColor: null,
|
|
125
125
|
id: null,
|
|
126
126
|
isHighlight: null,
|
|
@@ -132,12 +132,11 @@ class HeatMap {
|
|
|
132
132
|
itemInfo.show = true;
|
|
133
133
|
itemInfo.isHighlight = selectedValue !== null
|
|
134
134
|
&& (Math.floor(value) === Math.floor(min + ((max - min) * (selectedValue / 100))));
|
|
135
|
-
itemInfo.opacity = 1;
|
|
136
135
|
itemInfo.dataColor = value < 0
|
|
137
136
|
? this.errorColor : this.getColorForGradient(ratio);
|
|
138
137
|
}
|
|
139
138
|
} else {
|
|
140
|
-
const colorIndex = this.
|
|
139
|
+
const colorIndex = this.getColorIndexByValue(value);
|
|
141
140
|
const { show, state, color, id } = this.colorState[colorIndex];
|
|
142
141
|
itemInfo.show = show;
|
|
143
142
|
itemInfo.opacity = state === 'downplay' ? 0.1 : 1;
|
|
@@ -147,16 +146,22 @@ class HeatMap {
|
|
|
147
146
|
return itemInfo;
|
|
148
147
|
}
|
|
149
148
|
|
|
150
|
-
drawItem(ctx, x, y, w, h) {
|
|
149
|
+
drawItem(ctx, x, y, w, h, borderOpt) {
|
|
151
150
|
ctx.beginPath();
|
|
152
|
-
if (
|
|
153
|
-
const { radius } =
|
|
154
|
-
if (radius > 0
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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();
|
|
160
165
|
ctx.fill();
|
|
161
166
|
} else {
|
|
162
167
|
ctx.strokeRect(x, y, w, h);
|
|
@@ -204,7 +209,15 @@ class HeatMap {
|
|
|
204
209
|
return;
|
|
205
210
|
}
|
|
206
211
|
|
|
207
|
-
const {
|
|
212
|
+
const {
|
|
213
|
+
ctx,
|
|
214
|
+
chartRect,
|
|
215
|
+
labelOffset,
|
|
216
|
+
overlayCtx,
|
|
217
|
+
selectLabel,
|
|
218
|
+
legendHitInfo,
|
|
219
|
+
selectItem,
|
|
220
|
+
} = param;
|
|
208
221
|
|
|
209
222
|
const xArea = chartRect.chartWidth - (labelOffset.left + labelOffset.right);
|
|
210
223
|
const yArea = chartRect.chartHeight - (labelOffset.top + labelOffset.bottom);
|
|
@@ -215,34 +228,80 @@ class HeatMap {
|
|
|
215
228
|
this.size.w = xArea / this.labels.x.length;
|
|
216
229
|
this.size.h = yArea / this.labels.y.length;
|
|
217
230
|
|
|
218
|
-
|
|
219
|
-
|
|
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;
|
|
220
253
|
let yp = this.calculateXY('y', item.y, ysp);
|
|
221
254
|
let w = this.size.w;
|
|
222
255
|
let h = this.size.h;
|
|
256
|
+
|
|
223
257
|
const value = item.o;
|
|
224
258
|
|
|
225
259
|
if (xp !== null && yp !== null
|
|
226
260
|
&& (value !== null && value !== undefined)) {
|
|
227
|
-
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
|
+
|
|
228
271
|
item.dataColor = dataColor;
|
|
229
272
|
item.cId = id;
|
|
230
273
|
ctx.save();
|
|
274
|
+
|
|
231
275
|
if (show) {
|
|
232
|
-
ctx.fillStyle = Util.colorStringToRgba(item.dataColor,
|
|
233
|
-
|
|
234
|
-
|
|
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;
|
|
235
291
|
ctx.strokeStyle = Util.colorStringToRgba(
|
|
236
292
|
color,
|
|
237
|
-
|
|
293
|
+
itemOpacity === 1 ? borderOpacity : itemOpacity,
|
|
238
294
|
);
|
|
295
|
+
|
|
239
296
|
ctx.lineWidth = lineWidth;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
297
|
+
|
|
298
|
+
xp += (lineWidth * 0.5);
|
|
299
|
+
yp += (lineWidth * 0.5);
|
|
300
|
+
w -= (lineWidth);
|
|
301
|
+
h -= (lineWidth);
|
|
244
302
|
}
|
|
245
|
-
|
|
303
|
+
|
|
304
|
+
this.drawItem(ctx, xp, yp, w, h, borderOpt);
|
|
246
305
|
ctx.restore();
|
|
247
306
|
|
|
248
307
|
item.xp = xp;
|
|
@@ -369,10 +428,10 @@ class HeatMap {
|
|
|
369
428
|
const gdata = item.data;
|
|
370
429
|
const ctx = context;
|
|
371
430
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
431
|
+
let x = gdata.xp;
|
|
432
|
+
let y = gdata.yp;
|
|
433
|
+
let w = gdata.w;
|
|
434
|
+
let h = gdata.h;
|
|
376
435
|
const cId = gdata.cId;
|
|
377
436
|
|
|
378
437
|
let isShow;
|
|
@@ -385,16 +444,24 @@ class HeatMap {
|
|
|
385
444
|
isShow = this.colorState.find(({ id }) => id === cId)?.show;
|
|
386
445
|
}
|
|
387
446
|
ctx.save();
|
|
388
|
-
ctx.shadowOffsetX =
|
|
389
|
-
ctx.shadowOffsetY =
|
|
447
|
+
ctx.shadowOffsetX = 0;
|
|
448
|
+
ctx.shadowOffsetY = 0;
|
|
390
449
|
ctx.shadowBlur = 4;
|
|
391
450
|
|
|
392
451
|
if (x !== null && y !== null && isShow) {
|
|
393
452
|
const color = gdata.dataColor;
|
|
394
|
-
ctx.shadowColor = Util.colorStringToRgba('#
|
|
453
|
+
ctx.shadowColor = Util.colorStringToRgba('#959494');
|
|
395
454
|
ctx.strokeStyle = Util.colorStringToRgba(color);
|
|
396
455
|
ctx.fillStyle = Util.colorStringToRgba(color);
|
|
397
|
-
|
|
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);
|
|
398
465
|
|
|
399
466
|
ctx.restore();
|
|
400
467
|
|
|
@@ -424,7 +491,7 @@ class HeatMap {
|
|
|
424
491
|
};
|
|
425
492
|
const gdata = this.data;
|
|
426
493
|
|
|
427
|
-
const
|
|
494
|
+
const itemIndex = gdata.findIndex((data) => {
|
|
428
495
|
const { xp: x, yp: y, w: wSize, h: hSize } = data;
|
|
429
496
|
|
|
430
497
|
return (x <= xp)
|
|
@@ -433,9 +500,11 @@ class HeatMap {
|
|
|
433
500
|
&& (yp <= y + hSize);
|
|
434
501
|
});
|
|
435
502
|
|
|
436
|
-
if (
|
|
503
|
+
if (itemIndex > -1) {
|
|
504
|
+
const foundItem = gdata[itemIndex];
|
|
437
505
|
item.data = foundItem;
|
|
438
506
|
item.color = foundItem.dataColor;
|
|
507
|
+
item.index = itemIndex;
|
|
439
508
|
item.hit = true;
|
|
440
509
|
}
|
|
441
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,10 +444,10 @@ 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
453
|
label: 'Error',
|
|
@@ -455,10 +455,10 @@ const modules = {
|
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
-
let interval = maxValue > minValue ? Math.floor((maxValue - minValue) /
|
|
459
|
-
if ((maxValue - minValue) <=
|
|
458
|
+
let interval = maxValue > minValue ? Math.floor((maxValue - minValue) / rangeCount) : 1;
|
|
459
|
+
if ((maxValue - minValue) <= rangeCount) {
|
|
460
460
|
if (decimalPoint > 0) {
|
|
461
|
-
interval = +((maxValue - minValue) /
|
|
461
|
+
interval = +((maxValue - minValue) / rangeCount).toFixed(decimalPoint);
|
|
462
462
|
} else {
|
|
463
463
|
interval = 1;
|
|
464
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;
|
|
@@ -427,6 +427,7 @@ const modules = {
|
|
|
427
427
|
}
|
|
428
428
|
|
|
429
429
|
const targetId = targetDOM?.series?.cId;
|
|
430
|
+
const legendHitInfo = { sId: targetId, type: this.options.type };
|
|
430
431
|
|
|
431
432
|
series.colorState.forEach((colorItem) => {
|
|
432
433
|
colorItem.state = colorItem.id === targetId ? 'highlight' : 'downplay';
|
|
@@ -435,6 +436,9 @@ const modules = {
|
|
|
435
436
|
this.update({
|
|
436
437
|
updateSeries: false,
|
|
437
438
|
updateSelTip: { update: false, keepDomain: false },
|
|
439
|
+
hitInfo: {
|
|
440
|
+
legend: legendHitInfo,
|
|
441
|
+
},
|
|
438
442
|
});
|
|
439
443
|
};
|
|
440
444
|
|
|
@@ -127,6 +127,14 @@ const DEFAULT_OPTIONS = {
|
|
|
127
127
|
fontWeight: 400,
|
|
128
128
|
},
|
|
129
129
|
useSeriesOpacity: false,
|
|
130
|
+
useDeselectItem: false,
|
|
131
|
+
showBorder: false,
|
|
132
|
+
borderStyle: {
|
|
133
|
+
color: '#FFFFFF',
|
|
134
|
+
lineWidth: 1,
|
|
135
|
+
opacity: 1,
|
|
136
|
+
radius: 0,
|
|
137
|
+
},
|
|
130
138
|
},
|
|
131
139
|
selectLabel: {
|
|
132
140
|
use: false,
|
|
@@ -196,8 +204,8 @@ const DEFAULT_OPTIONS = {
|
|
|
196
204
|
heatMapColor: {
|
|
197
205
|
min: '#FFFFFF',
|
|
198
206
|
max: '#0052FF',
|
|
199
|
-
|
|
200
|
-
|
|
207
|
+
rangeCount: 1,
|
|
208
|
+
colorsByRange: [],
|
|
201
209
|
stroke: {
|
|
202
210
|
show: false,
|
|
203
211
|
color: '#FFFFFF',
|
|
@@ -248,7 +256,14 @@ export const useModel = (selectedLabel) => {
|
|
|
248
256
|
click: async (e) => {
|
|
249
257
|
await nextTick();
|
|
250
258
|
if (e.label) {
|
|
251
|
-
|
|
259
|
+
let selectedItem = { seriesID: e.seriesId, dataIndex: e.dataIndex };
|
|
260
|
+
if ('deselect' in e) {
|
|
261
|
+
if (e.deselect) {
|
|
262
|
+
selectedItem = null;
|
|
263
|
+
}
|
|
264
|
+
delete e.deselect;
|
|
265
|
+
}
|
|
266
|
+
emit('update:selectedItem', selectedItem);
|
|
252
267
|
}
|
|
253
268
|
if (e.selected?.dataIndex) {
|
|
254
269
|
if (selectedLabel?.value) {
|