evui 3.4.206 → 3.4.208
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 +18 -33
- package/dist/404.html +44 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.js +22645 -0
- package/dist/index.umd.cjs +28 -0
- package/dist/style.css +1 -0
- package/package.json +46 -43
- package/dist/evui.common.js +0 -63678
- package/dist/evui.common.js.map +0 -1
- package/dist/evui.umd.js +0 -63688
- package/dist/evui.umd.js.map +0 -1
- package/dist/evui.umd.min.js +0 -2
- package/dist/evui.umd.min.js.map +0 -1
- package/dist/img/EVUI.b82ee81a.svg +0 -293
- package/src/assets/logo.png +0 -0
- package/src/common/emitter.js +0 -20
- package/src/common/utils.bignumber.js +0 -67
- package/src/common/utils.debounce.js +0 -223
- package/src/common/utils.js +0 -151
- package/src/common/utils.table.js +0 -78
- package/src/common/utils.throttle.js +0 -83
- package/src/common/utils.tree.js +0 -18
- package/src/components/button/Button.vue +0 -195
- package/src/components/button/index.js +0 -7
- package/src/components/buttonGroup/ButtonGroup.vue +0 -11
- package/src/components/buttonGroup/index.js +0 -7
- package/src/components/calendar/Calendar.vue +0 -725
- package/src/components/calendar/index.js +0 -7
- package/src/components/calendar/uses.js +0 -1410
- package/src/components/chart/Chart.vue +0 -363
- package/src/components/chart/ChartToolbar.vue +0 -52
- package/src/components/chart/chart.core.js +0 -1170
- package/src/components/chart/chartZoom.core.js +0 -540
- package/src/components/chart/element/element.bar.js +0 -672
- package/src/components/chart/element/element.bar.time.js +0 -166
- package/src/components/chart/element/element.heatmap.js +0 -743
- package/src/components/chart/element/element.line.js +0 -611
- package/src/components/chart/element/element.pie.js +0 -197
- package/src/components/chart/element/element.scatter.js +0 -320
- package/src/components/chart/element/element.tip.js +0 -717
- package/src/components/chart/helpers/helpers.canvas.js +0 -265
- package/src/components/chart/helpers/helpers.constant.js +0 -235
- package/src/components/chart/helpers/helpers.util.js +0 -400
- package/src/components/chart/index.js +0 -9
- package/src/components/chart/model/index.js +0 -50
- package/src/components/chart/model/model.series.js +0 -125
- package/src/components/chart/model/model.store.js +0 -1427
- package/src/components/chart/plugins/plugins.interaction.js +0 -1655
- package/src/components/chart/plugins/plugins.legend.gradient.js +0 -606
- package/src/components/chart/plugins/plugins.legend.js +0 -1543
- package/src/components/chart/plugins/plugins.pie.js +0 -254
- package/src/components/chart/plugins/plugins.scrollbar.js +0 -732
- package/src/components/chart/plugins/plugins.title.js +0 -61
- package/src/components/chart/plugins/plugins.tooltip.js +0 -1041
- package/src/components/chart/scale/scale.js +0 -951
- package/src/components/chart/scale/scale.linear.js +0 -268
- package/src/components/chart/scale/scale.logarithmic.js +0 -135
- package/src/components/chart/scale/scale.step.js +0 -430
- package/src/components/chart/scale/scale.time.category.js +0 -338
- package/src/components/chart/scale/scale.time.js +0 -49
- package/src/components/chart/style/chart.scss +0 -405
- package/src/components/chart/uses.js +0 -721
- package/src/components/chartBrush/ChartBrush.vue +0 -323
- package/src/components/chartBrush/chartBrush.core.js +0 -691
- package/src/components/chartBrush/index.js +0 -9
- package/src/components/chartBrush/uses.js +0 -23
- package/src/components/chartGroup/ChartGroup.vue +0 -144
- package/src/components/chartGroup/index.js +0 -9
- package/src/components/chartGroup/style/chartGroup.scss +0 -5
- package/src/components/chartGroup/uses.js +0 -53
- package/src/components/checkbox/Checkbox.vue +0 -229
- package/src/components/checkbox/index.js +0 -7
- package/src/components/checkboxGroup/CheckboxGroup.vue +0 -44
- package/src/components/checkboxGroup/index.js +0 -7
- package/src/components/contextMenu/ContextMenu.vue +0 -95
- package/src/components/contextMenu/MenuList.vue +0 -182
- package/src/components/contextMenu/index.js +0 -7
- package/src/components/contextMenu/uses.js +0 -223
- package/src/components/datePicker/DatePicker.vue +0 -504
- package/src/components/datePicker/index.js +0 -7
- package/src/components/datePicker/uses.js +0 -460
- package/src/components/grid/Grid.vue +0 -1535
- package/src/components/grid/GridColumnSetting.vue +0 -358
- package/src/components/grid/GridFilterSetting.vue +0 -323
- package/src/components/grid/GridPagination.vue +0 -75
- package/src/components/grid/GridSummary.vue +0 -314
- package/src/components/grid/GridToolbar.vue +0 -35
- package/src/components/grid/icon/icon-option-button.vue +0 -17
- package/src/components/grid/icon/icon-sort-button.vue +0 -67
- package/src/components/grid/index.js +0 -11
- package/src/components/grid/style/grid.scss +0 -417
- package/src/components/grid/uses.js +0 -1629
- package/src/components/icon/Icon.vue +0 -53
- package/src/components/icon/index.js +0 -8
- package/src/components/inputNumber/InputNumber.vue +0 -212
- package/src/components/inputNumber/index.js +0 -7
- package/src/components/inputNumber/uses.js +0 -217
- package/src/components/loading/Loading.vue +0 -125
- package/src/components/loading/index.js +0 -7
- package/src/components/menu/Menu.vue +0 -79
- package/src/components/menu/MenuItem.vue +0 -201
- package/src/components/menu/index.js +0 -7
- package/src/components/message/Message.vue +0 -229
- package/src/components/message/index.js +0 -34
- package/src/components/messageBox/MessageBox.vue +0 -358
- package/src/components/messageBox/index.js +0 -22
- package/src/components/notification/Notification.vue +0 -316
- package/src/components/notification/index.js +0 -49
- package/src/components/pagination/Pagination.vue +0 -317
- package/src/components/pagination/index.js +0 -7
- package/src/components/pagination/pageButton.vue +0 -31
- package/src/components/progress/Progress.vue +0 -139
- package/src/components/progress/index.js +0 -7
- package/src/components/radio/Radio.vue +0 -159
- package/src/components/radio/index.js +0 -7
- package/src/components/radioGroup/RadioGroup.vue +0 -41
- package/src/components/radioGroup/index.js +0 -7
- package/src/components/scheduler/Scheduler.vue +0 -149
- package/src/components/scheduler/index.js +0 -7
- package/src/components/scheduler/uses.js +0 -183
- package/src/components/select/Select.vue +0 -556
- package/src/components/select/index.js +0 -7
- package/src/components/select/uses.js +0 -379
- package/src/components/slider/Slider.vue +0 -505
- package/src/components/slider/index.js +0 -7
- package/src/components/slider/uses.js +0 -391
- package/src/components/tabPanel/TabPanel.vue +0 -74
- package/src/components/tabPanel/index.js +0 -7
- package/src/components/tabs/Tabs.vue +0 -517
- package/src/components/tabs/index.js +0 -7
- package/src/components/textField/TextField.vue +0 -399
- package/src/components/textField/index.js +0 -7
- package/src/components/timePicker/TimePicker.vue +0 -364
- package/src/components/timePicker/index.js +0 -7
- package/src/components/toggle/Toggle.vue +0 -115
- package/src/components/toggle/index.js +0 -7
- package/src/components/tree/Tree.vue +0 -338
- package/src/components/tree/TreeNode.vue +0 -293
- package/src/components/tree/index.js +0 -7
- package/src/components/treeGrid/TreeGrid.vue +0 -1074
- package/src/components/treeGrid/TreeGridNode.vue +0 -349
- package/src/components/treeGrid/TreeGridToolbar.vue +0 -35
- package/src/components/treeGrid/icon/icon-tree.png +0 -0
- package/src/components/treeGrid/index.js +0 -9
- package/src/components/treeGrid/style/treeGrid.scss +0 -277
- package/src/components/treeGrid/uses.js +0 -1178
- package/src/components/window/Window.vue +0 -329
- package/src/components/window/index.js +0 -7
- package/src/components/window/uses.js +0 -908
- package/src/directives/clickoutside.js +0 -90
- package/src/main.js +0 -120
- package/src/style/components/input.scss +0 -108
- package/src/style/functions.scss +0 -3
- package/src/style/index.scss +0 -6
- package/src/style/lib/fonts/EVUI.eot +0 -0
- package/src/style/lib/fonts/EVUI.svg +0 -293
- package/src/style/lib/fonts/EVUI.ttf +0 -0
- package/src/style/lib/fonts/EVUI.woff +0 -0
- package/src/style/lib/icon.css +0 -888
- package/src/style/mixins.scss +0 -94
- package/src/style/themes.scss +0 -69
- package/src/style/variables.scss +0 -22
|
@@ -1,1427 +0,0 @@
|
|
|
1
|
-
import { reverse } from 'lodash-es';
|
|
2
|
-
import dayjs from 'dayjs';
|
|
3
|
-
import Util from '../helpers/helpers.util';
|
|
4
|
-
|
|
5
|
-
const modules = {
|
|
6
|
-
/**
|
|
7
|
-
* Take chart data and labels to create normalized data and min/max info
|
|
8
|
-
* @param {object} data chart series info
|
|
9
|
-
* @param {object} label chart label
|
|
10
|
-
*
|
|
11
|
-
* @returns {undefined}
|
|
12
|
-
*/
|
|
13
|
-
createDataSet(data, label) {
|
|
14
|
-
Object.keys(this.seriesInfo.charts).forEach((typeKey) => {
|
|
15
|
-
const seriesIDs = this.seriesInfo.charts[typeKey];
|
|
16
|
-
|
|
17
|
-
if (seriesIDs.length) {
|
|
18
|
-
if (typeKey === 'pie') {
|
|
19
|
-
if (this.options.sunburst) {
|
|
20
|
-
this.createSunburstDataSet(data);
|
|
21
|
-
} else {
|
|
22
|
-
this.createPieDataSet(data, seriesIDs);
|
|
23
|
-
}
|
|
24
|
-
} else if (typeKey === 'scatter') {
|
|
25
|
-
seriesIDs.forEach((seriesID) => {
|
|
26
|
-
const series = this.seriesList[seriesID];
|
|
27
|
-
const sData = data[seriesID];
|
|
28
|
-
const passingValue = series?.passingValue;
|
|
29
|
-
|
|
30
|
-
if (series && sData) {
|
|
31
|
-
series.data = this.addSeriesDSforScatter(sData);
|
|
32
|
-
series.minMax = this.getSeriesMinMax(series.data, passingValue);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
} else if (typeKey === 'heatMap') {
|
|
36
|
-
seriesIDs.forEach((seriesID) => {
|
|
37
|
-
const series = this.seriesList[seriesID];
|
|
38
|
-
const passingValue = series?.passingValue;
|
|
39
|
-
const sData = data[seriesID];
|
|
40
|
-
|
|
41
|
-
if (series && sData) {
|
|
42
|
-
series.labels = label;
|
|
43
|
-
series.data = this.addSeriesDSForHeatMap(sData);
|
|
44
|
-
series.minMax = this.getSeriesMinMax(series.data, passingValue);
|
|
45
|
-
series.valueOpt = this.getSeriesValueOptForHeatMap(series);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
} else {
|
|
49
|
-
seriesIDs.forEach((seriesID) => {
|
|
50
|
-
const series = this.seriesList[seriesID];
|
|
51
|
-
|
|
52
|
-
const hasPassingValueInData = data?.[seriesID]
|
|
53
|
-
?.some(item => item === series.passingValue);
|
|
54
|
-
|
|
55
|
-
series.hasPassingValueInData = hasPassingValueInData;
|
|
56
|
-
|
|
57
|
-
const sData = data?.[seriesID]?.map((item) => {
|
|
58
|
-
if (series.interpolation === 'zero' && !item) {
|
|
59
|
-
return 0;
|
|
60
|
-
}
|
|
61
|
-
if (item === series.passingValue) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return item;
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if (series && sData) {
|
|
68
|
-
if (series.isExistGrp && series.stackIndex && !series.isOverlapping) {
|
|
69
|
-
series.data = this.addSeriesStackDS(sData, label, series.bsIds, series.stackIndex);
|
|
70
|
-
} else {
|
|
71
|
-
series.data = this.addSeriesDS(sData, label, series.isExistGrp);
|
|
72
|
-
}
|
|
73
|
-
series.minMax = this.getSeriesMinMax(series.data, series.passingValue);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Take chart data and create a two-dimensional array, specify max/min and delete/add over time.
|
|
83
|
-
* @param {object} datas chart series info
|
|
84
|
-
*
|
|
85
|
-
* @returns {undefined}
|
|
86
|
-
*/
|
|
87
|
-
createRealTimeScatterDataSet(datas) {
|
|
88
|
-
const keys = Object.keys(datas);
|
|
89
|
-
|
|
90
|
-
const minMaxValues = {
|
|
91
|
-
maxY: 0,
|
|
92
|
-
minY: Infinity,
|
|
93
|
-
fromTime: 0,
|
|
94
|
-
toTime: 0,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
for (let x = 0; x < keys.length; x++) {
|
|
98
|
-
const key = keys[x];
|
|
99
|
-
const data = datas[key];
|
|
100
|
-
const storeLength = data?.length;
|
|
101
|
-
let lastTime = 0;
|
|
102
|
-
|
|
103
|
-
if (!this.isInit || this.updateSeries) {
|
|
104
|
-
const defaultValues = {
|
|
105
|
-
dataGroup: [],
|
|
106
|
-
startIndex: 0,
|
|
107
|
-
endIndex: 0,
|
|
108
|
-
length: 0,
|
|
109
|
-
fromTime: 0,
|
|
110
|
-
toTime: 0,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
this.dataSet[key] = {
|
|
114
|
-
...defaultValues,
|
|
115
|
-
...this.dataSet[key],
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
this.dataSet[key].length = this.options.realTimeScatter.range || 300;
|
|
120
|
-
|
|
121
|
-
for (let i = 0; i < storeLength; i++) {
|
|
122
|
-
const item = data[i];
|
|
123
|
-
|
|
124
|
-
if (lastTime < item.x) {
|
|
125
|
-
lastTime = item.x;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
lastTime = Math.floor(lastTime / 1000) * 1000;
|
|
130
|
-
|
|
131
|
-
const dataGroupLastTime = this.dataSet[key].dataGroup.at(-1)?.data?.at(-1)?.x || Date.now();
|
|
132
|
-
|
|
133
|
-
this.dataSet[key].toTime = lastTime
|
|
134
|
-
|| (dataGroupLastTime ? Math.floor(dataGroupLastTime / 1000) * 1000 : 0);
|
|
135
|
-
this.dataSet[key].fromTime = this.dataSet[key].toTime - this.dataSet[key].length * 1000;
|
|
136
|
-
this.dataSet[key].endIndex = this.dataSet[key].length - 1;
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
(this.dataSet[key].toTime - lastTime) / 1000
|
|
140
|
-
> this.dataSet[key].length && key === ''
|
|
141
|
-
) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
let gapCount = (lastTime - this.dataSet[key].toTime) / 1000;
|
|
146
|
-
if (gapCount > 0) {
|
|
147
|
-
this.dataSet[key].toTime = lastTime;
|
|
148
|
-
this.dataSet[key].fromTime = lastTime
|
|
149
|
-
- this.dataSet[key].length * 1000;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
for (let i = 0; i < this.dataSet[key].length; i++) {
|
|
153
|
-
const defaultValues = {
|
|
154
|
-
data: [],
|
|
155
|
-
max: 0,
|
|
156
|
-
min: Infinity,
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
this.dataSet[key].dataGroup[i] = {
|
|
160
|
-
...defaultValues,
|
|
161
|
-
...this.dataSet[key].dataGroup[i],
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
if (gapCount > 0) {
|
|
165
|
-
if (gapCount >= this.dataSet[key].length) {
|
|
166
|
-
for (let i = 0; i < this.dataSet[key].length; i++) {
|
|
167
|
-
this.dataSet[key].dataGroup[i].data.length = 0;
|
|
168
|
-
this.dataSet[key].dataGroup[i].max = 0;
|
|
169
|
-
this.dataSet[key].dataGroup[i].min = Infinity;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
this.dataSet[key].startIndex = 0;
|
|
173
|
-
this.dataSet[key].endIndex = this.dataSet[key].length - 1;
|
|
174
|
-
} else {
|
|
175
|
-
while (gapCount > 0) {
|
|
176
|
-
if (
|
|
177
|
-
this.dataSet[key].dataGroup[this.dataSet[key].startIndex]
|
|
178
|
-
=== null
|
|
179
|
-
) {
|
|
180
|
-
this.dataSet[key].dataGroup[this.dataSet[key].startIndex] = {
|
|
181
|
-
data: [],
|
|
182
|
-
max: 0,
|
|
183
|
-
min: Infinity,
|
|
184
|
-
};
|
|
185
|
-
} else {
|
|
186
|
-
this.dataSet[key]
|
|
187
|
-
.dataGroup[this.dataSet[key].startIndex].data.length = 0;
|
|
188
|
-
this.dataSet[key]
|
|
189
|
-
.dataGroup[this.dataSet[key].startIndex].max = 0;
|
|
190
|
-
this.dataSet[key]
|
|
191
|
-
.dataGroup[this.dataSet[key].startIndex].min = Infinity;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
++this.dataSet[key].startIndex;
|
|
195
|
-
|
|
196
|
-
if (this.dataSet[key].startIndex >= this.dataSet[key].length) {
|
|
197
|
-
this.dataSet[key].startIndex = 0;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
++this.dataSet[key].endIndex;
|
|
201
|
-
if (this.dataSet[key].endIndex >= this.dataSet[key].length) {
|
|
202
|
-
this.dataSet[key].endIndex = 0;
|
|
203
|
-
}
|
|
204
|
-
--gapCount;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
for (let i = 0; i < storeLength; i++) {
|
|
210
|
-
const item = data[i];
|
|
211
|
-
const xAxisTime = Math.floor(item.x / 1000) * 1000;
|
|
212
|
-
|
|
213
|
-
if (this.dataSet[key].fromTime <= xAxisTime) {
|
|
214
|
-
let index = this.dataSet[key].endIndex
|
|
215
|
-
- (this.dataSet[key].toTime - xAxisTime) / 1000;
|
|
216
|
-
if (index < 0) {
|
|
217
|
-
index = this.dataSet[key].length + index;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
this.dataSet[key].dataGroup[index].data.push({
|
|
221
|
-
x: item.x,
|
|
222
|
-
y: item.y,
|
|
223
|
-
color: item.color,
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
this.dataSet[key].dataGroup[index].max = Math.max(
|
|
227
|
-
this.dataSet[key].dataGroup[index].max,
|
|
228
|
-
item.y,
|
|
229
|
-
);
|
|
230
|
-
this.dataSet[key].dataGroup[index].min = Math.min(
|
|
231
|
-
this.dataSet[key].dataGroup[index].min,
|
|
232
|
-
item.y,
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const tempMinMax = {
|
|
238
|
-
maxY: 0,
|
|
239
|
-
minY: Infinity,
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
for (let i = 0; i < this.dataSet[key].length; i++) {
|
|
243
|
-
if (this.dataSet[key].dataGroup[i].max > tempMinMax.maxY) {
|
|
244
|
-
tempMinMax.maxY = this.dataSet[key].dataGroup[i].max;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (this.dataSet[key].dataGroup[i].min < tempMinMax.minY) {
|
|
248
|
-
tempMinMax.minY = this.dataSet[key].dataGroup[i].min;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
minMaxValues.maxY = Math.max(minMaxValues.maxY, tempMinMax.maxY);
|
|
253
|
-
minMaxValues.minY = Math.min(minMaxValues.minY, tempMinMax.minY);
|
|
254
|
-
minMaxValues.fromTime = this.dataSet[key].fromTime;
|
|
255
|
-
minMaxValues.toTime = this.dataSet[key].toTime;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
this.seriesInfo.charts.scatter.forEach((seriesID) => {
|
|
259
|
-
const series = this.seriesList[seriesID];
|
|
260
|
-
series.data = this.dataSet;
|
|
261
|
-
series.minMax = {
|
|
262
|
-
minX: dayjs(minMaxValues.fromTime),
|
|
263
|
-
minY: minMaxValues.minY,
|
|
264
|
-
maxX: dayjs(minMaxValues.toTime),
|
|
265
|
-
maxY: minMaxValues.maxY,
|
|
266
|
-
};
|
|
267
|
-
});
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Take chart data and to create normalized pie data
|
|
272
|
-
* @param {object} data chart series info
|
|
273
|
-
*
|
|
274
|
-
* @returns {undefined}
|
|
275
|
-
*/
|
|
276
|
-
createSunburstDataSet(data) {
|
|
277
|
-
this.pieDataSet = [];
|
|
278
|
-
const ds = this.pieDataSet;
|
|
279
|
-
const sunburstQueue = [];
|
|
280
|
-
|
|
281
|
-
for (let ix = 0; ix < data.length; ix++) {
|
|
282
|
-
const slice = data[ix];
|
|
283
|
-
const series = this.seriesList[slice.id];
|
|
284
|
-
let showChildren = false;
|
|
285
|
-
|
|
286
|
-
if (!ds[0]) {
|
|
287
|
-
ds[0] = { ir: 0, or: 0, total: 0, data: [] };
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (series.show) {
|
|
291
|
-
ds[0].total += slice.value || 0;
|
|
292
|
-
ds[0].data.push({ parent: '$ev-root', id: slice.id, value: slice.value, sa: 0, ea: 0 });
|
|
293
|
-
|
|
294
|
-
if (slice.children) {
|
|
295
|
-
for (let jx = 0; jx < slice.children.length; jx++) {
|
|
296
|
-
const childSeries = this.seriesList[slice.children[jx].id];
|
|
297
|
-
if (childSeries.show) {
|
|
298
|
-
showChildren = true;
|
|
299
|
-
}
|
|
300
|
-
sunburstQueue.push({ parent: slice.id, data: slice.children[jx], depth: 1 });
|
|
301
|
-
}
|
|
302
|
-
} else {
|
|
303
|
-
const dummy = {
|
|
304
|
-
id: 'dummy',
|
|
305
|
-
value: slice.value,
|
|
306
|
-
};
|
|
307
|
-
sunburstQueue.push({ parent: slice.id, data: dummy, depth: 1 });
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (!showChildren) {
|
|
311
|
-
const dummy = {
|
|
312
|
-
id: 'dummy',
|
|
313
|
-
value: slice.value,
|
|
314
|
-
};
|
|
315
|
-
sunburstQueue.push({ parent: slice.id, data: dummy, depth: 1 });
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
ds[0].data.sort((a, b) => b.value - a.value);
|
|
321
|
-
|
|
322
|
-
while (sunburstQueue.length) {
|
|
323
|
-
const item = sunburstQueue.shift();
|
|
324
|
-
const parent = item.parent;
|
|
325
|
-
const slice = item.data;
|
|
326
|
-
const depth = item.depth;
|
|
327
|
-
let showChildren = false;
|
|
328
|
-
|
|
329
|
-
if (!ds[depth]) {
|
|
330
|
-
ds[depth] = { ir: 0, or: 0, total: {}, data: [] };
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (!ds[depth].total[parent]) {
|
|
334
|
-
ds[depth].total[parent] = 0;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
const series = this.seriesList[slice.id];
|
|
338
|
-
if (slice.id === 'dummy') {
|
|
339
|
-
ds[depth].data.push({ parent, id: 'dummy', value: slice.value, sa: 0, ea: 0 });
|
|
340
|
-
ds[depth].total[parent] += slice.value;
|
|
341
|
-
} else if (series && series.show) {
|
|
342
|
-
ds[depth].data.push({ parent, id: slice.id, value: slice.value, sa: 0, ea: 0 });
|
|
343
|
-
ds[depth].total[parent] += slice.value;
|
|
344
|
-
|
|
345
|
-
if (slice.children) {
|
|
346
|
-
for (let ix = 0; ix < slice.children.length; ix++) {
|
|
347
|
-
if (this.seriesList[slice.children[ix].id].show) {
|
|
348
|
-
showChildren = true;
|
|
349
|
-
}
|
|
350
|
-
sunburstQueue.push({ parent: slice.id, data: slice.children[ix], depth: depth + 1 });
|
|
351
|
-
}
|
|
352
|
-
} else {
|
|
353
|
-
const dummy = {
|
|
354
|
-
id: 'dummy',
|
|
355
|
-
value: slice.value,
|
|
356
|
-
};
|
|
357
|
-
sunburstQueue.push({ parent: slice.id, data: dummy, depth: depth + 1 });
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
if (!showChildren) {
|
|
361
|
-
const dummy = {
|
|
362
|
-
id: 'dummy',
|
|
363
|
-
value: slice.value,
|
|
364
|
-
};
|
|
365
|
-
sunburstQueue.push({ parent: slice.id, data: dummy, depth: depth + 1 });
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
ds[depth].data.sort((a, b) => b.value - a.value);
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Take chart data and to create normalized pie data
|
|
375
|
-
* @param {object} data chart data
|
|
376
|
-
* @param {String[]} seriesIDs chart series info
|
|
377
|
-
*
|
|
378
|
-
* @returns {undefined}
|
|
379
|
-
*/
|
|
380
|
-
createPieDataSet(data, seriesIDs) {
|
|
381
|
-
this.pieDataSet = [];
|
|
382
|
-
const ds = this.pieDataSet;
|
|
383
|
-
ds[0] = { data: [], ir: 0, or: 0, total: 0 };
|
|
384
|
-
|
|
385
|
-
seriesIDs.forEach((sId) => {
|
|
386
|
-
if (this.seriesList[sId].show) {
|
|
387
|
-
const value = data[sId][0] ?? 0;
|
|
388
|
-
ds[0].total += value;
|
|
389
|
-
ds[0].data.push({ id: sId, value, sa: 0, ea: 0 });
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
ds.forEach((item) => {
|
|
394
|
-
item.data.sort((a, b) => b.value - a.value);
|
|
395
|
-
});
|
|
396
|
-
},
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Take data and label to create stack data for each series
|
|
400
|
-
* @param {object} data chart series info
|
|
401
|
-
* @param {object} label chart label
|
|
402
|
-
* @param {array} bsIds stacked base data ID List
|
|
403
|
-
* @param {number} sIdx series ordered index
|
|
404
|
-
*
|
|
405
|
-
* @typedef {import('./index').ChartSeriesDataPoint} ChartSeriesDataPoint
|
|
406
|
-
*
|
|
407
|
-
* @returns {ChartSeriesDataPoint[]} data for each series
|
|
408
|
-
*/
|
|
409
|
-
addSeriesStackDS(data, label, bsIds, sIdx = 0) {
|
|
410
|
-
const isHorizontal = this.options.horizontal;
|
|
411
|
-
const sdata = [];
|
|
412
|
-
|
|
413
|
-
const getBaseDataPosition = (baseIndex, dataIndex, curr) => {
|
|
414
|
-
const nextBaseSeriesIndex = baseIndex - 1;
|
|
415
|
-
const baseSeries = this.seriesList[bsIds[baseIndex]];
|
|
416
|
-
const baseDataList = baseSeries.data;
|
|
417
|
-
const baseData = baseDataList[dataIndex];
|
|
418
|
-
const position = isHorizontal ? baseData?.x : baseData?.y;
|
|
419
|
-
|
|
420
|
-
const baseValue = baseData?.o;
|
|
421
|
-
const isPassingValue = !Util.isNullOrUndefined(baseSeries?.passingValue)
|
|
422
|
-
&& baseSeries?.passingValue === baseValue;
|
|
423
|
-
const isSameSign = (curr >= 0 && baseValue >= 0) || (curr < 0 && baseValue < 0);
|
|
424
|
-
|
|
425
|
-
if (isPassingValue || position == null || !isSameSign || !baseSeries.show) {
|
|
426
|
-
if (nextBaseSeriesIndex > -1) {
|
|
427
|
-
return getBaseDataPosition(nextBaseSeriesIndex, dataIndex, curr);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
return 0;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
return position;
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
data.forEach((curr, index) => {
|
|
437
|
-
const baseIndex = bsIds.length - 1 < 0 ? 0 : bsIds.length - 1;
|
|
438
|
-
let bdata = getBaseDataPosition(baseIndex, index, curr); // base(previous) series data
|
|
439
|
-
let odata = curr; // current series original data
|
|
440
|
-
let ldata = label[index]; // label data
|
|
441
|
-
let gdata = curr; // current series data which added previous series's value
|
|
442
|
-
|
|
443
|
-
if (bdata != null && ldata != null) {
|
|
444
|
-
if (gdata && typeof gdata === 'object' && (curr.x || curr.y)) {
|
|
445
|
-
odata = isHorizontal ? curr.x : curr.y;
|
|
446
|
-
ldata = isHorizontal ? curr.y : curr.x;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
const oData = odata?.value ?? odata;
|
|
450
|
-
if (sIdx > 0) {
|
|
451
|
-
if (oData != null) {
|
|
452
|
-
gdata = bdata + oData;
|
|
453
|
-
} else {
|
|
454
|
-
gdata = odata;
|
|
455
|
-
}
|
|
456
|
-
} else {
|
|
457
|
-
bdata = 0;
|
|
458
|
-
gdata = oData;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
sdata.push(this.addData(gdata, ldata, odata, bdata));
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
return sdata;
|
|
466
|
-
},
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Take data and label to create data for each series
|
|
470
|
-
* @param {object} data chart series info
|
|
471
|
-
* @param {object} label chart label
|
|
472
|
-
* @param {boolean} isBase is Base(bottommost) series at stack chart
|
|
473
|
-
*
|
|
474
|
-
* @typedef {import('./index').ChartSeriesDataPoint} ChartSeriesDataPoint
|
|
475
|
-
*
|
|
476
|
-
* @returns {ChartSeriesDataPoint[]} data for each series
|
|
477
|
-
*/
|
|
478
|
-
addSeriesDS(data, label, isBase) {
|
|
479
|
-
const isHorizontal = this.options.horizontal;
|
|
480
|
-
const sdata = [];
|
|
481
|
-
const passingValue = this.seriesList[Object.keys(this.seriesList)[0]]?.passingValue;
|
|
482
|
-
|
|
483
|
-
data.forEach((curr, index) => {
|
|
484
|
-
let gdata = curr;
|
|
485
|
-
let ldata = label[index];
|
|
486
|
-
|
|
487
|
-
if (gdata && typeof gdata === 'object' && (curr.x || curr.y)) {
|
|
488
|
-
gdata = isHorizontal ? curr.x : curr.y;
|
|
489
|
-
ldata = isHorizontal ? curr.y : curr.x;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
if (ldata !== null) {
|
|
493
|
-
const isPassingValueWithStack = isBase
|
|
494
|
-
&& !Util.isNullOrUndefined(passingValue)
|
|
495
|
-
&& gdata === passingValue;
|
|
496
|
-
sdata.push(this.addData(isPassingValueWithStack ? 0 : gdata, ldata, gdata,
|
|
497
|
-
));
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
return sdata;
|
|
502
|
-
},
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Take data to create data for each series
|
|
506
|
-
* @param {array} data data array for each series
|
|
507
|
-
* @returns {array} data info added position and etc
|
|
508
|
-
*/
|
|
509
|
-
addSeriesDSforScatter(data) {
|
|
510
|
-
return data.map((item) => {
|
|
511
|
-
const ldata = item.x;
|
|
512
|
-
const gdata = {
|
|
513
|
-
value: item.y,
|
|
514
|
-
color: item?.color || null,
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
return this.addData(gdata, ldata, gdata);
|
|
518
|
-
});
|
|
519
|
-
},
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Take data to create data for each series
|
|
523
|
-
* @param {array} data data array for each series
|
|
524
|
-
*
|
|
525
|
-
* @returns {array} data info added position and etc
|
|
526
|
-
*/
|
|
527
|
-
addSeriesDSForHeatMap(data) {
|
|
528
|
-
return data.map(({ x, y, value, color = null }) => ({
|
|
529
|
-
x,
|
|
530
|
-
y,
|
|
531
|
-
o: value,
|
|
532
|
-
xp: null,
|
|
533
|
-
yp: null,
|
|
534
|
-
w: null,
|
|
535
|
-
h: null,
|
|
536
|
-
dataColor: color,
|
|
537
|
-
cId: null,
|
|
538
|
-
}));
|
|
539
|
-
},
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Take data to create data object for graph
|
|
543
|
-
* @param {object} gdata graph data (y-axis value for vertical chart)
|
|
544
|
-
* @param {object} ldata label data (x-axis value for vertical chart)
|
|
545
|
-
* @param {object} odata original data (without stacked value)
|
|
546
|
-
* @param {object} bdata base data (stacked value)
|
|
547
|
-
*
|
|
548
|
-
* @typedef {import('./index').ChartSeriesDataPoint} ChartSeriesDataPoint
|
|
549
|
-
*
|
|
550
|
-
* @returns {ChartSeriesDataPoint} data for each graph point
|
|
551
|
-
*/
|
|
552
|
-
addData(gdata, ldata, odata = null, bdata = null) {
|
|
553
|
-
let data;
|
|
554
|
-
let gdataValue = null;
|
|
555
|
-
let odataValue = null;
|
|
556
|
-
let gdataColor = null;
|
|
557
|
-
let odataColor = null;
|
|
558
|
-
let dataTextColor = null;
|
|
559
|
-
|
|
560
|
-
if (gdata !== null && typeof gdata === 'object') {
|
|
561
|
-
gdataValue = gdata.value;
|
|
562
|
-
gdataColor = gdata.color;
|
|
563
|
-
dataTextColor = gdata.textColor;
|
|
564
|
-
} else {
|
|
565
|
-
gdataValue = gdata ?? null;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
if (odata !== null && typeof odata === 'object') {
|
|
569
|
-
odataValue = odata.value;
|
|
570
|
-
odataColor = odata.color;
|
|
571
|
-
} else {
|
|
572
|
-
odataValue = odata ?? null;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
if (this.options.horizontal) {
|
|
576
|
-
data = { x: gdataValue, y: ldata, o: odataValue, b: bdata };
|
|
577
|
-
} else {
|
|
578
|
-
data = { x: ldata, y: gdataValue, o: odataValue, b: bdata };
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
data.xp = null;
|
|
582
|
-
data.yp = null;
|
|
583
|
-
data.w = null;
|
|
584
|
-
data.h = null;
|
|
585
|
-
data.dataColor = gdataColor ?? odataColor;
|
|
586
|
-
data.dataTextColor = dataTextColor;
|
|
587
|
-
|
|
588
|
-
return data;
|
|
589
|
-
},
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Take series data to create min/max info for each series
|
|
593
|
-
* @param {object} data series data
|
|
594
|
-
*
|
|
595
|
-
* @returns {object} min/max info for series
|
|
596
|
-
*/
|
|
597
|
-
getSeriesMinMax(data, passingValue) {
|
|
598
|
-
const def = { minX: null, minY: null, maxX: null, maxY: null, maxDomain: null };
|
|
599
|
-
const isHorizontal = this.options.horizontal;
|
|
600
|
-
|
|
601
|
-
if (data.length) {
|
|
602
|
-
const usePassingValue = !Util.isNullOrUndefined(passingValue);
|
|
603
|
-
|
|
604
|
-
return data.reduce((acc, p, index) => {
|
|
605
|
-
const minmax = acc;
|
|
606
|
-
const px = p.x?.value || p.x;
|
|
607
|
-
const py = p.y?.value || p.y;
|
|
608
|
-
const po = p.o?.value || p.o;
|
|
609
|
-
|
|
610
|
-
if ((usePassingValue ? (po !== passingValue && px <= minmax.minX) : px <= minmax.minX)) {
|
|
611
|
-
minmax.minX = (px === null) ? 0 : px;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
if ((usePassingValue ? (po !== passingValue && py <= minmax.minY) : py <= minmax.minY)) {
|
|
615
|
-
minmax.minY = (py === null) ? 0 : py;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
if ((usePassingValue ? (po !== passingValue && px >= minmax.maxX) : px >= minmax.maxX)) {
|
|
619
|
-
minmax.maxX = (px === null) ? 0 : px;
|
|
620
|
-
|
|
621
|
-
if (isHorizontal && px !== null) {
|
|
622
|
-
minmax.maxDomain = py;
|
|
623
|
-
minmax.maxDomainIndex = index;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
if ((usePassingValue ? (po !== passingValue && py >= minmax.maxY) : py >= minmax.maxY)) {
|
|
628
|
-
minmax.maxY = (py === null) ? 0 : py;
|
|
629
|
-
|
|
630
|
-
if (!isHorizontal && py !== null) {
|
|
631
|
-
minmax.maxDomain = px;
|
|
632
|
-
minmax.maxDomainIndex = index;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
return minmax;
|
|
637
|
-
}, {
|
|
638
|
-
minX: data[0].x,
|
|
639
|
-
minY: data[0].y,
|
|
640
|
-
maxX: data[0].x,
|
|
641
|
-
maxY: data[0].y,
|
|
642
|
-
maxDomain: isHorizontal ? data[0].y : data[0].x,
|
|
643
|
-
maxDomainIndex: 0,
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
return def;
|
|
648
|
-
},
|
|
649
|
-
|
|
650
|
-
getSeriesValueOptForHeatMap(series) {
|
|
651
|
-
const { data, colorState, isGradient } = series;
|
|
652
|
-
const colorOpt = this.options.heatMapColor;
|
|
653
|
-
const rangeCount = colorOpt.colorsByRange.length || colorOpt.rangeCount;
|
|
654
|
-
const decimalPoint = colorOpt.decimalPoint;
|
|
655
|
-
|
|
656
|
-
let minValue;
|
|
657
|
-
let maxValue = 0;
|
|
658
|
-
|
|
659
|
-
let isExistError = false;
|
|
660
|
-
data.forEach(({ o: value }) => {
|
|
661
|
-
if (maxValue < value) {
|
|
662
|
-
maxValue = Math.max(maxValue, value);
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
if (value < 0) {
|
|
666
|
-
isExistError = true;
|
|
667
|
-
} else if (minValue === undefined) {
|
|
668
|
-
minValue = value;
|
|
669
|
-
} else {
|
|
670
|
-
minValue = Math.min(minValue, value);
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
|
|
674
|
-
if (
|
|
675
|
-
isExistError
|
|
676
|
-
&& !isGradient
|
|
677
|
-
&& colorState.length === rangeCount
|
|
678
|
-
) {
|
|
679
|
-
colorState.push({
|
|
680
|
-
id: `color#${rangeCount}`,
|
|
681
|
-
color: colorOpt.error,
|
|
682
|
-
state: 'normal',
|
|
683
|
-
label: 'Error',
|
|
684
|
-
show: true,
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
let interval = maxValue > minValue ? Math.floor((maxValue - minValue) / rangeCount) : 1;
|
|
689
|
-
if ((maxValue - minValue) <= rangeCount) {
|
|
690
|
-
if (decimalPoint > 0) {
|
|
691
|
-
interval = +((maxValue - minValue) / rangeCount).toFixed(decimalPoint);
|
|
692
|
-
} else {
|
|
693
|
-
interval = 1;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
return {
|
|
698
|
-
min: minValue,
|
|
699
|
-
max: maxValue,
|
|
700
|
-
interval,
|
|
701
|
-
existError: isExistError,
|
|
702
|
-
decimalPoint,
|
|
703
|
-
};
|
|
704
|
-
},
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* Get graph items for each series by label index
|
|
708
|
-
* @param {number} labelIndex label index
|
|
709
|
-
*
|
|
710
|
-
* @returns {object} graph item
|
|
711
|
-
*/
|
|
712
|
-
getItemByLabelIndex(labelIndex) {
|
|
713
|
-
if (labelIndex < 0) {
|
|
714
|
-
return false;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
const sIds = Object.keys(this.seriesList);
|
|
718
|
-
const isHorizontal = !!this.options.horizontal;
|
|
719
|
-
|
|
720
|
-
let maxl = null;
|
|
721
|
-
let maxp = null;
|
|
722
|
-
let maxg = null;
|
|
723
|
-
let maxSID = '';
|
|
724
|
-
let acc = 0;
|
|
725
|
-
let useStack = false;
|
|
726
|
-
let findInfo = false;
|
|
727
|
-
|
|
728
|
-
if (labelIndex > -1) {
|
|
729
|
-
for (let ix = 0; ix < sIds.length; ix++) {
|
|
730
|
-
const sId = sIds[ix];
|
|
731
|
-
const series = this.seriesList[sId];
|
|
732
|
-
const data = series.data[labelIndex];
|
|
733
|
-
|
|
734
|
-
if (data && series.show && series.showLegend) {
|
|
735
|
-
const ldata = isHorizontal ? data.y : data.x;
|
|
736
|
-
const lp = isHorizontal ? data.yp : data.xp;
|
|
737
|
-
|
|
738
|
-
if (ldata !== null && ldata !== undefined) {
|
|
739
|
-
const g = isHorizontal ? data.o || data.x : data.o || data.y;
|
|
740
|
-
|
|
741
|
-
if (series.stackIndex) {
|
|
742
|
-
acc += !isNaN(data.o) ? data.o : 0;
|
|
743
|
-
useStack = true;
|
|
744
|
-
} else {
|
|
745
|
-
acc += data.y;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
if (maxg === null || maxg <= g) {
|
|
749
|
-
maxg = g;
|
|
750
|
-
maxSID = sId;
|
|
751
|
-
maxl = ldata;
|
|
752
|
-
maxp = lp;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
findInfo = {
|
|
759
|
-
label: maxl,
|
|
760
|
-
pos: maxp,
|
|
761
|
-
value: maxg === null ? 0 : maxg,
|
|
762
|
-
sId: maxSID,
|
|
763
|
-
acc,
|
|
764
|
-
useStack,
|
|
765
|
-
maxIndex: labelIndex,
|
|
766
|
-
};
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
return findInfo;
|
|
770
|
-
},
|
|
771
|
-
|
|
772
|
-
getItem(selectedInfo, useApproximate = false) {
|
|
773
|
-
const { seriesID, dataIndex } = selectedInfo;
|
|
774
|
-
|
|
775
|
-
let itemPosition;
|
|
776
|
-
if ('seriesID' in selectedInfo) {
|
|
777
|
-
const dataInfo = this.getDataByValues(seriesID, dataIndex);
|
|
778
|
-
|
|
779
|
-
if (!dataInfo || !dataInfo?.xp || !dataInfo?.yp) {
|
|
780
|
-
return null;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
itemPosition = [this.getItemByPosition(
|
|
784
|
-
[dataInfo.xp, dataInfo.yp],
|
|
785
|
-
useApproximate,
|
|
786
|
-
dataIndex,
|
|
787
|
-
true,
|
|
788
|
-
)];
|
|
789
|
-
} else {
|
|
790
|
-
const seriesList = Object.entries(this.seriesList);
|
|
791
|
-
let firShowSeriesID;
|
|
792
|
-
|
|
793
|
-
for (let i = 0; i < seriesList.length; i++) {
|
|
794
|
-
const [id, info] = seriesList[i];
|
|
795
|
-
|
|
796
|
-
if (info.show) {
|
|
797
|
-
firShowSeriesID = id;
|
|
798
|
-
break;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
itemPosition = dataIndex?.map((idx) => {
|
|
803
|
-
const dataInfo = this.getDataByValues(firShowSeriesID, idx);
|
|
804
|
-
|
|
805
|
-
if (!dataInfo) {
|
|
806
|
-
return null;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
return this.getItemByPosition(
|
|
810
|
-
[dataInfo?.xp ?? 0, dataInfo?.yp ?? 0],
|
|
811
|
-
useApproximate,
|
|
812
|
-
idx,
|
|
813
|
-
true,
|
|
814
|
-
);
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
return itemPosition;
|
|
819
|
-
},
|
|
820
|
-
|
|
821
|
-
/**
|
|
822
|
-
*
|
|
823
|
-
* @param seriesID
|
|
824
|
-
* @param dataIndex
|
|
825
|
-
* @returns {*}
|
|
826
|
-
*/
|
|
827
|
-
getDataByValues(seriesID, dataIndex) {
|
|
828
|
-
const series = this.seriesList[seriesID];
|
|
829
|
-
if (!series || isNaN(dataIndex) || dataIndex < 0 || series?.data.length <= dataIndex) {
|
|
830
|
-
return false;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
return series.data[dataIndex];
|
|
834
|
-
},
|
|
835
|
-
|
|
836
|
-
/**
|
|
837
|
-
* Find graph item by position x and y
|
|
838
|
-
* @param {array} offset position x and y
|
|
839
|
-
* @param {boolean} useApproximate if it's true. it'll look for closed item on mouse position
|
|
840
|
-
* @param {number} dataIndex selected data index
|
|
841
|
-
* @param {boolean} useSelectLabelOrItem used to display select label/item at tooltip location
|
|
842
|
-
*
|
|
843
|
-
* @returns {object} clicked item information
|
|
844
|
-
*/
|
|
845
|
-
getItemByPosition(
|
|
846
|
-
offset,
|
|
847
|
-
useApproximate = false,
|
|
848
|
-
dataIndex,
|
|
849
|
-
useSelectLabelOrItem = false,
|
|
850
|
-
) {
|
|
851
|
-
const seriesIDs = Object.keys(this.seriesList);
|
|
852
|
-
const isHorizontal = !!this.options.horizontal;
|
|
853
|
-
|
|
854
|
-
let maxType = null;
|
|
855
|
-
let maxLabel = null;
|
|
856
|
-
let maxValuePos = null;
|
|
857
|
-
let maxValue = null;
|
|
858
|
-
let maxSeriesID = '';
|
|
859
|
-
let acc = 0;
|
|
860
|
-
let useStack = false;
|
|
861
|
-
let maxIndex = null;
|
|
862
|
-
|
|
863
|
-
for (let ix = 0; ix < seriesIDs.length; ix++) {
|
|
864
|
-
const seriesID = seriesIDs[ix];
|
|
865
|
-
const series = this.seriesList[seriesID];
|
|
866
|
-
const findFn = useApproximate ? series.findApproximateData : series.findGraphData;
|
|
867
|
-
|
|
868
|
-
if (findFn) {
|
|
869
|
-
const item = findFn.call(
|
|
870
|
-
series,
|
|
871
|
-
offset,
|
|
872
|
-
isHorizontal,
|
|
873
|
-
dataIndex,
|
|
874
|
-
useSelectLabelOrItem,
|
|
875
|
-
);
|
|
876
|
-
const data = item.data;
|
|
877
|
-
const index = item.index;
|
|
878
|
-
|
|
879
|
-
if (data) {
|
|
880
|
-
if (Util.isPieType(item.type)) {
|
|
881
|
-
maxLabel = seriesID;
|
|
882
|
-
maxSeriesID = seriesID;
|
|
883
|
-
maxValuePos = (data.ea - data.sa) / 2;
|
|
884
|
-
maxValue = data.o;
|
|
885
|
-
maxIndex = data.index;
|
|
886
|
-
maxType = item.type;
|
|
887
|
-
} else {
|
|
888
|
-
const ldata = isHorizontal ? data.y : data.x;
|
|
889
|
-
const lp = isHorizontal ? data.yp : data.xp;
|
|
890
|
-
|
|
891
|
-
if (ldata !== null && ldata !== undefined) {
|
|
892
|
-
const g = isHorizontal ? data.o || data.x : data.o || data.y;
|
|
893
|
-
|
|
894
|
-
if (series.stackIndex != null) {
|
|
895
|
-
acc += !isNaN(data.o) ? data.o : 0;
|
|
896
|
-
useStack = true;
|
|
897
|
-
} else {
|
|
898
|
-
acc += data.y;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
if (maxType === 'bar' && useStack) {
|
|
903
|
-
if (item.hit) {
|
|
904
|
-
maxValue = g;
|
|
905
|
-
maxSeriesID = seriesID;
|
|
906
|
-
maxIndex = index;
|
|
907
|
-
maxLabel = ldata;
|
|
908
|
-
maxValuePos = lp;
|
|
909
|
-
maxType = series.type;
|
|
910
|
-
}
|
|
911
|
-
} else if (maxValue === null || maxValue <= g) {
|
|
912
|
-
maxValue = g;
|
|
913
|
-
maxSeriesID = seriesID;
|
|
914
|
-
maxLabel = ldata;
|
|
915
|
-
maxValuePos = lp;
|
|
916
|
-
maxIndex = index;
|
|
917
|
-
maxType = series.type;
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
return {
|
|
926
|
-
type: maxType,
|
|
927
|
-
label: maxLabel,
|
|
928
|
-
pos: maxValuePos,
|
|
929
|
-
value: maxValue ?? 0,
|
|
930
|
-
sId: maxSeriesID,
|
|
931
|
-
acc,
|
|
932
|
-
useStack,
|
|
933
|
-
maxIndex,
|
|
934
|
-
};
|
|
935
|
-
},
|
|
936
|
-
|
|
937
|
-
/**
|
|
938
|
-
* Find seriesId by position x and y
|
|
939
|
-
* @param {array} offset position x and y
|
|
940
|
-
*
|
|
941
|
-
* @returns {object} clicked series id
|
|
942
|
-
*/
|
|
943
|
-
getSeriesInfoByPosition(offset) {
|
|
944
|
-
const [clickedX, clickedY] = offset;
|
|
945
|
-
const chartRect = this.chartRect;
|
|
946
|
-
const labelOffset = this.labelOffset;
|
|
947
|
-
const aPos = {
|
|
948
|
-
x1: chartRect.x1 + labelOffset.left,
|
|
949
|
-
x2: chartRect.x2 - labelOffset.right,
|
|
950
|
-
y1: chartRect.y1 + labelOffset.top,
|
|
951
|
-
y2: chartRect.y2 - labelOffset.bottom,
|
|
952
|
-
};
|
|
953
|
-
const valueAxes = this.axesY[0];
|
|
954
|
-
const labelAxes = this.axesX[0];
|
|
955
|
-
const valueStartPoint = aPos[valueAxes.units.rectStart];
|
|
956
|
-
const valueEndPoint = aPos[valueAxes.units.rectEnd];
|
|
957
|
-
const labelStartPoint = aPos[labelAxes.units.rectStart];
|
|
958
|
-
const labelEndPoint = aPos[labelAxes.units.rectEnd];
|
|
959
|
-
|
|
960
|
-
const result = { sId: null };
|
|
961
|
-
|
|
962
|
-
if (clickedY > valueEndPoint && clickedY < valueStartPoint
|
|
963
|
-
&& clickedX < labelEndPoint && clickedX > labelStartPoint) {
|
|
964
|
-
let hitSeries;
|
|
965
|
-
let positionList;
|
|
966
|
-
const hitItem = this.findHitItem(offset);
|
|
967
|
-
const hitSeriesList = Object.keys(hitItem.items);
|
|
968
|
-
|
|
969
|
-
switch (this.options.type) {
|
|
970
|
-
case 'line': {
|
|
971
|
-
const orderedSeriesList = this.seriesInfo.charts.line;
|
|
972
|
-
const isStackChart = Object.values(this.seriesList).some(({ stackIndex }) => stackIndex);
|
|
973
|
-
|
|
974
|
-
if (hitSeriesList.length) { // 클릭한 위치에 data 가 존재하는 경우
|
|
975
|
-
if (isStackChart) {
|
|
976
|
-
positionList = orderedSeriesList.filter(sId => hitSeriesList.includes(sId))
|
|
977
|
-
.map(sId => ({ sId, position: hitItem.items[sId]?.data?.yp }));
|
|
978
|
-
hitSeries = positionList.find(({ position }) => clickedY > position)?.sId;
|
|
979
|
-
} else {
|
|
980
|
-
hitSeries = Object.entries(hitItem.items).find(([, { hit }]) => hit)?.[0];
|
|
981
|
-
}
|
|
982
|
-
} else { // 클릭한 위치에 data 가 존재하지 않는 경우
|
|
983
|
-
const visibleSeriesList = orderedSeriesList.filter(sId => this.seriesList[sId].show);
|
|
984
|
-
positionList = visibleSeriesList.map(sId => ({
|
|
985
|
-
sId,
|
|
986
|
-
position: this.seriesList[sId].data?.map(({ xp, yp }) => [xp, yp]),
|
|
987
|
-
}));
|
|
988
|
-
const dataIndex = positionList[0].position?.findIndex(([xp]) => xp >= clickedX);
|
|
989
|
-
const vectorList = positionList.map(({ sId, position }) => ({
|
|
990
|
-
sId,
|
|
991
|
-
vector: { start: position[dataIndex - 1], end: position[dataIndex] },
|
|
992
|
-
}));
|
|
993
|
-
|
|
994
|
-
const isEmptyVector = (arr => !arr || !Array.isArray(arr) || arr?.length !== 2);
|
|
995
|
-
|
|
996
|
-
// canvas 의 클릭 위치값은 제 4 사분면의 위치이므로 clickedY, y1, y2 의 값은 음수를 취한다.
|
|
997
|
-
if (isStackChart) {
|
|
998
|
-
hitSeries = vectorList.find(({ vector }) => {
|
|
999
|
-
if (isEmptyVector(vector?.start) && isEmptyVector(vector?.end)) {
|
|
1000
|
-
return false;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
const [x1, y1] = vector.start;
|
|
1004
|
-
const [x2, y2] = vector.end;
|
|
1005
|
-
const v1 = [x2 - x1, y1 - y2];
|
|
1006
|
-
const v2 = [x2 - clickedX, clickedY - y2];
|
|
1007
|
-
const xp = v1[0] * v2[1] - v1[1] * v2[0];
|
|
1008
|
-
|
|
1009
|
-
return vector.start.every(v => typeof v === 'number')
|
|
1010
|
-
&& vector.end.every(v => typeof v === 'number')
|
|
1011
|
-
&& xp > 0;
|
|
1012
|
-
})?.sId;
|
|
1013
|
-
} else {
|
|
1014
|
-
hitSeries = vectorList.find(({ vector }) => {
|
|
1015
|
-
if (isEmptyVector(vector?.start) && isEmptyVector(vector?.end)) {
|
|
1016
|
-
return false;
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
const [x1, y1] = vector.start;
|
|
1020
|
-
const [x2, y2] = vector.end;
|
|
1021
|
-
const a = (y1 - y2) / (x2 - x1);
|
|
1022
|
-
const b = -1;
|
|
1023
|
-
const c = -y1 - a * x1;
|
|
1024
|
-
const distance = Math.abs(a * clickedX - b * clickedY + c)
|
|
1025
|
-
/ Math.sqrt(a ** 2 + b ** 2);
|
|
1026
|
-
|
|
1027
|
-
return distance < 3;
|
|
1028
|
-
})?.sId;
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
break;
|
|
1032
|
-
}
|
|
1033
|
-
default:
|
|
1034
|
-
break;
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
result.sId = hitSeries;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
return result;
|
|
1041
|
-
},
|
|
1042
|
-
/**
|
|
1043
|
-
* @typedef {Object} LabelInfoResult
|
|
1044
|
-
* @property {number} labelIndex - 선택된 라벨의 인덱스
|
|
1045
|
-
* @property {object} hitInfo - 해당 위치에서의 히트 정보 (getItemByPosition 반환값)
|
|
1046
|
-
*/
|
|
1047
|
-
/**
|
|
1048
|
-
* Find label info by position x and y
|
|
1049
|
-
* @param {array} offset position x and y
|
|
1050
|
-
* @param {string | null} targetAxis target Axis Location ('xAxis', 'yAxis' , null)
|
|
1051
|
-
*
|
|
1052
|
-
* @returns {LabelInfoResult} clicked label information
|
|
1053
|
-
*/
|
|
1054
|
-
getLabelInfoByPosition(offset, targetAxis) {
|
|
1055
|
-
const [x, y] = offset;
|
|
1056
|
-
const aPos = {
|
|
1057
|
-
x1: this.chartRect.x1 + this.labelOffset.left,
|
|
1058
|
-
x2: this.chartRect.x2 - this.labelOffset.right,
|
|
1059
|
-
y1: this.chartRect.y1 + this.labelOffset.top,
|
|
1060
|
-
y2: this.chartRect.y2 - this.labelOffset.bottom,
|
|
1061
|
-
};
|
|
1062
|
-
|
|
1063
|
-
const seriesList = this.data.series;
|
|
1064
|
-
const pointSize = Object.values(seriesList).sort(
|
|
1065
|
-
(a, b) => b.pointSize ?? 0 - a.pointSize ?? 0,
|
|
1066
|
-
)[0]?.pointSize ?? 3; // default pointSize 3
|
|
1067
|
-
const { horizontal, selectLabel } = this.options;
|
|
1068
|
-
|
|
1069
|
-
let scale;
|
|
1070
|
-
let scrollbarOpt;
|
|
1071
|
-
if (targetAxis === 'xAxis') {
|
|
1072
|
-
scale = this.axesX[0];
|
|
1073
|
-
scrollbarOpt = this.scrollbar.x;
|
|
1074
|
-
} else if (targetAxis === 'yAxis') {
|
|
1075
|
-
scale = this.axesY[0];
|
|
1076
|
-
scrollbarOpt = this.scrollbar.y;
|
|
1077
|
-
} else {
|
|
1078
|
-
scale = horizontal ? this.axesY[0] : this.axesX[0];
|
|
1079
|
-
scrollbarOpt = horizontal ? this.scrollbar.y : this.scrollbar.x;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
const startPoint = aPos[scale.units.rectStart];
|
|
1083
|
-
const endPoint = aPos[scale.units.rectEnd];
|
|
1084
|
-
|
|
1085
|
-
let labelIndex;
|
|
1086
|
-
let hitInfo;
|
|
1087
|
-
if (scrollbarOpt?.use && scale?.labels?.length) {
|
|
1088
|
-
const { type, range, interval = 1 } = scrollbarOpt;
|
|
1089
|
-
const [min, max] = range ?? [0, scale.labels.length];
|
|
1090
|
-
const labelCount = Math.floor((+max - +min) / interval) + 1;
|
|
1091
|
-
const labelGap = (endPoint - startPoint) / labelCount;
|
|
1092
|
-
|
|
1093
|
-
const isYAxis = targetAxis === 'yAxis' || horizontal;
|
|
1094
|
-
const index = Math.floor(((isYAxis ? y : x) - startPoint) / labelGap);
|
|
1095
|
-
if (type === 'step') {
|
|
1096
|
-
labelIndex = min + index;
|
|
1097
|
-
} else {
|
|
1098
|
-
const minIndex = scale?.labels.findIndex(label => label === +min);
|
|
1099
|
-
labelIndex = minIndex + index;
|
|
1100
|
-
}
|
|
1101
|
-
} else if (scale?.labels?.length) {
|
|
1102
|
-
const labelGap = (endPoint - startPoint) / scale.labels.length;
|
|
1103
|
-
const isYAxis = targetAxis === 'yAxis';
|
|
1104
|
-
const index = Math.floor(((isYAxis ? y : x) - startPoint) / labelGap);
|
|
1105
|
-
labelIndex = scale.labels.length > index ? index : -1;
|
|
1106
|
-
} else {
|
|
1107
|
-
let offsetX;
|
|
1108
|
-
let dataIndex;
|
|
1109
|
-
if (x < startPoint - pointSize) {
|
|
1110
|
-
offsetX = startPoint;
|
|
1111
|
-
dataIndex = 0;
|
|
1112
|
-
} else if (x > endPoint + pointSize) {
|
|
1113
|
-
offsetX = endPoint;
|
|
1114
|
-
dataIndex = this.data.labels.length - 1;
|
|
1115
|
-
} else {
|
|
1116
|
-
offsetX = x;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
hitInfo = this.getItemByPosition(
|
|
1120
|
-
[offsetX, y],
|
|
1121
|
-
selectLabel?.useApproximateValue,
|
|
1122
|
-
dataIndex,
|
|
1123
|
-
true,
|
|
1124
|
-
);
|
|
1125
|
-
labelIndex = hitInfo.maxIndex ?? -1;
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
return {
|
|
1129
|
-
labelIndex,
|
|
1130
|
-
hitInfo,
|
|
1131
|
-
};
|
|
1132
|
-
},
|
|
1133
|
-
|
|
1134
|
-
/**
|
|
1135
|
-
* Get current mouse target label value in label array or calculated using mouse position
|
|
1136
|
-
*
|
|
1137
|
-
* @typedef {import('./index').MouseLabelValue} MouseLabelValue
|
|
1138
|
-
*
|
|
1139
|
-
* @param {string} targetAxis target Axis Location ('xAxis', 'yAxis')
|
|
1140
|
-
* @param {array} offset return value from getMousePosition()
|
|
1141
|
-
* @param {number} labelIndex
|
|
1142
|
-
*
|
|
1143
|
-
* @returns {MouseLabelValue} current mouse target label value
|
|
1144
|
-
*/
|
|
1145
|
-
getCurMouseLabelVal(targetAxis, offset, labelIndex) {
|
|
1146
|
-
const { type: chartType, horizontal } = this.options;
|
|
1147
|
-
const isXAxis = targetAxis === 'xAxis';
|
|
1148
|
-
const targetAxisDirection = isXAxis ? 'x' : 'y';
|
|
1149
|
-
|
|
1150
|
-
let labelVal = '';
|
|
1151
|
-
let labelIdx = -1;
|
|
1152
|
-
|
|
1153
|
-
const findLabelValInLabelArr = () => {
|
|
1154
|
-
let result = '';
|
|
1155
|
-
switch (chartType) {
|
|
1156
|
-
case 'bar':
|
|
1157
|
-
case 'line': {
|
|
1158
|
-
result = (
|
|
1159
|
-
(horizontal && !isXAxis)
|
|
1160
|
-
|| (!horizontal && isXAxis)
|
|
1161
|
-
) ? this.data.labels[labelIndex] : '';
|
|
1162
|
-
break;
|
|
1163
|
-
}
|
|
1164
|
-
case 'heatMap': {
|
|
1165
|
-
result = this.data.labels[targetAxisDirection][labelIndex];
|
|
1166
|
-
break;
|
|
1167
|
-
}
|
|
1168
|
-
default:
|
|
1169
|
-
break;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
return result;
|
|
1173
|
-
};
|
|
1174
|
-
|
|
1175
|
-
const calLabelValUseMousePos = () => {
|
|
1176
|
-
let result = '';
|
|
1177
|
-
const aPos = {
|
|
1178
|
-
x1: this.chartRect.x1 + this.labelOffset.left,
|
|
1179
|
-
x2: this.chartRect.x2 - this.labelOffset.right,
|
|
1180
|
-
y1: this.chartRect.y1 + this.labelOffset.top,
|
|
1181
|
-
y2: this.chartRect.y2 - this.labelOffset.bottom,
|
|
1182
|
-
};
|
|
1183
|
-
const {
|
|
1184
|
-
steps,
|
|
1185
|
-
interval: labelValInterval,
|
|
1186
|
-
graphMin,
|
|
1187
|
-
} = this.axesSteps[targetAxisDirection][0];
|
|
1188
|
-
const {
|
|
1189
|
-
width: labelWidth,
|
|
1190
|
-
height: labelHeight,
|
|
1191
|
-
} = this.axesRange[targetAxisDirection][0].size;
|
|
1192
|
-
const axes = isXAxis ? this.axesX : this.axesY;
|
|
1193
|
-
const axisStartPoint = aPos[axes[0].units.rectStart];
|
|
1194
|
-
const axisEndPoint = aPos[axes[0].units.rectEnd];
|
|
1195
|
-
const curMousePosInAxis = Math.abs(offset[isXAxis ? 0 : 1] - axisStartPoint);
|
|
1196
|
-
const labelMidLength = (isXAxis ? labelWidth : labelHeight) / 2;
|
|
1197
|
-
const labelPosInterval = Math.abs(axisStartPoint - axisEndPoint) / steps;
|
|
1198
|
-
const labelStep = Math.floor((curMousePosInAxis + labelMidLength) / labelPosInterval);
|
|
1199
|
-
|
|
1200
|
-
if (
|
|
1201
|
-
((labelPosInterval * labelStep) + labelMidLength > curMousePosInAxis)
|
|
1202
|
-
&& ((labelPosInterval * labelStep) - labelMidLength < curMousePosInAxis)
|
|
1203
|
-
) {
|
|
1204
|
-
result = (labelStep * labelValInterval) + graphMin;
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
return result;
|
|
1208
|
-
};
|
|
1209
|
-
|
|
1210
|
-
if (typeof labelIndex === 'number') {
|
|
1211
|
-
labelVal = findLabelValInLabelArr();
|
|
1212
|
-
labelIdx = labelIndex;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
if (!labelVal) {
|
|
1216
|
-
labelVal = calLabelValUseMousePos();
|
|
1217
|
-
labelIdx = -1;
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
return { labelVal, labelIdx };
|
|
1221
|
-
},
|
|
1222
|
-
|
|
1223
|
-
/**
|
|
1224
|
-
* Create min/max information for all of data
|
|
1225
|
-
* @property seriesList
|
|
1226
|
-
*
|
|
1227
|
-
* @returns {object} min/max info for all of data
|
|
1228
|
-
*/
|
|
1229
|
-
getStoreMinMax() {
|
|
1230
|
-
const keys = Object.keys(this.seriesList);
|
|
1231
|
-
const isHorizontal = this.options.horizontal;
|
|
1232
|
-
const def = {
|
|
1233
|
-
x: [{ min: null, max: null }],
|
|
1234
|
-
y: [{ min: null, max: null }],
|
|
1235
|
-
};
|
|
1236
|
-
|
|
1237
|
-
if (keys.length) {
|
|
1238
|
-
return keys.reduce((acc, key) => {
|
|
1239
|
-
const minmax = acc;
|
|
1240
|
-
const series = this.seriesList[key];
|
|
1241
|
-
const smm = series.minMax;
|
|
1242
|
-
const axisX = series.xAxisIndex;
|
|
1243
|
-
const axisY = series.yAxisIndex;
|
|
1244
|
-
|
|
1245
|
-
if (!minmax.x[axisX]) {
|
|
1246
|
-
minmax.x[axisX] = { min: null, max: null, maxSID: null };
|
|
1247
|
-
}
|
|
1248
|
-
if (!minmax.y[axisY]) {
|
|
1249
|
-
minmax.y[axisY] = { min: null, max: null, maxSID: null };
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
if (smm && series.show) {
|
|
1253
|
-
if (!isHorizontal) {
|
|
1254
|
-
if (smm.minX !== null
|
|
1255
|
-
&& ((minmax.x[axisX].min === null || (smm.minX < minmax.x[axisX].min)))) {
|
|
1256
|
-
minmax.x[axisX].min = smm.minX;
|
|
1257
|
-
}
|
|
1258
|
-
if (minmax.y[axisY].min === null || (smm.minY < minmax.y[axisY].min)) {
|
|
1259
|
-
minmax.y[axisY].min = smm.minY;
|
|
1260
|
-
}
|
|
1261
|
-
} else {
|
|
1262
|
-
if (minmax.x[axisX].min === null || (smm.minX < minmax.x[axisX].min)) {
|
|
1263
|
-
minmax.x[axisX].min = smm.minX;
|
|
1264
|
-
}
|
|
1265
|
-
if (smm.minY !== null
|
|
1266
|
-
&& (minmax.y[axisY].min === null || (smm.minY < minmax.y[axisY].min))) {
|
|
1267
|
-
minmax.y[axisY].min = smm.minY;
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
const isExistGrp = this.seriesList[key].isExistGrp;
|
|
1272
|
-
const maxXisNegative = minmax.x[axisX].max < 0;
|
|
1273
|
-
|
|
1274
|
-
if (isExistGrp && maxXisNegative) {
|
|
1275
|
-
minmax.x[axisX].max = smm.maxX;
|
|
1276
|
-
minmax.x[axisX].maxSID = key;
|
|
1277
|
-
} else if (!minmax.x[axisX].max || smm.maxX >= minmax.x[axisX].max) {
|
|
1278
|
-
minmax.x[axisX].max = smm.maxX;
|
|
1279
|
-
minmax.x[axisX].maxSID = key;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
const maxYisNegative = minmax.y[axisY].max < 0;
|
|
1283
|
-
if (isExistGrp && maxYisNegative) {
|
|
1284
|
-
minmax.y[axisY].max = smm.maxY;
|
|
1285
|
-
minmax.y[axisY].maxSID = key;
|
|
1286
|
-
} else if (!minmax.y[axisY].max || smm.maxY >= minmax.y[axisY].max) {
|
|
1287
|
-
minmax.y[axisY].max = smm.maxY;
|
|
1288
|
-
minmax.y[axisY].maxSID = key;
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
return minmax;
|
|
1293
|
-
}, {
|
|
1294
|
-
x: [{ min: null, max: null, maxSID: null }],
|
|
1295
|
-
y: [{ min: null, max: null, maxSID: null }],
|
|
1296
|
-
});
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
return def;
|
|
1300
|
-
},
|
|
1301
|
-
|
|
1302
|
-
calculateAngle() {
|
|
1303
|
-
const pieDataSet = this.pieDataSet;
|
|
1304
|
-
|
|
1305
|
-
let slice;
|
|
1306
|
-
let value;
|
|
1307
|
-
let parent;
|
|
1308
|
-
let totalValue;
|
|
1309
|
-
|
|
1310
|
-
let sliceAngle;
|
|
1311
|
-
let startAngle;
|
|
1312
|
-
let endAngle;
|
|
1313
|
-
let totalAngle;
|
|
1314
|
-
let isDummy;
|
|
1315
|
-
|
|
1316
|
-
const dummyIndex = [];
|
|
1317
|
-
const saStore = {
|
|
1318
|
-
'$ev-root': 1.5 * Math.PI,
|
|
1319
|
-
};
|
|
1320
|
-
|
|
1321
|
-
for (let ix = 0; ix < pieDataSet.length; ix++) {
|
|
1322
|
-
const pie = pieDataSet[ix];
|
|
1323
|
-
isDummy = true;
|
|
1324
|
-
|
|
1325
|
-
for (let jx = 0; jx < pie.data.length; jx++) {
|
|
1326
|
-
slice = pie.data[jx];
|
|
1327
|
-
value = slice.value;
|
|
1328
|
-
|
|
1329
|
-
if (isDummy) {
|
|
1330
|
-
isDummy = slice.id === 'dummy';
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
if (!ix) {
|
|
1334
|
-
startAngle = saStore['$ev-root'];
|
|
1335
|
-
sliceAngle = 2 * Math.PI * (value / pie.total);
|
|
1336
|
-
endAngle = startAngle + sliceAngle;
|
|
1337
|
-
|
|
1338
|
-
slice.sa = startAngle;
|
|
1339
|
-
slice.ea = endAngle;
|
|
1340
|
-
saStore['$ev-root'] += sliceAngle;
|
|
1341
|
-
} else {
|
|
1342
|
-
parent = this.getParentInfo(ix - 1, slice.parent);
|
|
1343
|
-
if (!parent) {
|
|
1344
|
-
break;
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
if (!saStore[slice.parent]) {
|
|
1348
|
-
saStore[slice.parent] = parent.sa;
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
startAngle = saStore[slice.parent];
|
|
1352
|
-
totalAngle = parent.ea - parent.sa;
|
|
1353
|
-
totalValue = pie.total[slice.parent] || 0;
|
|
1354
|
-
sliceAngle = totalAngle * (value / totalValue);
|
|
1355
|
-
endAngle = startAngle + sliceAngle;
|
|
1356
|
-
|
|
1357
|
-
slice.sa = startAngle;
|
|
1358
|
-
slice.ea = endAngle;
|
|
1359
|
-
|
|
1360
|
-
saStore[slice.parent] += sliceAngle;
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
if (isDummy) {
|
|
1365
|
-
dummyIndex.push(ix);
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
for (let ix = 0; ix < dummyIndex.length; ix++) {
|
|
1370
|
-
this.pieDataSet.splice(dummyIndex, 1);
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
if (this.options.reverse) {
|
|
1374
|
-
this.pieDataSet = reverse(this.pieDataSet);
|
|
1375
|
-
}
|
|
1376
|
-
},
|
|
1377
|
-
|
|
1378
|
-
getParentInfo(depth, parentId) {
|
|
1379
|
-
for (let ix = depth; ix >= 0; ix--) {
|
|
1380
|
-
const pie = this.pieDataSet[ix];
|
|
1381
|
-
for (let jx = 0; jx < pie.data.length; jx++) {
|
|
1382
|
-
if (pie.data[jx].id === parentId) {
|
|
1383
|
-
return pie.data[jx];
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
return null;
|
|
1389
|
-
},
|
|
1390
|
-
|
|
1391
|
-
/**
|
|
1392
|
-
* Get Aggregations (
|
|
1393
|
-
* @returns {{}}
|
|
1394
|
-
*/
|
|
1395
|
-
getAggregations() {
|
|
1396
|
-
const allData = this.data.data;
|
|
1397
|
-
const series = this.data.series;
|
|
1398
|
-
const aggregationDataSet = {};
|
|
1399
|
-
const seriesIds = Object.keys(series);
|
|
1400
|
-
|
|
1401
|
-
seriesIds?.forEach((sId) => {
|
|
1402
|
-
const dataList = allData[sId].map(data => (data?.value ? data.value : data));
|
|
1403
|
-
const last = (dataList[dataList.length - 1]);
|
|
1404
|
-
|
|
1405
|
-
const dataListExcludedNull = dataList.filter(value => value !== undefined && value !== null);
|
|
1406
|
-
const min = (Math.min(...dataListExcludedNull));
|
|
1407
|
-
const max = (Math.max(...dataListExcludedNull));
|
|
1408
|
-
const total = (dataListExcludedNull.reduce((a, b) => a + b, 0));
|
|
1409
|
-
const avg = (total / dataListExcludedNull.length || 0);
|
|
1410
|
-
|
|
1411
|
-
if (!Util.checkSafeInteger(min)
|
|
1412
|
-
|| !Util.checkSafeInteger(max)
|
|
1413
|
-
|| !Util.checkSafeInteger(avg)
|
|
1414
|
-
|| !Util.checkSafeInteger(total)
|
|
1415
|
-
|| !Util.checkSafeInteger(last)
|
|
1416
|
-
) {
|
|
1417
|
-
console.warn('[EVUI][Chart] The aggregated value exceeds 9007199254740991 or less than -9007199254740991.');
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
aggregationDataSet[sId] = { min, max, avg, total, last };
|
|
1421
|
-
});
|
|
1422
|
-
|
|
1423
|
-
return aggregationDataSet;
|
|
1424
|
-
},
|
|
1425
|
-
};
|
|
1426
|
-
|
|
1427
|
-
export default modules;
|