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.
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 -63678
  9. package/dist/evui.common.js.map +0 -1
  10. package/dist/evui.umd.js +0 -63688
  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 -1655
  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,743 +0,0 @@
1
- import { merge } from 'lodash-es';
2
- import { convertToPercent, truthy, truthyNumber, checkNullAndUndefined } from '@/common/utils';
3
- import Util from '../helpers/helpers.util';
4
- import { HEAT_MAP_OPTION } from '../helpers/helpers.constant';
5
-
6
- class HeatMap {
7
- constructor(sId, opt, colorOpt, isHorizontal, isGradient) {
8
- const merged = merge({}, HEAT_MAP_OPTION, opt);
9
-
10
- Object.keys(merged).forEach((key) => {
11
- this[key] = merged[key];
12
- });
13
-
14
- this.isHorizontal = isHorizontal;
15
- this.isGradient = isGradient;
16
- this.createColorState(colorOpt);
17
-
18
- this.sId = sId;
19
- this.data = [];
20
- this.labels = {
21
- x: [],
22
- y: [],
23
- };
24
- this.valueOpt = {};
25
- this.size = {
26
- w: 0,
27
- h: 0,
28
- };
29
- this.type = 'heatMap';
30
-
31
- this.currentLabelInfo = {
32
- x: {
33
- steps: 0,
34
- min: 0,
35
- max: 0,
36
- },
37
- y: {
38
- steps: 0,
39
- min: 0,
40
- max: 0,
41
- },
42
- };
43
- }
44
-
45
- /**
46
- * create series color axis
47
- * @param colorOpt
48
- * @returns {*[]}
49
- */
50
- createColorState(colorOpt) {
51
- const colorState = [];
52
- const regex = /[^0-9]&[^,]/g;
53
- const { min, max, rangeCount, colorsByRange, error, stroke } = colorOpt;
54
-
55
- const minColor = min.includes('#') ? Util.hexToRgb(min) : min.replace(regex, '');
56
- const maxColor = max.includes('#') ? Util.hexToRgb(max) : max.replace(regex, '');
57
-
58
- const [minR, minG, minB] = minColor.split(',');
59
- const [maxR, maxG, maxB] = maxColor.split(',');
60
-
61
- if (this.isGradient) {
62
- colorState.push({
63
- minColor: { minR, minG, minB },
64
- maxColor: { maxR, maxG, maxB },
65
- rangeCount,
66
- start: 0,
67
- end: 100,
68
- selectedValue: null,
69
- });
70
- } else if (colorsByRange.length) {
71
- colorsByRange.forEach(({ color, label }, ix) => {
72
- colorState.push({
73
- id: `color#${ix}`,
74
- color,
75
- label,
76
- state: 'normal',
77
- show: true,
78
- });
79
- });
80
- } else {
81
- const unitR = Math.floor((minR - maxR) / (rangeCount - 1));
82
- const unitG = Math.floor((minG - maxG) / (rangeCount - 1));
83
- const unitB = Math.floor((minB - maxB) / (rangeCount - 1));
84
-
85
- for (let ix = 0; ix < rangeCount; ix++) {
86
- const r = +minR - (unitR * ix);
87
- const g = +minG - (unitG * ix);
88
- const b = +minB - (unitB * ix);
89
-
90
- colorState.push({
91
- id: `color#${ix}`,
92
- color: `rgb(${r},${g},${b})`,
93
- state: 'normal',
94
- show: true,
95
- });
96
- }
97
- }
98
-
99
- this.colorState = colorState;
100
- this.errorColor = error;
101
- this.stroke = stroke;
102
- }
103
-
104
- getColorForGradient(value) {
105
- const { minColor, maxColor } = this.colorState[0];
106
-
107
- const { minR, minG, minB } = minColor;
108
- const { maxR, maxG, maxB } = maxColor;
109
-
110
- const r = +minR - Math.floor(((minR - maxR) * value) / 100);
111
- const g = +minG - Math.floor(((minG - maxG) * value) / 100);
112
- const b = +minB - Math.floor(((minB - maxB) * value) / 100);
113
-
114
- return `rgb(${r},${g},${b})`;
115
- }
116
-
117
- getColorIndexByValue(value) {
118
- const { existError, min, interval, decimalPoint } = this.valueOpt;
119
- const maxIndex = this.colorState.length - 1;
120
- if (existError && value < 0) {
121
- return maxIndex;
122
- }
123
-
124
- const colorIndex = Math.floor(+(value - min).toFixed(decimalPoint) / interval);
125
-
126
- if (colorIndex >= maxIndex) {
127
- return existError ? maxIndex - 1 : maxIndex;
128
- }
129
-
130
- return colorIndex;
131
- }
132
-
133
- getItemInfo(value) {
134
- const { min, max } = this.valueOpt;
135
- const itemInfo = {
136
- show: false,
137
- opacity: 1,
138
- dataColor: null,
139
- id: null,
140
- isHighlight: null,
141
- };
142
- if (this.isGradient) {
143
- const ratio = convertToPercent(value - min, max - min);
144
- const { start, end, selectedValue } = this.colorState[0];
145
- if (value < 0 || (start <= ratio && ratio <= end)) {
146
- itemInfo.show = true;
147
- itemInfo.isHighlight = selectedValue !== null
148
- && (Math.floor(value) === Math.floor(min + ((max - min) * (selectedValue / 100))));
149
- itemInfo.dataColor = value < 0
150
- ? this.errorColor : this.getColorForGradient(ratio);
151
- }
152
- } else {
153
- const colorIndex = this.getColorIndexByValue(value);
154
- const { show, state, color, id } = this.colorState[colorIndex];
155
- itemInfo.show = show;
156
- itemInfo.opacity = state === 'downplay' ? 0.1 : 1;
157
- itemInfo.dataColor = value < 0 ? this.errorColor : color;
158
- itemInfo.id = id;
159
- }
160
- return itemInfo;
161
- }
162
-
163
- drawItem(ctx, x, y, w, h, borderOpt) {
164
- ctx.beginPath();
165
-
166
- if (w < 0 || h < 0) {
167
- return;
168
- }
169
-
170
- if (borderOpt.show) {
171
- const { radius } = borderOpt;
172
- if (radius > 0) {
173
- const minSize = Math.min(w, h);
174
- let r = radius;
175
- if (r > (minSize / 2)) {
176
- r = Math.floor(minSize / 2);
177
- }
178
- ctx.moveTo(x + r, y);
179
- ctx.arcTo(x + w, y, x + w, y + h, r);
180
- ctx.arcTo(x + w, y + h, x, y + h, r);
181
- ctx.arcTo(x, y + h, x, y, r);
182
- ctx.arcTo(x, y, x + w, y, r);
183
- ctx.stroke();
184
- ctx.fill();
185
- } else {
186
- ctx.strokeRect(x, y, w, h);
187
- ctx.fillRect(x, y, w, h);
188
- }
189
- } else {
190
- const aliasPixel = Util.aliasPixel(1);
191
- ctx.fillRect(
192
- x,
193
- y - aliasPixel,
194
- w + aliasPixel,
195
- h + aliasPixel,
196
- );
197
- }
198
- ctx.closePath();
199
- }
200
-
201
- calculateXY(dir, value, startPoint, minMax) {
202
- let point = null;
203
-
204
- if (this.labels[dir] && this.labels[dir].length) {
205
- let index = this.labels[dir].findIndex(label => label === value);
206
-
207
- if (index === -1) {
208
- index = this.labels[dir].findIndex(label => +label === +value);
209
- }
210
-
211
- const { minIndex, maxIndex, graphMin, graphMax } = minMax;
212
- if (truthyNumber(maxIndex) && index > maxIndex) {
213
- return null;
214
- }
215
-
216
- if (truthyNumber(minIndex) && index < minIndex) {
217
- return null;
218
- }
219
-
220
- if (checkNullAndUndefined(minIndex) && checkNullAndUndefined(maxIndex)) {
221
- if (value < graphMin || value > graphMax) {
222
- return null;
223
- }
224
- }
225
-
226
- const startIndex = minIndex ?? this.labels[dir].findIndex(label => +label === +graphMin);
227
-
228
- if (index > -1) {
229
- index -= (startIndex > -1 ? startIndex : 0);
230
- point = dir === 'x'
231
- ? startPoint + (this.size.w * index)
232
- : startPoint - (this.size.h * (index + 1));
233
- }
234
- }
235
-
236
- return point;
237
- }
238
-
239
- draw(param) {
240
- if (!this.show) {
241
- return;
242
- }
243
-
244
- const {
245
- ctx,
246
- chartRect,
247
- labelOffset,
248
- overlayCtx,
249
- selectLabel,
250
- legendHitInfo,
251
- selectItem,
252
- axesSteps,
253
- } = param;
254
-
255
- const xArea = chartRect.chartWidth - (labelOffset.left + labelOffset.right);
256
- const yArea = chartRect.chartHeight - (labelOffset.top + labelOffset.bottom);
257
-
258
- const xsp = chartRect.x1 + labelOffset.left;
259
- const ysp = chartRect.y2 - labelOffset.bottom;
260
-
261
- const minmaxX = axesSteps.x[this.xAxisIndex];
262
- const minmaxY = axesSteps.y[this.yAxisIndex];
263
-
264
- this.size.w = xArea / minmaxX.oriSteps;
265
- this.size.h = yArea / minmaxY.oriSteps;
266
-
267
- this.currentLabelInfo = {
268
- x: {
269
- steps: minmaxX.oriSteps,
270
- min: minmaxX.graphMin,
271
- max: minmaxX.graphMax,
272
- },
273
- y: {
274
- steps: minmaxY.oriSteps,
275
- min: minmaxY.graphMin,
276
- max: minmaxY.graphMax,
277
- },
278
- };
279
-
280
- const getOpacity = (item, opacity, index) => {
281
- if (!legendHitInfo) {
282
- let isDownplay;
283
- const {
284
- option: selectedItemOpt,
285
- selected: selectedItem,
286
- } = selectItem;
287
-
288
- const {
289
- option: selectedLabelOpt,
290
- selected: selectedLabel,
291
- } = selectLabel;
292
-
293
- const isSelectedItem = truthy(selectedItem?.dataIndex) && selectedItem?.dataIndex > -1;
294
- const isSelectedLabel = selectedLabel?.label?.length > 0;
295
- if (isSelectedItem) {
296
- isDownplay = selectedItemOpt.useSeriesOpacity
297
- ? index !== selectedItem?.dataIndex
298
- : false;
299
- } else if (isSelectedLabel) {
300
- isDownplay = selectedLabelOpt.useSeriesOpacity
301
- ? !selectedLabel?.label?.includes(this.getItemLabel(selectLabel, item))
302
- : false;
303
- }
304
-
305
- return isDownplay ? 0.1 : opacity;
306
- }
307
-
308
- return opacity;
309
- };
310
-
311
- this.data.forEach((item, index) => {
312
- const axisLineWidth = 1;
313
- let xp = this.calculateXY('x', item.x, xsp, minmaxX);
314
- let yp = this.calculateXY('y', item.y, ysp, minmaxY);
315
- let w = this.size.w;
316
- let h = this.size.h;
317
-
318
- const value = item.o;
319
-
320
- if (xp !== null && yp !== null
321
- && (value !== null && value !== undefined)) {
322
- const {
323
- show,
324
- opacity,
325
- dataColor,
326
- id,
327
- isHighlight,
328
- } = this.getItemInfo(value);
329
-
330
- let originalOpacity = opacity;
331
- if (opacity === 1 && Util.getColorStringType(item.dataColor) === 'RGBA') {
332
- originalOpacity = Util.getOpacity(item.dataColor);
333
- }
334
-
335
- const itemOpacity = getOpacity(item, originalOpacity, index);
336
-
337
- if (!item.dataColor) {
338
- item.dataColor = dataColor;
339
- }
340
-
341
- item.cId = id;
342
- ctx.save();
343
-
344
- if (show) {
345
- ctx.fillStyle = Util.colorStringToRgba(item.dataColor, itemOpacity);
346
-
347
- let borderOpt = this.stroke;
348
- const selectItemOption = selectItem?.option;
349
- const useSelectItem = selectItemOption?.use && selectItemOption?.showBorder;
350
- const isHit = (index === selectItem?.selected?.dataIndex);
351
- if (useSelectItem && isHit) {
352
- borderOpt = {
353
- show: selectItemOption?.showBorder,
354
- ...selectItemOption?.borderStyle,
355
- };
356
- }
357
-
358
- if (borderOpt.show) {
359
- const { color, lineWidth, opacity: borderOpacity } = borderOpt;
360
- ctx.strokeStyle = Util.colorStringToRgba(
361
- color,
362
- itemOpacity === 1 ? borderOpacity : itemOpacity,
363
- );
364
-
365
- // item 사이즈 보다 border 선 굵기가 큰 경우 lineWidth props 무시
366
- if (lineWidth < w && lineWidth < h) {
367
- ctx.lineWidth = lineWidth;
368
- xp += (lineWidth * 0.5);
369
- yp += (lineWidth * 0.5);
370
- w -= (lineWidth);
371
- h -= (lineWidth);
372
- }
373
- }
374
-
375
- xp += axisLineWidth;
376
-
377
- item.xp = xp;
378
- item.yp = yp;
379
- item.w = w;
380
- item.h = h;
381
-
382
- this.drawItem(ctx, xp, yp, w, h, borderOpt);
383
- ctx.restore();
384
-
385
- if (this.showValue.use) {
386
- this.drawValueLabels({
387
- context: ctx,
388
- data: item,
389
- });
390
- }
391
- if (isHighlight) {
392
- this.itemHighlight({
393
- data: item,
394
- }, overlayCtx);
395
- }
396
- }
397
- }
398
- });
399
- }
400
-
401
- /**
402
- * Draw value label if series 'use' of showValue option is true
403
- *
404
- * @param context canvas context
405
- * @param data series value data (model.store.js addData return value)
406
- */
407
- drawValueLabels({ context, data }) {
408
- const { fontSize, textColor, align, formatter, decimalPoint } = this.showValue;
409
- const { xp: x, yp: y, w, h, o: value } = data;
410
- const ctx = context;
411
-
412
- ctx.save();
413
- ctx.beginPath();
414
-
415
- ctx.font = `normal normal normal ${fontSize}px Roboto`;
416
- ctx.fillStyle = textColor;
417
- ctx.lineWidth = 1;
418
- ctx.textBaseline = 'middle';
419
- ctx.textAlign = align !== 'center' ? 'left' : 'center';
420
-
421
- let formattedTxt;
422
- if (formatter) {
423
- formattedTxt = formatter(value);
424
- }
425
-
426
- if (!formatter || typeof formattedTxt !== 'string') {
427
- formattedTxt = Util.labelSignFormat(value, decimalPoint);
428
- }
429
-
430
- const vw = Math.round(ctx.measureText(formattedTxt).width);
431
- const vh = fontSize;
432
- const centerX = x + (w / 2);
433
- const centerY = y + (h / 2);
434
-
435
- if (vw >= w || vh >= h || formattedTxt < 0) {
436
- return;
437
- }
438
-
439
- switch (align) {
440
- case 'top': {
441
- const xPos = centerX - (vw / 2);
442
- const yPos = centerY - (vh / 2);
443
- ctx.fillText(formattedTxt, xPos, yPos);
444
- break;
445
- }
446
- case 'right': {
447
- const xPos = x + w - vw;
448
- ctx.fillText(formattedTxt, xPos, centerY);
449
- break;
450
- }
451
- case 'bottom': {
452
- const xPos = centerX - (vw / 2);
453
- const yPos = centerY + (vh / 2);
454
- ctx.fillText(formattedTxt, xPos, yPos);
455
- break;
456
- }
457
- case 'left':
458
- ctx.fillText(formattedTxt, x, centerY);
459
- break;
460
- default: {
461
- const xPos = centerX - (vw / 2);
462
- ctx.fillText(formattedTxt, xPos, centerY);
463
- break;
464
- }
465
- }
466
-
467
- ctx.restore();
468
- }
469
-
470
- /**
471
- *Returns items in range
472
- * @param {object} params range values
473
- *
474
- * @returns {array}
475
- */
476
- findItems({ xsp, ysp, width, height }) {
477
- const gdata = this.data;
478
- const xep = xsp + width;
479
- const yep = ysp + height;
480
- return gdata.filter(({ xp, yp, w, h }) => {
481
- const x1 = xp;
482
- const x2 = xp + w;
483
- const y1 = yp;
484
- const y2 = yp + h;
485
-
486
- return ((x1 >= xsp && x2 <= xep) && (y1 >= ysp && y2 <= yep));
487
- });
488
- }
489
-
490
- /**
491
- * Draw item highlight
492
- * @param {object} item object for drawing series data
493
- * @param {object} context canvas context
494
- *
495
- * @returns {undefined}
496
- */
497
- itemHighlight(item, context) {
498
- const gdata = item.data;
499
- const ctx = context;
500
- const { stroke: strokeOpt, shadow: shadowOpt } = this.highlight;
501
-
502
- const x = gdata.xp;
503
- const y = gdata.yp;
504
- const w = gdata.w;
505
- const h = gdata.h;
506
- const cId = gdata.cId;
507
-
508
- let isShow;
509
- if (this.isGradient) {
510
- const { min, max } = this.valueOpt;
511
- const ratio = convertToPercent(gdata.o - min, max - min);
512
- const { start, end } = this.colorState[0];
513
- isShow = (start <= ratio && ratio <= end) || gdata.o === -1;
514
- } else {
515
- isShow = this.colorState.find(({ id }) => id === cId)?.show;
516
- }
517
-
518
- if (x === null || y === null || !isShow) {
519
- return;
520
- }
521
-
522
- ctx.save();
523
-
524
- const dataColor = Util.getColorStringType(gdata.dataColor) === 'RGBA'
525
- ? item.dataColor
526
- : Util.colorStringToRgba(gdata.dataColor, 1);
527
-
528
- ctx.fillStyle = dataColor;
529
-
530
- if (shadowOpt.use) {
531
- ctx.shadowOffsetX = shadowOpt.offsetX;
532
- ctx.shadowOffsetY = shadowOpt.offsetY;
533
- ctx.shadowBlur = shadowOpt.blur;
534
- ctx.shadowColor = shadowOpt.color;
535
- }
536
-
537
- const borderOpt = {
538
- color: '',
539
- lineWidth: 1,
540
- opacity: 1,
541
- radius: 0,
542
- show: true,
543
- };
544
-
545
- if (strokeOpt.use) {
546
- const { color, width, radius } = strokeOpt;
547
- borderOpt.show = true;
548
- borderOpt.radius = radius;
549
-
550
- ctx.lineWidth = width;
551
- borderOpt.lineWidth = width;
552
-
553
- ctx.strokeStyle = color || dataColor;
554
- borderOpt.color = color || dataColor;
555
- } else {
556
- borderOpt.show = false;
557
- ctx.strokeStyle = dataColor;
558
- borderOpt.color = dataColor;
559
- }
560
-
561
- this.drawItem(ctx, x - 0.5, y - 0.5, w + 1, h + 1, borderOpt);
562
-
563
- ctx.restore();
564
-
565
- if (this.showValue.use) {
566
- this.drawValueLabels({
567
- context: ctx,
568
- data: gdata,
569
- });
570
- }
571
- }
572
-
573
- /**
574
- * Find graph item for tooltip
575
- * @param {array} offset mouse position
576
- *
577
- * @returns {object} graph item
578
- */
579
- findGraphData(offset) {
580
- const xp = offset[0];
581
- const yp = offset[1];
582
- const item = {
583
- data: null,
584
- hit: false,
585
- color: null,
586
- dataColor: null,
587
- name: null,
588
- };
589
- const gdata = this.data;
590
-
591
- const itemIndex = gdata.findIndex((data) => {
592
- const { xp: x, yp: y, w: wSize, h: hSize } = data;
593
-
594
- return (x <= xp)
595
- && (xp <= x + wSize)
596
- && (y <= yp)
597
- && (yp <= y + hSize);
598
- });
599
-
600
- if (itemIndex > -1) {
601
- const foundItem = gdata[itemIndex];
602
- item.data = foundItem;
603
- item.color = foundItem.dataColor;
604
- item.dataColor = foundItem.dataColor;
605
- item.index = itemIndex;
606
- item.hit = true;
607
- }
608
-
609
- return item;
610
- }
611
-
612
- findBlockRange({ xcp, xep, ycp, yep, range }) {
613
- const labels = this.labels;
614
- const axesLineWidth = 1;
615
-
616
- const blockRange = {
617
- xsp: Math.min(xcp, xep),
618
- ysp: Math.min(ycp, yep),
619
- width: Math.ceil(Math.abs(xep - xcp)),
620
- height: Math.ceil(Math.abs(yep - ycp)),
621
- };
622
-
623
- if (labels.x.length && labels.y.length) {
624
- const labelXCount = this.currentLabelInfo.x.steps || labels.x.length;
625
- const labelYCount = this.currentLabelInfo.y.steps || labels.y.length;
626
-
627
- const { x1, x2, y1, y2 } = range;
628
- const gapX = (x2 - x1) / labelXCount;
629
- const gapY = (y2 - y1) / labelYCount;
630
-
631
- const point = {
632
- xsp: xcp,
633
- xep,
634
- ysp: ycp,
635
- yep,
636
- };
637
-
638
- const setPoint = (dir, target, key) => {
639
- let itemPoint;
640
- let gap;
641
- let startPoint;
642
-
643
- if (dir === 'x') {
644
- gap = gapX;
645
- startPoint = x1 + axesLineWidth;
646
- } else {
647
- gap = gapY;
648
- startPoint = y1;
649
- }
650
-
651
- const findItem = labels[dir].findIndex((item, index) => {
652
- itemPoint = startPoint + (gap * index);
653
- return itemPoint <= target && target <= itemPoint + gap;
654
- });
655
-
656
- if (findItem > -1) {
657
- point[key] = ['xsp', 'ysp'].includes(key) ? itemPoint : itemPoint + gap;
658
- }
659
- };
660
-
661
- setPoint('x', Math.min(xcp, xep), 'xsp');
662
- setPoint('x', Math.max(xcp, xep), 'xep');
663
- setPoint('y', Math.min(ycp, yep), 'ysp');
664
- setPoint('y', Math.max(ycp, yep), 'yep');
665
-
666
- blockRange.xsp = Math.min(point.xsp, point.xep);
667
- blockRange.ysp = Math.min(point.ysp, point.yep);
668
- blockRange.width = Math.abs(point.xep - point.xsp);
669
- blockRange.height = Math.abs(point.yep - point.ysp);
670
- }
671
-
672
- return blockRange;
673
- }
674
-
675
- getFilteredLabel(labels, count, min, max) {
676
- return labels.length !== count
677
- ? labels.filter(label => min <= label && label <= max)
678
- : labels;
679
- }
680
-
681
- findSelectionRange(rangeInfo) {
682
- const { xsp, ysp, width, height, range } = rangeInfo;
683
-
684
- let selectionRange = null;
685
-
686
- const { x1, x2, y1, y2 } = range;
687
- const { x: labelX, y: labelY } = this.labels;
688
-
689
- if (labelX.length && labelY.length) {
690
- const {
691
- x: { steps: xCurrentCount, min: xMin, max: xMax },
692
- y: { steps: yCurrentCount, min: yMin, max: yMax },
693
- } = this.currentLabelInfo;
694
-
695
- const labelXCount = xCurrentCount || labelX.length;
696
- const labelYCount = yCurrentCount || labelY.length;
697
- const gapX = (x2 - x1) / labelXCount;
698
- const gapY = (y2 - y1) / labelYCount;
699
-
700
- const xep = xsp + width;
701
- const yep = ysp + height;
702
-
703
- const xIndex = {
704
- min: Math.floor((xsp - x1) / gapX),
705
- max: Math.floor((xep - x1 - gapX) / gapX),
706
- };
707
-
708
- const lastIndexY = labelYCount - 1;
709
- const yIndex = {
710
- min: lastIndexY - Math.round((yep - y1 - gapY) / gapY),
711
- max: lastIndexY - Math.round((ysp - y1) / gapY),
712
- };
713
-
714
- const filteredLabelX = this.getFilteredLabel(labelX, labelXCount, xMin, xMax);
715
- const filteredLabelY = this.getFilteredLabel(labelY, labelYCount, yMin, yMax);
716
-
717
- selectionRange = {
718
- xMin: filteredLabelX[xIndex.min],
719
- xMax: filteredLabelX[xIndex.max],
720
- yMin: filteredLabelY[yIndex.min],
721
- yMax: filteredLabelY[yIndex.max],
722
- };
723
- }
724
-
725
- return selectionRange;
726
- }
727
-
728
- getItemLabel(selectLabel, item) {
729
- const {
730
- option: selectedLabelOpt,
731
- selected: selectedLabel,
732
- } = selectLabel;
733
-
734
- let targetLabel = this.isHorizontal ? item.y : item.x;
735
- if (selectedLabelOpt?.useBothAxis && selectedLabel?.targetAxis) {
736
- targetLabel = selectedLabel?.targetAxis === 'yAxis' ? item.y : item.x;
737
- }
738
-
739
- return targetLabel;
740
- }
741
- }
742
-
743
- export default HeatMap;