evui 3.4.207 → 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.
Files changed (162) hide show
  1. package/README.md +18 -33
  2. package/dist/404.html +44 -0
  3. package/dist/favicon.ico +0 -0
  4. package/dist/index.js +22645 -0
  5. package/dist/index.umd.cjs +28 -0
  6. package/dist/style.css +1 -0
  7. package/package.json +46 -43
  8. package/dist/evui.common.js +0 -63681
  9. package/dist/evui.common.js.map +0 -1
  10. package/dist/evui.umd.js +0 -63691
  11. package/dist/evui.umd.js.map +0 -1
  12. package/dist/evui.umd.min.js +0 -2
  13. package/dist/evui.umd.min.js.map +0 -1
  14. package/dist/img/EVUI.b82ee81a.svg +0 -293
  15. package/src/assets/logo.png +0 -0
  16. package/src/common/emitter.js +0 -20
  17. package/src/common/utils.bignumber.js +0 -67
  18. package/src/common/utils.debounce.js +0 -223
  19. package/src/common/utils.js +0 -151
  20. package/src/common/utils.table.js +0 -78
  21. package/src/common/utils.throttle.js +0 -83
  22. package/src/common/utils.tree.js +0 -18
  23. package/src/components/button/Button.vue +0 -195
  24. package/src/components/button/index.js +0 -7
  25. package/src/components/buttonGroup/ButtonGroup.vue +0 -11
  26. package/src/components/buttonGroup/index.js +0 -7
  27. package/src/components/calendar/Calendar.vue +0 -725
  28. package/src/components/calendar/index.js +0 -7
  29. package/src/components/calendar/uses.js +0 -1410
  30. package/src/components/chart/Chart.vue +0 -363
  31. package/src/components/chart/ChartToolbar.vue +0 -52
  32. package/src/components/chart/chart.core.js +0 -1170
  33. package/src/components/chart/chartZoom.core.js +0 -540
  34. package/src/components/chart/element/element.bar.js +0 -672
  35. package/src/components/chart/element/element.bar.time.js +0 -166
  36. package/src/components/chart/element/element.heatmap.js +0 -743
  37. package/src/components/chart/element/element.line.js +0 -611
  38. package/src/components/chart/element/element.pie.js +0 -197
  39. package/src/components/chart/element/element.scatter.js +0 -320
  40. package/src/components/chart/element/element.tip.js +0 -717
  41. package/src/components/chart/helpers/helpers.canvas.js +0 -265
  42. package/src/components/chart/helpers/helpers.constant.js +0 -235
  43. package/src/components/chart/helpers/helpers.util.js +0 -400
  44. package/src/components/chart/index.js +0 -9
  45. package/src/components/chart/model/index.js +0 -50
  46. package/src/components/chart/model/model.series.js +0 -125
  47. package/src/components/chart/model/model.store.js +0 -1427
  48. package/src/components/chart/plugins/plugins.interaction.js +0 -1659
  49. package/src/components/chart/plugins/plugins.legend.gradient.js +0 -606
  50. package/src/components/chart/plugins/plugins.legend.js +0 -1543
  51. package/src/components/chart/plugins/plugins.pie.js +0 -254
  52. package/src/components/chart/plugins/plugins.scrollbar.js +0 -732
  53. package/src/components/chart/plugins/plugins.title.js +0 -61
  54. package/src/components/chart/plugins/plugins.tooltip.js +0 -1041
  55. package/src/components/chart/scale/scale.js +0 -951
  56. package/src/components/chart/scale/scale.linear.js +0 -268
  57. package/src/components/chart/scale/scale.logarithmic.js +0 -135
  58. package/src/components/chart/scale/scale.step.js +0 -430
  59. package/src/components/chart/scale/scale.time.category.js +0 -338
  60. package/src/components/chart/scale/scale.time.js +0 -49
  61. package/src/components/chart/style/chart.scss +0 -405
  62. package/src/components/chart/uses.js +0 -721
  63. package/src/components/chartBrush/ChartBrush.vue +0 -323
  64. package/src/components/chartBrush/chartBrush.core.js +0 -691
  65. package/src/components/chartBrush/index.js +0 -9
  66. package/src/components/chartBrush/uses.js +0 -23
  67. package/src/components/chartGroup/ChartGroup.vue +0 -144
  68. package/src/components/chartGroup/index.js +0 -9
  69. package/src/components/chartGroup/style/chartGroup.scss +0 -5
  70. package/src/components/chartGroup/uses.js +0 -53
  71. package/src/components/checkbox/Checkbox.vue +0 -229
  72. package/src/components/checkbox/index.js +0 -7
  73. package/src/components/checkboxGroup/CheckboxGroup.vue +0 -44
  74. package/src/components/checkboxGroup/index.js +0 -7
  75. package/src/components/contextMenu/ContextMenu.vue +0 -95
  76. package/src/components/contextMenu/MenuList.vue +0 -182
  77. package/src/components/contextMenu/index.js +0 -7
  78. package/src/components/contextMenu/uses.js +0 -223
  79. package/src/components/datePicker/DatePicker.vue +0 -504
  80. package/src/components/datePicker/index.js +0 -7
  81. package/src/components/datePicker/uses.js +0 -460
  82. package/src/components/grid/Grid.vue +0 -1535
  83. package/src/components/grid/GridColumnSetting.vue +0 -358
  84. package/src/components/grid/GridFilterSetting.vue +0 -323
  85. package/src/components/grid/GridPagination.vue +0 -75
  86. package/src/components/grid/GridSummary.vue +0 -314
  87. package/src/components/grid/GridToolbar.vue +0 -35
  88. package/src/components/grid/icon/icon-option-button.vue +0 -17
  89. package/src/components/grid/icon/icon-sort-button.vue +0 -67
  90. package/src/components/grid/index.js +0 -11
  91. package/src/components/grid/style/grid.scss +0 -417
  92. package/src/components/grid/uses.js +0 -1629
  93. package/src/components/icon/Icon.vue +0 -53
  94. package/src/components/icon/index.js +0 -8
  95. package/src/components/inputNumber/InputNumber.vue +0 -212
  96. package/src/components/inputNumber/index.js +0 -7
  97. package/src/components/inputNumber/uses.js +0 -217
  98. package/src/components/loading/Loading.vue +0 -125
  99. package/src/components/loading/index.js +0 -7
  100. package/src/components/menu/Menu.vue +0 -79
  101. package/src/components/menu/MenuItem.vue +0 -201
  102. package/src/components/menu/index.js +0 -7
  103. package/src/components/message/Message.vue +0 -229
  104. package/src/components/message/index.js +0 -34
  105. package/src/components/messageBox/MessageBox.vue +0 -358
  106. package/src/components/messageBox/index.js +0 -22
  107. package/src/components/notification/Notification.vue +0 -316
  108. package/src/components/notification/index.js +0 -49
  109. package/src/components/pagination/Pagination.vue +0 -317
  110. package/src/components/pagination/index.js +0 -7
  111. package/src/components/pagination/pageButton.vue +0 -31
  112. package/src/components/progress/Progress.vue +0 -139
  113. package/src/components/progress/index.js +0 -7
  114. package/src/components/radio/Radio.vue +0 -159
  115. package/src/components/radio/index.js +0 -7
  116. package/src/components/radioGroup/RadioGroup.vue +0 -41
  117. package/src/components/radioGroup/index.js +0 -7
  118. package/src/components/scheduler/Scheduler.vue +0 -149
  119. package/src/components/scheduler/index.js +0 -7
  120. package/src/components/scheduler/uses.js +0 -183
  121. package/src/components/select/Select.vue +0 -556
  122. package/src/components/select/index.js +0 -7
  123. package/src/components/select/uses.js +0 -379
  124. package/src/components/slider/Slider.vue +0 -505
  125. package/src/components/slider/index.js +0 -7
  126. package/src/components/slider/uses.js +0 -391
  127. package/src/components/tabPanel/TabPanel.vue +0 -74
  128. package/src/components/tabPanel/index.js +0 -7
  129. package/src/components/tabs/Tabs.vue +0 -517
  130. package/src/components/tabs/index.js +0 -7
  131. package/src/components/textField/TextField.vue +0 -399
  132. package/src/components/textField/index.js +0 -7
  133. package/src/components/timePicker/TimePicker.vue +0 -364
  134. package/src/components/timePicker/index.js +0 -7
  135. package/src/components/toggle/Toggle.vue +0 -115
  136. package/src/components/toggle/index.js +0 -7
  137. package/src/components/tree/Tree.vue +0 -338
  138. package/src/components/tree/TreeNode.vue +0 -293
  139. package/src/components/tree/index.js +0 -7
  140. package/src/components/treeGrid/TreeGrid.vue +0 -1074
  141. package/src/components/treeGrid/TreeGridNode.vue +0 -349
  142. package/src/components/treeGrid/TreeGridToolbar.vue +0 -35
  143. package/src/components/treeGrid/icon/icon-tree.png +0 -0
  144. package/src/components/treeGrid/index.js +0 -9
  145. package/src/components/treeGrid/style/treeGrid.scss +0 -277
  146. package/src/components/treeGrid/uses.js +0 -1178
  147. package/src/components/window/Window.vue +0 -329
  148. package/src/components/window/index.js +0 -7
  149. package/src/components/window/uses.js +0 -908
  150. package/src/directives/clickoutside.js +0 -90
  151. package/src/main.js +0 -120
  152. package/src/style/components/input.scss +0 -108
  153. package/src/style/functions.scss +0 -3
  154. package/src/style/index.scss +0 -6
  155. package/src/style/lib/fonts/EVUI.eot +0 -0
  156. package/src/style/lib/fonts/EVUI.svg +0 -293
  157. package/src/style/lib/fonts/EVUI.ttf +0 -0
  158. package/src/style/lib/fonts/EVUI.woff +0 -0
  159. package/src/style/lib/icon.css +0 -888
  160. package/src/style/mixins.scss +0 -94
  161. package/src/style/themes.scss +0 -69
  162. package/src/style/variables.scss +0 -22
@@ -1,717 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import { numberWithComma } from '@/common/utils';
3
- import Canvas from '../helpers/helpers.canvas';
4
- import { truthyNumber } from '../../../common/utils';
5
-
6
- const modules = {
7
- /**
8
- * Draw TextTip with tip's locationInfo
9
- * @param {object} [tipLocationInfo=undefined] tip location information
10
- *
11
- * @returns {undefined}
12
- */
13
- drawTips(tipLocationInfo) {
14
- const opt = this.options;
15
- let tooltipValueFormatter = null;
16
- const isHorizontal = !!opt.horizontal;
17
- const maxTipOpt = opt.maxTip;
18
- const selTipOpt = opt.selectItem;
19
- const labelTipOpt = opt.selectLabel;
20
- let maxArgs;
21
- let isExistSelectedLabel;
22
-
23
- if (typeof opt.tooltip?.formatter === 'function') {
24
- tooltipValueFormatter = opt.tooltip?.formatter;
25
- } else if (typeof opt.tooltip?.formatter?.value === 'function') {
26
- tooltipValueFormatter = opt.tooltip?.formatter?.value;
27
- }
28
-
29
- if (labelTipOpt.use && labelTipOpt.showTip) {
30
- isExistSelectedLabel = opt.type === 'heatMap'
31
- ? this.drawLabelTipForHeatMap()
32
- : this.drawTipForSelectedLabel();
33
- }
34
-
35
- const executeDrawIndicator = (tipOpt) => {
36
- tipLocationInfo.forEach((tipInfo) => {
37
- if (tipInfo) {
38
- const seriesInfo = this.seriesList[tipInfo?.sId];
39
-
40
- if (!seriesInfo?.show) {
41
- return;
42
- }
43
-
44
- const selArgs = this.calculateTipInfo(
45
- seriesInfo,
46
- 'sel',
47
- tipInfo,
48
- );
49
-
50
- if (selArgs) {
51
- let isSamePos = false;
52
-
53
- if (maxTipOpt.use && maxArgs?.dp === selArgs.dp) {
54
- isSamePos = true;
55
- }
56
-
57
- if (tipOpt.showTextTip || tipOpt.showTip) {
58
- if (tipOpt.tipText === 'label') {
59
- const axisOpt = isHorizontal ? opt.axesY[0] : opt.axesX[0];
60
- const label = selArgs.label;
61
- selArgs.text = axisOpt.type === 'time' ? dayjs(label).format(axisOpt.timeFormat) : label;
62
- } else {
63
- selArgs.text = numberWithComma(selArgs.value);
64
- }
65
-
66
- this.drawTextTip({ opt: tipOpt, tipType: 'sel', seriesOpt: seriesInfo, isSamePos, ...selArgs });
67
- }
68
-
69
- if (tipOpt.showIndicator) {
70
- this.drawFixedIndicator({ opt: tipOpt, seriesOpt: seriesInfo, ...selArgs });
71
- }
72
- }
73
-
74
- if (tipInfo && tipInfo?.label && tipInfo?.label === 0) {
75
- this.lastHitInfo = tipInfo;
76
- }
77
- }
78
- });
79
- };
80
-
81
- if (tipLocationInfo && !isExistSelectedLabel) {
82
- if (selTipOpt.use) {
83
- executeDrawIndicator(selTipOpt);
84
- } else if (labelTipOpt.use && opt.type === 'line') {
85
- executeDrawIndicator(labelTipOpt);
86
- }
87
- }
88
-
89
- if (maxTipOpt.use && !isExistSelectedLabel) {
90
- const maxSID = this.minMax[isHorizontal ? 'x' : 'y'][0].maxSID;
91
- const seriesInfo = this.seriesList[maxSID];
92
- maxArgs = this.calculateTipInfo(seriesInfo, 'max', null);
93
-
94
- if (maxTipOpt.use && maxArgs) {
95
- if (tooltipValueFormatter) {
96
- maxArgs.text = tooltipValueFormatter({
97
- seriesId: seriesInfo.sId,
98
- x: isHorizontal ? maxArgs.value : undefined,
99
- y: !isHorizontal ? maxArgs.value : undefined,
100
- });
101
- } else {
102
- maxArgs.text = numberWithComma(maxArgs.value);
103
- }
104
- this.drawTextTip({ opt: maxTipOpt, tipType: 'max', seriesOpt: seriesInfo, ...maxArgs });
105
-
106
- if (maxTipOpt.showIndicator) {
107
- this.drawFixedIndicator({ opt: maxTipOpt, seriesOpt: seriesInfo, ...maxArgs });
108
- }
109
- }
110
- }
111
- },
112
-
113
- /**
114
- * Calculate tip size and contents
115
- * @param {object} series series information (max series or selected series)
116
- * @param {string} tipType tip type
117
- * [sel = user select series, label = user select label, max = max value]
118
- * @param {object} hitInfo mouse hit information
119
- *
120
- * @returns {object} size and tip contents
121
- */
122
- calculateTipInfo(series, tipType, hitInfo) {
123
- if (!series) {
124
- return false;
125
- }
126
-
127
- const isHorizontal = !!this.options.horizontal;
128
- const lastTip = this.lastTip;
129
- const chartRect = this.chartRect;
130
- const labelOffset = this.labelOffset;
131
- const graphPos = {
132
- x1: chartRect.x1 + labelOffset.left,
133
- x2: chartRect.x2 - labelOffset.right,
134
- y1: chartRect.y1 + labelOffset.top,
135
- y2: chartRect.y2 - labelOffset.bottom,
136
- };
137
-
138
- const yArea = chartRect.chartHeight - (labelOffset.top + labelOffset.bottom);
139
- const xArea = chartRect.chartWidth - (labelOffset.left + labelOffset.right);
140
-
141
- const graphX = this.axesSteps.x[series.xAxisIndex];
142
- const graphY = this.axesSteps.y[series.yAxisIndex];
143
-
144
- const xsp = graphPos.x1;
145
- const xep = graphPos.x2;
146
- const ysp = graphPos.y2;
147
-
148
- const { type, size } = series;
149
- const { maxDomain, maxDomainIndex } = series.minMax;
150
-
151
- if (maxDomain === null || maxDomainIndex < 0) {
152
- return false;
153
- }
154
-
155
- let ldata = type === 'bar' ? maxDomainIndex : maxDomain;
156
-
157
- if (tipType === 'sel') {
158
- if (hitInfo && hitInfo.label !== null) {
159
- lastTip.pos = type === 'bar' ? hitInfo.maxIndex : hitInfo.label;
160
- ldata = lastTip.pos;
161
- } else if (lastTip.pos !== null) {
162
- ldata = lastTip.pos;
163
- }
164
- }
165
-
166
- let value = isHorizontal ? series.minMax.maxX : series.minMax.maxY;
167
- let label;
168
- if (tipType === 'sel') {
169
- if (hitInfo && hitInfo.value !== null) {
170
- value = hitInfo.useStack ? hitInfo.acc : hitInfo.value;
171
- label = hitInfo.label;
172
- lastTip.value = value;
173
- lastTip.label = label;
174
- } else if (lastTip.value !== null) {
175
- value = lastTip.value;
176
- label = lastTip.label;
177
- } else if (lastTip.pos !== null) {
178
- const item = type === 'bar'
179
- ? this.getItemByLabelIndex(lastTip.pos) : this.getItemByLabel(lastTip.pos);
180
-
181
- value = item.useStack ? item.acc : item.value;
182
- label = item.label;
183
- lastTip.value = value;
184
- lastTip.label = label;
185
- }
186
- }
187
-
188
- let cp;
189
- let halfBarSize;
190
- let dp;
191
-
192
- if (type === 'bar') {
193
- const scrollbarOpt = isHorizontal ? this.scrollbar.y : this.scrollbar.x;
194
- if (scrollbarOpt?.use) {
195
- const [min, max] = scrollbarOpt?.range ?? [];
196
- if (ldata >= min && ldata <= max) {
197
- ldata -= (min ?? 0);
198
- } else {
199
- return false;
200
- }
201
- }
202
-
203
- if (isHorizontal) {
204
- halfBarSize = Math.round(size.h / 2);
205
- cp = ysp - (size.cat * ldata) - size.cPad;
206
- dp = (cp - ((size.bar * size.ix) - (size.h + size.bPad))) - halfBarSize;
207
- } else {
208
- halfBarSize = Math.round(size.w / 2);
209
- cp = xsp + (size.cat * ldata) + size.cPad;
210
- dp = cp + ((size.bar * size.ix) - (size.w + size.bPad)) + halfBarSize;
211
- }
212
- } else if (type === 'line') {
213
- dp = Canvas.calculateX(
214
- ldata,
215
- graphX.graphMin,
216
- graphX.graphMax,
217
- xArea - size.comboOffset,
218
- xsp + (size.comboOffset / 2),
219
- );
220
- } else if (type === 'scatter') {
221
- dp = Canvas.calculateX(
222
- ldata,
223
- graphX.graphMin,
224
- graphX.graphMax,
225
- xArea,
226
- xsp,
227
- );
228
- }
229
-
230
- const sizeObj = { xArea, yArea, graphX, graphY, xsp, xep, ysp };
231
- const dataObj = { dp, value, label, type };
232
-
233
- return { ...sizeObj, ...dataObj };
234
- },
235
- drawFixedIndicator(param) {
236
- const isHorizontal = !!this.options.horizontal;
237
- const ctx = this.bufferCtx;
238
- const { graphX, graphY, xArea, yArea, xsp, ysp, dp, type, value, opt, seriesOpt } = param;
239
- let offset = 0;
240
-
241
- if (type === 'line') {
242
- offset += 3;
243
- } else if (type === 'scatter') {
244
- offset += seriesOpt?.pointSize ?? 0;
245
- }
246
-
247
- let gp;
248
-
249
- if (opt.fixedPosTop) {
250
- if (isHorizontal) {
251
- gp = Canvas.calculateX(graphX.graphMax, graphX.graphMin, graphX.graphMax, xArea, xsp);
252
- } else {
253
- gp = Canvas.calculateY(graphY.graphMax, graphY.graphMin, graphY.graphMax, yArea, ysp);
254
- gp -= offset;
255
- }
256
- } else if (isHorizontal) {
257
- gp = Canvas.calculateX(value, graphX.graphMin, graphX.graphMax, xArea, xsp);
258
- } else {
259
- gp = Canvas.calculateY(value, graphY.graphMin, graphY.graphMax, yArea, ysp);
260
- gp -= offset;
261
- }
262
-
263
- if (dp === null) {
264
- return;
265
- }
266
-
267
- ctx.beginPath();
268
- ctx.save();
269
- ctx.strokeStyle = opt.indicatorColor;
270
- ctx.lineWidth = 2;
271
-
272
- if (isHorizontal) {
273
- ctx.moveTo(xsp, dp);
274
- ctx.lineTo(gp, dp);
275
- } else {
276
- ctx.moveTo(dp, ysp);
277
- ctx.lineTo(dp, gp);
278
- }
279
-
280
- ctx.stroke();
281
- ctx.restore();
282
- ctx.closePath();
283
- },
284
-
285
- /**
286
- * Draw Selected Label Tip
287
- * none Text
288
- * @returns {boolean} Whether drew at least one tip
289
- */
290
- drawTipForSelectedLabel() {
291
- const opt = this.options;
292
- const isHorizontal = !!opt.horizontal;
293
- const labelTipOpt = opt.selectLabel;
294
- const { dataIndex, data, label } = this.defaultSelectInfo;
295
- let drawTip = false;
296
-
297
- if (dataIndex.length) {
298
- drawTip = true;
299
-
300
- const chartRect = this.chartRect;
301
- const labelOffset = this.labelOffset;
302
- const aPos = {
303
- x1: chartRect.x1 + labelOffset.left,
304
- x2: chartRect.x2 - labelOffset.right,
305
- y1: chartRect.y1 + labelOffset.top,
306
- y2: chartRect.y2 - labelOffset.bottom,
307
- };
308
- const labelAxes = isHorizontal ? this.axesY[0] : this.axesX[0];
309
- const valueAxes = isHorizontal ? this.axesX[0] : this.axesY[0];
310
- const valueAxesSteps = isHorizontal ? this.axesSteps.x[0] : this.axesSteps.y[0];
311
- const valuePositionCalcFunction = isHorizontal ? Canvas.calculateX : Canvas.calculateY;
312
- const labelPositionCalcFunction = isHorizontal ? Canvas.calculateY : Canvas.calculateX;
313
- const scrollbarOpt = isHorizontal ? this.scrollbar.y : this.scrollbar.x;
314
-
315
- const chartWidth = chartRect.chartWidth - (labelOffset.left + labelOffset.right);
316
- const chartHeight = chartRect.chartHeight - (labelOffset.top + labelOffset.bottom);
317
- const valueSpace = isHorizontal ? chartWidth : chartHeight;
318
- const valueStartPoint = aPos[valueAxes.units.rectStart];
319
- let offset = this.options.type === 'bar' ? 4 : 6;
320
- offset *= isHorizontal ? 1 : -1;
321
-
322
- const seriesList = Object.keys(this.seriesList ?? {});
323
- const visibleSeries = seriesList.filter(sId => this.seriesList[sId].show);
324
- const isExistGrp = seriesList
325
- .some(sId => this.seriesList[sId].isExistGrp && !this.seriesList[sId].isOverlapping);
326
- const groups = this.data.groups?.[0] ?? [];
327
-
328
- let labelPos;
329
- let dataPos;
330
- let value;
331
- let labelStartPoint;
332
- let labelEndPoint;
333
- let labelGap;
334
- let graphX;
335
- let lineSeries;
336
- let sizeObj;
337
- let startIndex = 0;
338
- let endIndex = labelAxes.labels?.length;
339
-
340
- if (labelAxes.labels) {
341
- let labelCount = labelAxes.labels.length;
342
- if (scrollbarOpt?.use) {
343
- const { range, interval, type } = scrollbarOpt;
344
- const [min, max] = range;
345
- if (truthyNumber(min) && truthyNumber(max)) {
346
- labelCount = Math.floor((+max - +min) / interval) + 1;
347
- startIndex = type === 'step' ? min : labelAxes.labels.findIndex(v => v === +min);
348
- endIndex = type === 'step' ? max : labelAxes.labels.findIndex(v => v === +max);
349
- }
350
- }
351
-
352
- labelStartPoint = aPos[labelAxes.units.rectStart];
353
- labelEndPoint = aPos[labelAxes.units.rectEnd];
354
- labelGap = (labelEndPoint - labelStartPoint) / labelCount;
355
- } else {
356
- graphX = this.axesSteps.x[0];
357
- lineSeries = seriesList.find(sId => this.seriesList[sId]?.type === 'line');
358
- sizeObj = this.seriesList[lineSeries].size;
359
- }
360
-
361
- data.forEach((selectedData, i) => {
362
- value = valueAxesSteps.graphMax;
363
-
364
- if (!labelTipOpt.fixedPosTop) {
365
- if (isExistGrp) {
366
- const positiveSum = visibleSeries?.reduce((ac, sId) => (
367
- groups.includes(sId) && (selectedData[sId]?.value ?? selectedData[sId]) > 0
368
- ? ac + (selectedData[sId]?.value ?? selectedData[sId])
369
- : ac), 0);
370
-
371
- const nonGroupValues = visibleSeries
372
- ?.filter(sId => !groups.includes(sId))
373
- ?.map(sId => selectedData[sId]?.value ?? selectedData[sId]) ?? [];
374
-
375
- const maxNonGroupValue = nonGroupValues?.length > 0
376
- ? nonGroupValues.reduce((max, val) => Math.max(max, val ?? -Infinity), -Infinity)
377
- : -Infinity;
378
-
379
- value = positiveSum > 0
380
- ? Math.max(maxNonGroupValue, positiveSum)
381
- : Math.max(maxNonGroupValue, 0);
382
- } else if (visibleSeries.length) {
383
- const visibleValue = visibleSeries
384
- .map(sId => selectedData[sId]?.value ?? selectedData[sId]);
385
-
386
- const maxValue = visibleValue.length > 0
387
- ? visibleValue.reduce((max, val) => Math.max(max, val ?? -Infinity), -Infinity)
388
- : -Infinity;
389
-
390
- value = maxValue > 0 || this.options.type !== 'bar'
391
- ? maxValue
392
- : 0;
393
- }
394
- }
395
-
396
- if (labelAxes.labels) {
397
- if (dataIndex[i] < startIndex || dataIndex[i] > endIndex) {
398
- return;
399
- }
400
-
401
- const labelIndex = dataIndex[i] - startIndex;
402
- const labelCenter = Math.round(labelStartPoint + (labelGap * labelIndex));
403
- labelPos = labelCenter + (labelGap / 2);
404
- } else {
405
- labelPos = labelPositionCalcFunction(
406
- label[i],
407
- graphX.graphMin,
408
- graphX.graphMax,
409
- chartWidth - sizeObj.comboOffset,
410
- aPos.x1 + (sizeObj.comboOffset / 2),
411
- );
412
- }
413
-
414
- dataPos = valuePositionCalcFunction(
415
- value,
416
- valueAxesSteps.graphMin,
417
- valueAxesSteps.graphMax,
418
- valueSpace,
419
- valueStartPoint,
420
- ) + offset;
421
-
422
- this.showTip({
423
- context: this.bufferCtx,
424
- x: isHorizontal ? dataPos : labelPos,
425
- y: isHorizontal ? labelPos : dataPos,
426
- opt: labelTipOpt,
427
- isSamePos: false,
428
- });
429
- });
430
- }
431
-
432
- return drawTip;
433
- },
434
-
435
- /**
436
- * Draw Selected Label Tip
437
- * @returns {boolean} Whether drew at least one tip
438
- */
439
- drawLabelTipForHeatMap() {
440
- const opt = this.options;
441
- const isHorizontal = !!opt.horizontal;
442
- const labelTipOpt = opt.selectLabel;
443
- const { dataIndex } = this.defaultSelectInfo;
444
- let drawTip = false;
445
-
446
- if (dataIndex) {
447
- drawTip = true;
448
-
449
- const chartRect = this.chartRect;
450
- const labelOffset = this.labelOffset;
451
- const aPos = {
452
- x1: chartRect.x1 + labelOffset.left,
453
- x2: chartRect.x2 - labelOffset.right,
454
- y1: chartRect.y1 + labelOffset.top,
455
- y2: chartRect.y2 - labelOffset.bottom,
456
- };
457
- const labelAxes = isHorizontal ? this.axesY[0] : this.axesX[0];
458
- const labelStartPoint = aPos[labelAxes.units.rectStart];
459
- const labelEndPoint = aPos[labelAxes.units.rectEnd];
460
- const labelGap = (labelEndPoint - labelStartPoint) / labelAxes.labels.length;
461
-
462
- const valueAxes = isHorizontal ? this.axesX[0] : this.axesY[0];
463
- const offset = 6 * (isHorizontal ? 1 : -1);
464
- const gp = aPos[valueAxes.units.rectEnd] + offset;
465
-
466
- dataIndex?.forEach((index) => {
467
- const labelCenter = Math.round(labelStartPoint + (labelGap * index));
468
- const dp = labelCenter + (labelGap / 2);
469
-
470
- this.showTip({
471
- context: this.bufferCtx,
472
- x: isHorizontal ? gp : dp,
473
- y: isHorizontal ? dp : gp,
474
- opt: labelTipOpt,
475
- isSamePos: false,
476
- });
477
- });
478
- }
479
-
480
- return drawTip;
481
- },
482
-
483
- /**
484
- * Calculate x, y position to draw text tip
485
- * @param {object} param object for drawing text tip
486
- *
487
- * @returns {undefined}
488
- */
489
- drawTextTip(param) {
490
- const isHorizontal = !!this.options.horizontal;
491
- const ctx = this.bufferCtx;
492
- const { graphX, graphY, xArea, yArea, xsp, xep, ysp } = param;
493
- const { dp, value, text, opt, type, tipType, isSamePos, seriesOpt } = param;
494
-
495
- const arrowSize = 4;
496
- const borderRadius = 4;
497
- const {
498
- fontSize,
499
- fontFamily,
500
- fontWeight,
501
- height: maxTipHeight,
502
- } = opt.tipStyle;
503
- const textStyle = `normal normal ${fontWeight} ${fontSize}px ${fontFamily}`;
504
-
505
- let offset = 1;
506
- if (type === 'line') {
507
- offset += 6;
508
- } else if (type === 'scatter') {
509
- offset += seriesOpt?.pointSize;
510
- } else if (type === 'bar') {
511
- offset += 4;
512
- }
513
-
514
- let gp;
515
- let tdp = dp;
516
-
517
- if (opt.fixedPosTop) {
518
- if (isHorizontal) {
519
- gp = Canvas.calculateX(graphX.graphMax, graphX.graphMin, graphX.graphMax, xArea, xsp);
520
- gp += offset;
521
- } else {
522
- gp = Canvas.calculateY(graphY.graphMax, graphY.graphMin, graphY.graphMax, yArea, ysp);
523
- gp -= offset;
524
- }
525
- } else if (isHorizontal) {
526
- gp = Canvas.calculateX(value, graphX.graphMin, graphX.graphMax, xArea, xsp);
527
- gp = value < 0 ? gp - offset : gp + offset;
528
- } else {
529
- const adjustedValue = type === 'bar' && value < 0 ? 0 : value;
530
- gp = Canvas.calculateY(adjustedValue, graphY.graphMin, graphY.graphMax, yArea, ysp);
531
- gp = adjustedValue < 0 ? gp + offset : gp - offset;
532
- }
533
-
534
- let maxTipType = 'center';
535
-
536
- ctx.save();
537
- ctx.font = textStyle;
538
- const maxTipWidth = Math.round(Math.max(ctx.measureText(text).width + 12, 40));
539
-
540
- if (!isHorizontal) {
541
- if (dp + (maxTipWidth / 2) > xep - 10) {
542
- maxTipType = 'right';
543
- tdp -= (maxTipWidth / 2) - (arrowSize * 2);
544
- } else if (dp - (maxTipWidth / 2) < xsp + 10) {
545
- maxTipType = 'left';
546
- tdp += (maxTipWidth / 2) - (arrowSize * 2);
547
- }
548
- }
549
-
550
- ctx.restore();
551
-
552
- if (opt.showTextTip || tipType === 'max') {
553
- this.showTextTip({
554
- context: ctx,
555
- type: maxTipType,
556
- width: maxTipWidth,
557
- height: maxTipHeight,
558
- x: isHorizontal ? gp + (maxTipWidth / 2) : tdp,
559
- y: isHorizontal ? tdp + (maxTipHeight / 2) : gp,
560
- opt,
561
- arrowSize,
562
- borderRadius,
563
- text,
564
- textStyle,
565
- isNegative: value < 0,
566
- });
567
- }
568
-
569
- if (opt.showTip && tipType === 'sel') {
570
- this.showTip({
571
- context: ctx,
572
- x: isHorizontal ? gp : dp,
573
- y: isHorizontal ? dp : gp,
574
- opt,
575
- isSamePos,
576
- });
577
- }
578
- },
579
-
580
- /**
581
- * Draw text tip
582
- * @param {object} param object for drawing text tip
583
- *
584
- * @returns {undefined}
585
- */
586
- showTextTip(param) {
587
- const isHorizontal = !!this.options.horizontal;
588
- const {
589
- type, width, height, x, y, arrowSize, borderRadius, text, opt, textStyle, isNegative,
590
- } = param;
591
-
592
- const ctx = param.context;
593
-
594
- let sx = x - (width / 2);
595
- let ex = x + (width / 2);
596
- const sy = y - height;
597
- const ey = y;
598
-
599
- if (isNegative) {
600
- if (isHorizontal) {
601
- sx = x - (width / 2) - width;
602
- ex = x - (width / 2);
603
- }
604
- }
605
-
606
- ctx.save();
607
- ctx.font = textStyle;
608
-
609
- ctx.fillStyle = opt.tipBackground ?? opt.tipStyle.background;
610
- ctx.shadowBlur = 0;
611
-
612
- ctx.beginPath();
613
- ctx.moveTo(sx + borderRadius, sy);
614
- ctx.quadraticCurveTo(sx, sy, sx, sy + borderRadius);
615
- ctx.lineTo(sx, ey - borderRadius);
616
- ctx.quadraticCurveTo(sx, ey, sx + borderRadius, ey);
617
- ctx.lineTo(ex - borderRadius, ey);
618
- ctx.quadraticCurveTo(ex, ey, ex, ey - borderRadius);
619
- ctx.lineTo(ex, sy + borderRadius);
620
- ctx.quadraticCurveTo(ex, sy, ex - borderRadius, sy);
621
- ctx.lineTo(sx + borderRadius, sy);
622
- ctx.closePath();
623
- ctx.fill();
624
-
625
- // draw arrow
626
- ctx.beginPath();
627
- if (isHorizontal) {
628
- if (isNegative) {
629
- ctx.moveTo(ex, ey);
630
- ctx.lineTo(ex, sy + borderRadius + (arrowSize / 2));
631
- ctx.lineTo(ex + arrowSize, ey - (height / 2));
632
- ctx.lineTo(ex, ey - borderRadius - (arrowSize / 2));
633
- } else {
634
- ctx.moveTo(sx, sy);
635
- ctx.lineTo(sx, sy + borderRadius + (arrowSize / 2));
636
- ctx.lineTo(sx - arrowSize, ey - (height / 2));
637
- ctx.lineTo(sx, ey - borderRadius - (arrowSize / 2));
638
- }
639
-
640
- ctx.closePath();
641
- ctx.fill();
642
- } else {
643
- if (isNegative) {
644
- if (type === 'left') {
645
- ctx.lineTo(sx + borderRadius + arrowSize, ey + arrowSize);
646
- ctx.lineTo(sx + borderRadius + (arrowSize * 2), ey);
647
- } else if (type === 'right') {
648
- ctx.lineTo(ex - (arrowSize * 2) - borderRadius, ey);
649
- ctx.lineTo(ex - arrowSize - borderRadius, ey + arrowSize);
650
- } else {
651
- ctx.lineTo(x - arrowSize, ey);
652
- ctx.lineTo(x, ey + arrowSize);
653
- ctx.lineTo(x + arrowSize, ey);
654
- }
655
- } else if (!isNegative) {
656
- if (type === 'left') {
657
- ctx.moveTo(sx, sy);
658
- ctx.lineTo(sx + borderRadius + arrowSize, ey + arrowSize);
659
- ctx.lineTo(sx + borderRadius + (arrowSize * 2), ey);
660
- } else if (type === 'right') {
661
- ctx.moveTo(ex, sy);
662
- ctx.lineTo(ex - (arrowSize * 2) - borderRadius, ey);
663
- ctx.lineTo(ex - arrowSize - borderRadius, ey + arrowSize);
664
- } else {
665
- ctx.lineTo(x - arrowSize, ey);
666
- ctx.lineTo(x, ey + arrowSize);
667
- ctx.lineTo(x + arrowSize, ey);
668
- }
669
- }
670
-
671
- ctx.closePath();
672
- ctx.fill();
673
- }
674
-
675
- ctx.restore();
676
- ctx.save();
677
- ctx.font = textStyle;
678
- ctx.fillStyle = opt.tipTextColor ?? opt.tipStyle.textColor;
679
- ctx.textBaseline = 'middle';
680
- ctx.textAlign = 'center';
681
- ctx.fillText(`${text}`, sx + (width / 2), sy + (height / 2));
682
- ctx.restore();
683
- },
684
-
685
- /**
686
- * Draw arrow tip
687
- * @param {object} param object for drawing arrow tip
688
- *
689
- * @returns {undefined}
690
- */
691
- showTip(param) {
692
- const isHorizontal = !!this.options.horizontal;
693
- const { x, y, opt, isSamePos } = param;
694
- const ctx = param.context;
695
- const offset = isSamePos ? 24 : 0;
696
- const cy = y - offset;
697
- ctx.save();
698
-
699
- ctx.fillStyle = opt.tipBackground ?? opt.tipStyle.background;
700
- ctx.beginPath();
701
- ctx.moveTo(x, cy);
702
- if (isHorizontal) {
703
- ctx.lineTo(x + 6, cy - 6);
704
- ctx.lineTo(x + 6, cy + 6);
705
- } else {
706
- ctx.lineTo(x + 6, cy - 6);
707
- ctx.lineTo(x - 6, cy - 6);
708
- }
709
- ctx.lineTo(x, cy);
710
- ctx.closePath();
711
- ctx.fill();
712
-
713
- ctx.restore();
714
- },
715
- };
716
-
717
- export default modules;