evui 3.3.8 → 3.3.11
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 +2982 -792
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +2982 -792
- 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.vue +15 -6
- package/src/components/chart/chart.core.js +86 -31
- package/src/components/chart/element/element.bar.js +9 -3
- package/src/components/chart/element/element.heatmap.js +213 -0
- package/src/components/chart/element/element.pie.js +75 -5
- package/src/components/chart/element/element.scatter.js +26 -9
- package/src/components/chart/element/element.tip.js +158 -13
- package/src/components/chart/helpers/helpers.constant.js +22 -0
- package/src/components/chart/model/model.series.js +4 -0
- package/src/components/chart/model/model.store.js +166 -2
- package/src/components/chart/plugins/plugins.interaction.js +78 -10
- package/src/components/chart/plugins/plugins.legend.js +213 -42
- package/src/components/chart/plugins/plugins.pie.js +2 -0
- package/src/components/chart/plugins/plugins.tooltip.js +249 -6
- package/src/components/chart/scale/scale.js +20 -2
- package/src/components/chart/scale/scale.step.js +20 -5
- package/src/components/chart/scale/scale.time.category.js +20 -2
- package/src/components/chart/uses.js +20 -3
- package/src/components/grid/Grid.vue +276 -132
- package/src/components/grid/grid.filter.window.vue +1 -0
- package/src/components/grid/grid.pagination.vue +75 -0
- package/src/components/grid/grid.summary.vue +221 -0
- package/src/components/grid/style/grid.scss +0 -14
- package/src/components/grid/uses.js +157 -78
- package/src/components/pagination/Pagination.vue +20 -17
|
@@ -69,18 +69,34 @@ class Scatter {
|
|
|
69
69
|
return item;
|
|
70
70
|
}, this.data[0]);
|
|
71
71
|
|
|
72
|
-
const getOpacity = (colorStr) => {
|
|
72
|
+
const getOpacity = (colorStr, dataIndex) => {
|
|
73
73
|
const noneDownplayOpacity = colorStr.includes('rgba') ? Util.getOpacity(colorStr) : 1;
|
|
74
|
-
|
|
74
|
+
let resultOpacity = noneDownplayOpacity;
|
|
75
|
+
|
|
76
|
+
const { selectInfo } = param;
|
|
77
|
+
if (selectInfo) {
|
|
78
|
+
const isSelectedData = selectInfo?.seriesID === this.sId
|
|
79
|
+
&& selectInfo?.dataIndex === dataIndex;
|
|
80
|
+
|
|
81
|
+
if (isSelectedData) {
|
|
82
|
+
resultOpacity = noneDownplayOpacity;
|
|
83
|
+
} else {
|
|
84
|
+
resultOpacity = 0.1;
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
resultOpacity = this.state === 'downplay' ? 0.1 : noneDownplayOpacity;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return resultOpacity;
|
|
75
91
|
};
|
|
76
92
|
|
|
77
|
-
this.data.forEach((curr) => {
|
|
93
|
+
this.data.forEach((curr, idx) => {
|
|
78
94
|
if (curr.xp !== null && curr.yp !== null) {
|
|
79
95
|
const color = curr.dataColor || this.color;
|
|
80
|
-
ctx.strokeStyle = Util.colorStringToRgba(color, getOpacity(color));
|
|
96
|
+
ctx.strokeStyle = Util.colorStringToRgba(color, getOpacity(color, idx));
|
|
81
97
|
|
|
82
98
|
const pointFillColor = curr.dataColor || this.pointFill;
|
|
83
|
-
ctx.fillStyle = Util.colorStringToRgba(pointFillColor, getOpacity(pointFillColor));
|
|
99
|
+
ctx.fillStyle = Util.colorStringToRgba(pointFillColor, getOpacity(pointFillColor, idx));
|
|
84
100
|
|
|
85
101
|
Canvas.drawPoint(ctx, this.pointStyle, this.pointSize, curr.xp, curr.yp);
|
|
86
102
|
}
|
|
@@ -148,11 +164,11 @@ class Scatter {
|
|
|
148
164
|
findGraphData(offset) {
|
|
149
165
|
const xp = offset[0];
|
|
150
166
|
const yp = offset[1];
|
|
151
|
-
const item = { data: null, hit: false, color: this.color };
|
|
167
|
+
const item = { data: null, hit: false, color: this.color, index: null };
|
|
152
168
|
const pointSize = this.pointSize;
|
|
153
169
|
const gdata = this.data;
|
|
154
170
|
|
|
155
|
-
const
|
|
171
|
+
const targetIndex = gdata.findIndex((data) => {
|
|
156
172
|
const x = data.xp;
|
|
157
173
|
const y = data.yp;
|
|
158
174
|
|
|
@@ -162,8 +178,9 @@ class Scatter {
|
|
|
162
178
|
&& (yp <= y + pointSize);
|
|
163
179
|
});
|
|
164
180
|
|
|
165
|
-
if (
|
|
166
|
-
item.data =
|
|
181
|
+
if (targetIndex > -1) {
|
|
182
|
+
item.data = gdata[targetIndex];
|
|
183
|
+
item.index = targetIndex;
|
|
167
184
|
item.hit = true;
|
|
168
185
|
}
|
|
169
186
|
|
|
@@ -14,9 +14,15 @@ const modules = {
|
|
|
14
14
|
const isHorizontal = !!opt.horizontal;
|
|
15
15
|
const maxTipOpt = opt.maxTip;
|
|
16
16
|
const selTipOpt = opt.selectItem;
|
|
17
|
+
const labelTipOpt = opt.selectLabel;
|
|
17
18
|
let maxArgs;
|
|
19
|
+
let isExistSelectedLabel;
|
|
18
20
|
|
|
19
|
-
if (
|
|
21
|
+
if (labelTipOpt.use && labelTipOpt.showTip) {
|
|
22
|
+
isExistSelectedLabel = this.drawLabelTip();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (selTipOpt.use && tipLocationInfo && !isExistSelectedLabel) {
|
|
20
26
|
const seriesInfo = this.seriesList[tipLocationInfo?.sId];
|
|
21
27
|
|
|
22
28
|
if (!seriesInfo?.show) {
|
|
@@ -45,29 +51,30 @@ const modules = {
|
|
|
45
51
|
selArgs.text = numberWithComma(selArgs.value);
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
this.drawTextTip({ opt: selTipOpt, tipType: 'sel', isSamePos, ...selArgs });
|
|
54
|
+
this.drawTextTip({ opt: selTipOpt, tipType: 'sel', seriesOpt: seriesInfo, isSamePos, ...selArgs });
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
if (selTipOpt.showIndicator) {
|
|
52
|
-
this.drawFixedIndicator({ opt: selTipOpt, ...selArgs });
|
|
58
|
+
this.drawFixedIndicator({ opt: selTipOpt, seriesOpt: seriesInfo, ...selArgs });
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
if (tipLocationInfo && tipLocationInfo
|
|
62
|
+
if (tipLocationInfo && tipLocationInfo?.label && tipLocationInfo?.label === 0) {
|
|
57
63
|
this.lastHitInfo = tipLocationInfo;
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
if (maxTipOpt.use) {
|
|
67
|
+
if (maxTipOpt.use && !isExistSelectedLabel) {
|
|
62
68
|
const maxSID = this.minMax[isHorizontal ? 'x' : 'y'][0].maxSID;
|
|
63
|
-
|
|
69
|
+
const seriesInfo = this.seriesList[maxSID];
|
|
70
|
+
maxArgs = this.calculateTipInfo(seriesInfo, 'max', null);
|
|
64
71
|
|
|
65
72
|
if (maxTipOpt.use && maxArgs) {
|
|
66
73
|
maxArgs.text = numberWithComma(maxArgs.value);
|
|
67
|
-
this.drawTextTip({ opt: maxTipOpt, tipType: 'max', ...maxArgs });
|
|
74
|
+
this.drawTextTip({ opt: maxTipOpt, tipType: 'max', seriesOpt: seriesInfo, ...maxArgs });
|
|
68
75
|
|
|
69
76
|
if (maxTipOpt.showIndicator) {
|
|
70
|
-
this.drawFixedIndicator({ opt: maxTipOpt, ...maxArgs });
|
|
77
|
+
this.drawFixedIndicator({ opt: maxTipOpt, seriesOpt: seriesInfo, ...maxArgs });
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
}
|
|
@@ -76,7 +83,8 @@ const modules = {
|
|
|
76
83
|
/**
|
|
77
84
|
* Calculate tip size and contents
|
|
78
85
|
* @param {object} series series information (max series or selected series)
|
|
79
|
-
* @param {string} tipType tip type
|
|
86
|
+
* @param {string} tipType tip type
|
|
87
|
+
* [sel = user select series, label = user select label, max = max value]
|
|
80
88
|
* @param {object} hitInfo mouse hit information
|
|
81
89
|
*
|
|
82
90
|
* @returns {object} size and tip contents
|
|
@@ -169,6 +177,14 @@ const modules = {
|
|
|
169
177
|
xArea - size.comboOffset,
|
|
170
178
|
xsp + (size.comboOffset / 2),
|
|
171
179
|
);
|
|
180
|
+
} else if (type === 'scatter') {
|
|
181
|
+
dp = Canvas.calculateX(
|
|
182
|
+
ldata,
|
|
183
|
+
graphX.graphMin,
|
|
184
|
+
graphX.graphMax,
|
|
185
|
+
xArea,
|
|
186
|
+
xsp,
|
|
187
|
+
);
|
|
172
188
|
}
|
|
173
189
|
|
|
174
190
|
const sizeObj = { xArea, yArea, graphX, graphY, xsp, xep, ysp };
|
|
@@ -179,8 +195,14 @@ const modules = {
|
|
|
179
195
|
drawFixedIndicator(param) {
|
|
180
196
|
const isHorizontal = !!this.options.horizontal;
|
|
181
197
|
const ctx = this.bufferCtx;
|
|
182
|
-
const { graphX, graphY, xArea, yArea, xsp, ysp, dp, type, value, opt } = param;
|
|
183
|
-
|
|
198
|
+
const { graphX, graphY, xArea, yArea, xsp, ysp, dp, type, value, opt, seriesOpt } = param;
|
|
199
|
+
let offset = 0;
|
|
200
|
+
|
|
201
|
+
if (type === 'line') {
|
|
202
|
+
offset += 3;
|
|
203
|
+
} else if (type === 'scatter') {
|
|
204
|
+
offset += seriesOpt?.pointSize ?? 0;
|
|
205
|
+
}
|
|
184
206
|
|
|
185
207
|
let gp;
|
|
186
208
|
|
|
@@ -220,6 +242,121 @@ const modules = {
|
|
|
220
242
|
ctx.closePath();
|
|
221
243
|
},
|
|
222
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Draw Selected Label Tip
|
|
247
|
+
* @returns {boolean} Whether drew at least one tip
|
|
248
|
+
*/
|
|
249
|
+
drawLabelTip() {
|
|
250
|
+
const opt = this.options;
|
|
251
|
+
const isHorizontal = !!opt.horizontal;
|
|
252
|
+
const labelTipOpt = opt.selectLabel;
|
|
253
|
+
const { dataIndex, data } = this.defaultSelectLabelInfo;
|
|
254
|
+
let drawTip = false;
|
|
255
|
+
|
|
256
|
+
if (dataIndex.length) {
|
|
257
|
+
drawTip = true;
|
|
258
|
+
|
|
259
|
+
const chartRect = this.chartRect;
|
|
260
|
+
const labelOffset = this.labelOffset;
|
|
261
|
+
const aPos = {
|
|
262
|
+
x1: chartRect.x1 + labelOffset.left,
|
|
263
|
+
x2: chartRect.x2 - labelOffset.right,
|
|
264
|
+
y1: chartRect.y1 + labelOffset.top,
|
|
265
|
+
y2: chartRect.y2 - labelOffset.bottom,
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const labelAxes = this.options.horizontal ? this.axesY[0] : this.axesX[0];
|
|
269
|
+
const labelStartPoint = aPos[labelAxes.units.rectStart];
|
|
270
|
+
const labelEndPoint = aPos[labelAxes.units.rectEnd];
|
|
271
|
+
const labelGap = (labelEndPoint - labelStartPoint) / labelAxes.labels.length;
|
|
272
|
+
|
|
273
|
+
const valueAxes = this.options.horizontal ? this.axesX[0] : this.axesY[0];
|
|
274
|
+
const valueStartPoint = aPos[valueAxes.units.rectStart];
|
|
275
|
+
|
|
276
|
+
const offset = this.options.type === 'bar' ? 4 : 6;
|
|
277
|
+
const chartWidth = chartRect.chartWidth - (labelOffset.left + labelOffset.right);
|
|
278
|
+
const chartHeight = chartRect.chartHeight - (labelOffset.top + labelOffset.bottom);
|
|
279
|
+
|
|
280
|
+
dataIndex.forEach((idx, i) => {
|
|
281
|
+
const labelCenter = Math.round(labelStartPoint + (labelGap * idx));
|
|
282
|
+
let gp;
|
|
283
|
+
const dp = labelCenter + (labelGap / 2);
|
|
284
|
+
if (labelTipOpt.fixedPosTop) {
|
|
285
|
+
if (isHorizontal) {
|
|
286
|
+
gp = Canvas.calculateX(
|
|
287
|
+
this.axesRange.x[0].max,
|
|
288
|
+
this.axesRange.x[0].min,
|
|
289
|
+
this.axesRange.x[0].max,
|
|
290
|
+
chartWidth,
|
|
291
|
+
valueStartPoint);
|
|
292
|
+
gp += offset;
|
|
293
|
+
} else {
|
|
294
|
+
gp = Canvas.calculateY(
|
|
295
|
+
this.axesRange.y[0].max,
|
|
296
|
+
this.axesRange.y[0].min,
|
|
297
|
+
this.axesRange.y[0].max,
|
|
298
|
+
chartHeight,
|
|
299
|
+
valueStartPoint);
|
|
300
|
+
gp -= offset;
|
|
301
|
+
}
|
|
302
|
+
} else if (isHorizontal) {
|
|
303
|
+
const seriesList = Object.keys(data[i] ?? {});
|
|
304
|
+
const visibleSeries = seriesList.filter(sId => this.seriesList[sId].show);
|
|
305
|
+
const visibleValue = visibleSeries.map(sId => data[i][sId]);
|
|
306
|
+
const isExistGrp = seriesList.some(sId => this.seriesList[sId].isExistGrp);
|
|
307
|
+
|
|
308
|
+
let maxValue;
|
|
309
|
+
if (isExistGrp) {
|
|
310
|
+
maxValue = visibleValue.reduce((acc, v) => acc + v) ?? 0;
|
|
311
|
+
} else if (visibleValue.length) {
|
|
312
|
+
maxValue = Math.max(...visibleValue);
|
|
313
|
+
} else {
|
|
314
|
+
maxValue = this.axesRange.x[0].max;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
gp = Canvas.calculateX(
|
|
318
|
+
maxValue,
|
|
319
|
+
this.axesRange.x[0].min,
|
|
320
|
+
this.axesRange.x[0].max,
|
|
321
|
+
chartWidth,
|
|
322
|
+
valueStartPoint);
|
|
323
|
+
gp += offset;
|
|
324
|
+
} else {
|
|
325
|
+
const seriesList = Object.keys(data[i] ?? {});
|
|
326
|
+
const visibleSeries = seriesList.filter(sId => this.seriesList[sId].show);
|
|
327
|
+
const visibleValue = visibleSeries.map(sId => data[i][sId]);
|
|
328
|
+
const isExistGrp = seriesList.some(sId => this.seriesList[sId].isExistGrp);
|
|
329
|
+
|
|
330
|
+
let maxValue;
|
|
331
|
+
if (isExistGrp) {
|
|
332
|
+
maxValue = visibleValue.reduce((acc, v) => acc + v) ?? 0;
|
|
333
|
+
} else if (visibleValue.length) {
|
|
334
|
+
maxValue = Math.max(...visibleValue);
|
|
335
|
+
} else {
|
|
336
|
+
maxValue = this.axesRange.y[0].max;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
gp = Canvas.calculateY(
|
|
340
|
+
maxValue,
|
|
341
|
+
this.axesRange.y[0].min,
|
|
342
|
+
this.axesRange.y[0].max,
|
|
343
|
+
chartHeight,
|
|
344
|
+
valueStartPoint);
|
|
345
|
+
gp -= offset;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
this.showTip({
|
|
349
|
+
context: this.bufferCtx,
|
|
350
|
+
x: isHorizontal ? gp : dp,
|
|
351
|
+
y: isHorizontal ? dp : gp,
|
|
352
|
+
opt: labelTipOpt,
|
|
353
|
+
isSamePos: false,
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return drawTip;
|
|
359
|
+
},
|
|
223
360
|
/**
|
|
224
361
|
* Calculate x, y position to draw text tip
|
|
225
362
|
* @param {object} param object for drawing text tip
|
|
@@ -230,12 +367,20 @@ const modules = {
|
|
|
230
367
|
const isHorizontal = !!this.options.horizontal;
|
|
231
368
|
const ctx = this.bufferCtx;
|
|
232
369
|
const { graphX, graphY, xArea, yArea, xsp, xep, ysp } = param;
|
|
233
|
-
const { dp, value, text, opt, type, tipType, isSamePos } = param;
|
|
370
|
+
const { dp, value, text, opt, type, tipType, isSamePos, seriesOpt } = param;
|
|
234
371
|
|
|
235
372
|
const arrowSize = 4;
|
|
236
373
|
const maxTipHeight = 20;
|
|
237
374
|
const borderRadius = 4;
|
|
238
|
-
|
|
375
|
+
|
|
376
|
+
let offset = 1;
|
|
377
|
+
if (type === 'line') {
|
|
378
|
+
offset += 6;
|
|
379
|
+
} else if (type === 'scatter') {
|
|
380
|
+
offset += seriesOpt?.pointSize;
|
|
381
|
+
} else if (type === 'bar') {
|
|
382
|
+
offset += 4;
|
|
383
|
+
}
|
|
239
384
|
|
|
240
385
|
let gp;
|
|
241
386
|
let tdp = dp;
|
|
@@ -59,6 +59,7 @@ export const BAR_OPTION = {
|
|
|
59
59
|
fontSize: 12,
|
|
60
60
|
textColor: '#000000',
|
|
61
61
|
formatter: null,
|
|
62
|
+
decimalPoint: 0,
|
|
62
63
|
},
|
|
63
64
|
};
|
|
64
65
|
|
|
@@ -70,6 +71,12 @@ export const PIE_OPTION = {
|
|
|
70
71
|
color: '#FFFFFF',
|
|
71
72
|
lineWidth: 2,
|
|
72
73
|
},
|
|
74
|
+
showValue: {
|
|
75
|
+
use: false,
|
|
76
|
+
fontSize: 12,
|
|
77
|
+
textColor: '#000000',
|
|
78
|
+
formatter: null,
|
|
79
|
+
},
|
|
73
80
|
};
|
|
74
81
|
|
|
75
82
|
export const AXIS_OPTION = {
|
|
@@ -121,6 +128,21 @@ export const PLOT_BAND_OPTION = {
|
|
|
121
128
|
color: '#FAE59D',
|
|
122
129
|
};
|
|
123
130
|
|
|
131
|
+
export const HEAT_MAP_OPTION = {
|
|
132
|
+
...LINE_OPTION,
|
|
133
|
+
colorOpt: {
|
|
134
|
+
min: '#FFFFFF',
|
|
135
|
+
max: '#0052FF',
|
|
136
|
+
categoryCnt: 5,
|
|
137
|
+
border: '#FFFFFF',
|
|
138
|
+
error: '#FF0000',
|
|
139
|
+
},
|
|
140
|
+
spaces: {
|
|
141
|
+
x: 0,
|
|
142
|
+
y: 0,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
124
146
|
|
|
125
147
|
export const TIME_INTERVALS = {
|
|
126
148
|
millisecond: {
|
|
@@ -3,6 +3,7 @@ import Scatter from '../element/element.scatter';
|
|
|
3
3
|
import Bar from '../element/element.bar';
|
|
4
4
|
import TimeBar from '../element/element.bar.time';
|
|
5
5
|
import Pie from '../element/element.pie';
|
|
6
|
+
import HeatMap from '../element/element.heatmap';
|
|
6
7
|
|
|
7
8
|
const modules = {
|
|
8
9
|
/**
|
|
@@ -51,6 +52,9 @@ const modules = {
|
|
|
51
52
|
} else if (type === 'pie') {
|
|
52
53
|
this.seriesInfo.charts.pie.push(id);
|
|
53
54
|
return new Pie(id, opt, index);
|
|
55
|
+
} else if (type === 'heatMap') {
|
|
56
|
+
this.seriesInfo.charts.heatMap.push(id);
|
|
57
|
+
return new HeatMap(id, opt, index);
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
return false;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { reverse } from 'lodash-es';
|
|
2
2
|
import Util from '../helpers/helpers.util';
|
|
3
|
+
import { TIME_INTERVALS } from '../helpers/helpers.constant';
|
|
3
4
|
|
|
4
5
|
const modules = {
|
|
5
6
|
/**
|
|
@@ -30,6 +31,17 @@ const modules = {
|
|
|
30
31
|
series.minMax = this.getSeriesMinMax(series.data);
|
|
31
32
|
}
|
|
32
33
|
});
|
|
34
|
+
} else if (typeKey === 'heatMap') {
|
|
35
|
+
seriesIDs.forEach((seriesID) => {
|
|
36
|
+
const series = this.seriesList[seriesID];
|
|
37
|
+
const sData = data[seriesID];
|
|
38
|
+
|
|
39
|
+
if (series && sData) {
|
|
40
|
+
series.data = this.addSeriesDSForHeatMap(sData);
|
|
41
|
+
series.minMax = this.getSeriesMinMaxForHeatMap(series.data, series.spaces);
|
|
42
|
+
series.valueOpt = this.getSeriesValueOptForHeatMap(series);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
33
45
|
} else {
|
|
34
46
|
seriesIDs.forEach((seriesID) => {
|
|
35
47
|
const series = this.seriesList[seriesID];
|
|
@@ -286,6 +298,24 @@ const modules = {
|
|
|
286
298
|
});
|
|
287
299
|
},
|
|
288
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Take data to create data for each series
|
|
303
|
+
* @param {array} data data array for each series
|
|
304
|
+
* @returns {array} data info added position and etc
|
|
305
|
+
*/
|
|
306
|
+
addSeriesDSForHeatMap(data) {
|
|
307
|
+
return data.map(item => ({
|
|
308
|
+
x: item.x,
|
|
309
|
+
y: item.y,
|
|
310
|
+
o: item.value,
|
|
311
|
+
xp: null,
|
|
312
|
+
yp: null,
|
|
313
|
+
dataColor: null,
|
|
314
|
+
value: item.value,
|
|
315
|
+
cId: null,
|
|
316
|
+
}));
|
|
317
|
+
},
|
|
318
|
+
|
|
289
319
|
/**
|
|
290
320
|
* Take data to create data object for graph
|
|
291
321
|
* @param {object} gdata graph data (y-axis value for vertical chart)
|
|
@@ -384,6 +414,96 @@ const modules = {
|
|
|
384
414
|
return def;
|
|
385
415
|
},
|
|
386
416
|
|
|
417
|
+
adjustMinMax(max, min, opt, space) {
|
|
418
|
+
if ((opt.type === 'time' && opt.categoryMode) || opt.type === 'step') {
|
|
419
|
+
return {
|
|
420
|
+
max,
|
|
421
|
+
min,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
let targetMax = max;
|
|
426
|
+
let targetMin = min;
|
|
427
|
+
if (targetMax > 0 && opt.interval && space) {
|
|
428
|
+
if (targetMax < (opt.interval * space)) {
|
|
429
|
+
targetMax += opt.interval;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
let targetInterval = opt.interval;
|
|
434
|
+
if (opt.type === 'time') {
|
|
435
|
+
if (typeof targetInterval === 'string') {
|
|
436
|
+
targetInterval = TIME_INTERVALS[targetInterval].size;
|
|
437
|
+
} else if (typeof targetInterval === 'object') {
|
|
438
|
+
targetInterval = targetInterval.time * TIME_INTERVALS[targetInterval.unit].size;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (!opt.startToZero || targetMin > 0) {
|
|
443
|
+
const targetSpace = space ? (space - 1) : (targetMax - targetMin);
|
|
444
|
+
const targetStep = Math.ceil((max - targetMin) / targetSpace);
|
|
445
|
+
targetMin = targetMin < targetStep ? 0 : targetMin - targetStep;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return {
|
|
449
|
+
max: targetMax,
|
|
450
|
+
min: targetMin,
|
|
451
|
+
};
|
|
452
|
+
},
|
|
453
|
+
/**
|
|
454
|
+
* Take series data to create min/max info for each series
|
|
455
|
+
* @param data
|
|
456
|
+
* @param spaces
|
|
457
|
+
* @returns {*|{maxDomain: null, minY: null, minX: null, maxY: null, maxX: null}}
|
|
458
|
+
*/
|
|
459
|
+
getSeriesMinMaxForHeatMap(data, spaces) {
|
|
460
|
+
const axesXOption = this.options.axesX[0];
|
|
461
|
+
const axesYOption = this.options.axesY[0];
|
|
462
|
+
const seriesMinMax = this.getSeriesMinMax(data);
|
|
463
|
+
|
|
464
|
+
const adjustX = this.adjustMinMax(seriesMinMax.maxX, seriesMinMax.minX, axesXOption, spaces.x);
|
|
465
|
+
seriesMinMax.maxX = adjustX.max;
|
|
466
|
+
seriesMinMax.minX = adjustX.min;
|
|
467
|
+
|
|
468
|
+
const adjustY = this.adjustMinMax(seriesMinMax.maxY, seriesMinMax.minY, axesYOption, spaces.y);
|
|
469
|
+
seriesMinMax.maxY = adjustY.max;
|
|
470
|
+
seriesMinMax.minY = adjustY.min;
|
|
471
|
+
|
|
472
|
+
return seriesMinMax;
|
|
473
|
+
},
|
|
474
|
+
|
|
475
|
+
getSeriesValueOptForHeatMap(series) {
|
|
476
|
+
const data = series.data;
|
|
477
|
+
const colorOpt = series.colorOpt;
|
|
478
|
+
const colorAxis = series.colorAxis;
|
|
479
|
+
const categoryCnt = colorOpt.categoryCnt;
|
|
480
|
+
|
|
481
|
+
let maxValue = 0;
|
|
482
|
+
let isExistError = false;
|
|
483
|
+
data.forEach(({ value }) => {
|
|
484
|
+
if (maxValue < value) {
|
|
485
|
+
maxValue = value;
|
|
486
|
+
}
|
|
487
|
+
if (value < 0) {
|
|
488
|
+
isExistError = true;
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
const valueInterval = Math.ceil(maxValue / categoryCnt);
|
|
492
|
+
if (isExistError && colorAxis.length === categoryCnt) {
|
|
493
|
+
colorAxis.push({
|
|
494
|
+
id: `color#${categoryCnt}`,
|
|
495
|
+
value: colorOpt.error,
|
|
496
|
+
state: 'normal',
|
|
497
|
+
show: true,
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
return {
|
|
501
|
+
max: maxValue,
|
|
502
|
+
interval: valueInterval,
|
|
503
|
+
existError: isExistError,
|
|
504
|
+
};
|
|
505
|
+
},
|
|
506
|
+
|
|
387
507
|
/**
|
|
388
508
|
* Get graph items for each series by label index
|
|
389
509
|
* @param {number} labelIndex label index
|
|
@@ -452,8 +572,14 @@ const modules = {
|
|
|
452
572
|
|
|
453
573
|
getItem({ seriesID, dataIndex }, useApproximate = false) {
|
|
454
574
|
const dataInfo = this.getDataByValues(seriesID, dataIndex);
|
|
575
|
+
|
|
576
|
+
if (!dataInfo || !dataInfo?.xp || !dataInfo?.yp) {
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
|
|
455
580
|
return this.getItemByPosition([dataInfo.xp, dataInfo.yp], useApproximate);
|
|
456
581
|
},
|
|
582
|
+
|
|
457
583
|
/**
|
|
458
584
|
*
|
|
459
585
|
* @param seriesID
|
|
@@ -547,6 +673,42 @@ const modules = {
|
|
|
547
673
|
};
|
|
548
674
|
},
|
|
549
675
|
|
|
676
|
+
/**
|
|
677
|
+
* Find label info by position x and y
|
|
678
|
+
* @param {array} offset position x and y
|
|
679
|
+
*
|
|
680
|
+
* @returns {object} clicked label information
|
|
681
|
+
*/
|
|
682
|
+
getLabelInfoByPosition(offset) {
|
|
683
|
+
const [x, y] = offset;
|
|
684
|
+
const aPos = {
|
|
685
|
+
x1: this.chartRect.x1 + this.labelOffset.left,
|
|
686
|
+
x2: this.chartRect.x2 - this.labelOffset.right,
|
|
687
|
+
y1: this.chartRect.y1 + this.labelOffset.top,
|
|
688
|
+
y2: this.chartRect.y2 - this.labelOffset.bottom,
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
const scale = this.options.horizontal ? this.axesY[0] : this.axesX[0];
|
|
692
|
+
const startPoint = aPos[scale.units.rectStart];
|
|
693
|
+
const endPoint = aPos[scale.units.rectEnd];
|
|
694
|
+
|
|
695
|
+
let labelIndex;
|
|
696
|
+
let hitInfo;
|
|
697
|
+
if (scale.labels) {
|
|
698
|
+
const labelGap = (endPoint - startPoint) / scale.labels.length;
|
|
699
|
+
const index = Math.floor(((this.options.horizontal ? y : x) - startPoint) / labelGap);
|
|
700
|
+
labelIndex = scale.labels.length > index ? index : -1;
|
|
701
|
+
} else {
|
|
702
|
+
hitInfo = this.getItemByPosition(offset, false);
|
|
703
|
+
labelIndex = hitInfo.maxIndex;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return {
|
|
707
|
+
labelIndex,
|
|
708
|
+
hitInfo,
|
|
709
|
+
};
|
|
710
|
+
},
|
|
711
|
+
|
|
550
712
|
/**
|
|
551
713
|
* Create min/max information for all of data
|
|
552
714
|
* @property seriesList
|
|
@@ -578,7 +740,8 @@ const modules = {
|
|
|
578
740
|
|
|
579
741
|
if (smm && series.show) {
|
|
580
742
|
if (!isHorizontal) {
|
|
581
|
-
if (smm.minX
|
|
743
|
+
if (smm.minX !== null
|
|
744
|
+
&& ((minmax.x[axisX].min === null || (smm.minX < minmax.x[axisX].min)))) {
|
|
582
745
|
minmax.x[axisX].min = smm.minX;
|
|
583
746
|
}
|
|
584
747
|
if (minmax.y[axisY].min === null || (smm.minY < minmax.y[axisY].min)) {
|
|
@@ -588,7 +751,8 @@ const modules = {
|
|
|
588
751
|
if (minmax.x[axisX].min === null || (smm.minX < minmax.x[axisX].min)) {
|
|
589
752
|
minmax.x[axisX].min = smm.minX;
|
|
590
753
|
}
|
|
591
|
-
if (smm.minY
|
|
754
|
+
if (smm.minY !== null
|
|
755
|
+
&& (minmax.y[axisY].min === null || (smm.minY < minmax.y[axisY].min))) {
|
|
592
756
|
minmax.y[axisY].min = smm.minY;
|
|
593
757
|
}
|
|
594
758
|
}
|