evui 3.3.40 → 3.3.42

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evui",
3
- "version": "3.3.40",
3
+ "version": "3.3.42",
4
4
  "description": "A EXEM Library project",
5
5
  "author": "exem <dev_client@ex-em.com>",
6
6
  "license": "MIT",
@@ -78,7 +78,7 @@
78
78
  const injectIsChartGroup = inject('isChartGroup', false);
79
79
  const injectBrushSeries = inject('brushSeries', { list: [], chartIdx: null });
80
80
  const injectGroupSelectedLabel = inject('groupSelectedLabel', null);
81
- const injectBrushIdx = inject('brushIdx', { start: 0, end: 0 });
81
+ const injectBrushIdx = inject('brushIdx', { start: 0, end: -1 });
82
82
 
83
83
  const {
84
84
  eventListeners,
@@ -707,6 +707,8 @@ class EvChart {
707
707
  if (options.title.show) {
708
708
  if (!this.isInitTitle) {
709
709
  this.initTitle();
710
+ } else {
711
+ this.updateTitle();
710
712
  }
711
713
 
712
714
  this.showTitle();
@@ -438,7 +438,7 @@ export default class EvChartZoom {
438
438
  }
439
439
  };
440
440
 
441
- if (isUseZoomMode) {
441
+ if (isUseZoomMode && this.dragZoomIcon.classList.contains('active')) {
442
442
  const { previous, latest } = this.zoomAreaMemory;
443
443
 
444
444
  toggleIconStyle(this.previousIcon, previous.length);
@@ -246,12 +246,14 @@ class Line {
246
246
  let s = 0;
247
247
  let e = gdata.length - 1;
248
248
 
249
+ const xpInterval = gdata[1].xp - gdata[0].xp < 6 ? 1.5 : 6;
250
+
249
251
  while (s <= e) {
250
252
  const m = Math.floor((s + e) / 2);
251
253
  const x = gdata[m].xp;
252
254
  const y = gdata[m].yp;
253
255
 
254
- if ((x - 6 <= xp) && (xp <= x + 6)) {
256
+ if ((x - xpInterval < xp) && (xp < x + xpInterval)) {
255
257
  item.data = gdata[m];
256
258
  item.index = m;
257
259
 
@@ -259,10 +261,10 @@ class Line {
259
261
  item.hit = true;
260
262
  }
261
263
  return item;
262
- } else if (x + 6 < xp) {
263
- s = m + 1;
264
- } else {
264
+ } else if (x + xpInterval > xp) {
265
265
  e = m - 1;
266
+ } else {
267
+ s = m + 1;
266
268
  }
267
269
  }
268
270
 
@@ -20,14 +20,7 @@ const modules = {
20
20
  this.createTitle();
21
21
  }
22
22
 
23
- const opt = this.options.title;
24
- Object.keys(opt.style).forEach((key) => {
25
- this.titleDOM.style[key] = opt.style[key];
26
- });
27
-
28
- this.titleDOM.textContent = opt.text;
29
- this.titleDOM.style.height = `${opt.height}px`;
30
- this.titleDOM.style.lineHeight = `${opt.height}px`;
23
+ this.updateTitle();
31
24
 
32
25
  this.isInitTitle = true;
33
26
  },
@@ -51,6 +44,18 @@ const modules = {
51
44
  this.titleDOM.style.display = 'none';
52
45
  this.wrapperDOM.style.paddingTop = '0px';
53
46
  },
47
+
48
+ updateTitle() {
49
+ const opt = this.options.title;
50
+
51
+ Object.keys(opt.style).forEach((key) => {
52
+ this.titleDOM.style[key] = opt.style[key];
53
+ });
54
+
55
+ this.titleDOM.textContent = opt.text;
56
+ this.titleDOM.style.height = `${opt.height}px`;
57
+ this.titleDOM.style.lineHeight = `${opt.height}px`;
58
+ },
54
59
  };
55
60
 
56
61
  export default modules;
@@ -311,7 +311,7 @@ class Scale {
311
311
 
312
312
  if (this.type === 'x') {
313
313
  labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
314
- if (options?.brush?.showLabel || !options.brush) {
314
+ if (options?.brush?.showLabel || !options?.brush) {
315
315
  ctx.fillText(labelText, labelCenter, labelPoint);
316
316
  }
317
317
 
@@ -344,7 +344,7 @@ class Scale {
344
344
  }
345
345
  } else {
346
346
  labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
347
- if (options?.brush?.showLabel || !options.brush) {
347
+ if (options?.brush?.showLabel || !options?.brush) {
348
348
  ctx.fillText(labelText, labelPoint, labelCenter);
349
349
  }
350
350
 
@@ -232,7 +232,7 @@ export const useModel = (selectedLabel) => {
232
232
  left: 2,
233
233
  bottom: 4,
234
234
  };
235
- }
235
+ }
236
236
 
237
237
  return normalizedOptions;
238
238
  };
@@ -308,7 +308,6 @@ export const useWrapper = (options) => {
308
308
  };
309
309
  };
310
310
 
311
-
312
311
  export const useZoomModel = (
313
312
  evChartNormalizedOptions,
314
313
  { wrapper: evChartWrapper, evChartGroupRef },
@@ -323,7 +322,7 @@ export const useZoomModel = (
323
322
  const evChartZoomOptions = reactive({ zoom: evChartNormalizedOptions.zoom });
324
323
  const brushIdx = reactive({
325
324
  start: 0,
326
- end: 0,
325
+ end: -1,
327
326
  isUseButton: false,
328
327
  isUseScroll: false,
329
328
  });
@@ -337,6 +336,7 @@ export const useZoomModel = (
337
336
  },
338
337
  });
339
338
  const evChartClone = reactive({ data: null, options: null });
339
+ const brushChartIdx = ref([]);
340
340
 
341
341
  const getRangeInfo = (zoomInfo) => {
342
342
  if (zoomInfo.data.length && zoomInfo.range && isUseZoomMode.value) {
@@ -387,6 +387,8 @@ export const useZoomModel = (
387
387
 
388
388
  evChartInfo.props.data.push(data);
389
389
  evChartInfo.props.options.push(options);
390
+ } else if (type?.name === 'EvChartBrush') {
391
+ brushChartIdx.value.push(evChartProps?.options?.chartIdx ?? 0);
390
392
  }
391
393
  });
392
394
  }
@@ -490,8 +492,15 @@ export const useZoomModel = (
490
492
 
491
493
  setEvChartOptions();
492
494
 
493
- brushIdx.start = 0;
494
- brushIdx.end = evChartClone.data[0].labels.length - 1;
495
+ brushIdx.end = -1;
496
+ for (let i = 0; i < brushChartIdx.value.length; i++) {
497
+ const data = evChartClone.data[brushChartIdx.value[i]];
498
+
499
+ if (data.labels.length) {
500
+ brushIdx.start = 0;
501
+ brushIdx.end = data.labels.length - 1;
502
+ }
503
+ }
495
504
 
496
505
  if (evChartZoom) {
497
506
  evChartZoom.updateEvChartCloneData(evChartClone, isUseZoomMode.value);
@@ -32,7 +32,7 @@ export default {
32
32
  const injectEvChartInfo = inject('evChartInfo', { props: { options: [] } });
33
33
  const injectBrushIdx = inject('brushIdx', {
34
34
  start: 0,
35
- end: 0,
35
+ end: -1,
36
36
  isUseButton: false,
37
37
  isUseScroll: false,
38
38
  });
@@ -15,6 +15,8 @@ export default class EvChartBrush {
15
15
 
16
16
  init(isResize) {
17
17
  if (this.brushIdx.start > this.brushIdx.end) {
18
+ this.initEventState();
19
+ this.removeBrushCanvas();
18
20
  return;
19
21
  }
20
22
 
@@ -72,52 +74,55 @@ export default class EvChartBrush {
72
74
  const brushIdx = this.debounceBrushIdx ?? this.brushIdx;
73
75
 
74
76
  const labelEndIdx = this.evChartData.value.labels.length - 1;
75
- this.labelEndIdx = labelEndIdx;
76
- const axesXInterval = (evChartRange.x2 - evChartRange.x1) / labelEndIdx;
77
- const brushRectX = brushIdx.start * axesXInterval * pixelRatio;
78
- const brushRectWidth = (
79
- brushCanvasWidth - (
80
- labelEndIdx - (brushIdx.end - brushIdx.start)
81
- ) * axesXInterval
82
- ) * pixelRatio;
83
- const brushRectHeight = this.evChartBrushOptions.value.height - evChartRange.y1;
84
- const brushButtonLeftXPos = brushRectX;
85
- const brushButtonRightXPos = brushRectX + brushRectWidth;
86
-
87
- if (!brushCanvas.style.position) {
88
- brushCanvas.style.position = 'absolute';
89
- brushCanvas.style.top = `${evChartRange.y1}px`;
90
- brushCanvas.style.left = `${evChartRange.x1 - (brushButtonWidth / 2)}px`;
91
- }
92
77
 
93
- if (!isEqualWidth) {
94
- brushCanvas.width = (brushCanvasWidth * pixelRatio);
95
- brushCanvas.style.width = `${brushCanvasWidth}px`;
96
- brushCanvas.height = brushCanvasHeight * pixelRatio;
97
- brushCanvas.style.height = `${brushCanvasHeight}px`;
98
- }
78
+ if (labelEndIdx >= 0) {
79
+ this.labelEndIdx = labelEndIdx;
80
+ const axesXInterval = (evChartRange.x2 - evChartRange.x1) / labelEndIdx;
81
+ const brushRectX = brushIdx.start * axesXInterval * pixelRatio;
82
+ const brushRectWidth = (
83
+ brushCanvasWidth - (
84
+ labelEndIdx - (brushIdx.end - brushIdx.start)
85
+ ) * axesXInterval
86
+ ) * pixelRatio;
87
+ const brushRectHeight = this.evChartBrushOptions.value.height - evChartRange.y1;
88
+ const brushButtonLeftXPos = brushRectX;
89
+ const brushButtonRightXPos = brushRectX + brushRectWidth;
90
+
91
+ if (!brushCanvas.style.position) {
92
+ brushCanvas.style.position = 'absolute';
93
+ brushCanvas.style.top = `${evChartRange.y1}px`;
94
+ brushCanvas.style.left = `${evChartRange.x1 - (brushButtonWidth / 2)}px`;
95
+ }
99
96
 
100
- const ctx = brushCanvas.getContext('2d');
101
-
102
- ctx.clearRect(
103
- 0,
104
- 0,
105
- brushCanvasWidth * pixelRatio,
106
- brushCanvasHeight * pixelRatio,
107
- );
108
-
109
- ctx.fillStyle = this.evChartBrushOptions.value.selection.fillColor;
110
- ctx.globalAlpha = this.evChartBrushOptions.value.selection.opacity;
111
- ctx.fillRect(brushRectX, 0, brushRectWidth, brushRectHeight);
112
- ctx.fillRect(brushButtonLeftXPos, 0, brushButtonWidth, brushRectHeight);
113
- ctx.fillRect(brushButtonRightXPos - brushButtonWidth, 0, brushButtonWidth, brushRectHeight);
114
-
115
- this.evChartBrushPos = {
116
- leftX: brushButtonLeftXPos / pixelRatio,
117
- rightX: brushButtonRightXPos / pixelRatio,
118
- buttonWidth: brushButtonWidth,
119
- axesXInterval,
120
- };
97
+ if (!isEqualWidth) {
98
+ brushCanvas.width = (brushCanvasWidth * pixelRatio);
99
+ brushCanvas.style.width = `${brushCanvasWidth}px`;
100
+ brushCanvas.height = brushCanvasHeight * pixelRatio;
101
+ brushCanvas.style.height = `${brushCanvasHeight}px`;
102
+ }
103
+
104
+ const ctx = brushCanvas.getContext('2d');
105
+
106
+ ctx.clearRect(
107
+ 0,
108
+ 0,
109
+ brushCanvasWidth * pixelRatio,
110
+ brushCanvasHeight * pixelRatio,
111
+ );
112
+
113
+ ctx.fillStyle = this.evChartBrushOptions.value.selection.fillColor;
114
+ ctx.globalAlpha = this.evChartBrushOptions.value.selection.opacity;
115
+ ctx.fillRect(brushRectX, 0, brushRectWidth, brushRectHeight);
116
+ ctx.fillRect(brushButtonLeftXPos, 0, brushButtonWidth, brushRectHeight);
117
+ ctx.fillRect(brushButtonRightXPos - brushButtonWidth, 0, brushButtonWidth, brushRectHeight);
118
+
119
+ this.evChartBrushPos = {
120
+ leftX: brushButtonLeftXPos / pixelRatio,
121
+ rightX: brushButtonRightXPos / pixelRatio,
122
+ buttonWidth: brushButtonWidth,
123
+ axesXInterval,
124
+ };
125
+ }
121
126
  }
122
127
 
123
128
  addEvent() {
@@ -47,10 +47,11 @@ export default {
47
47
  },
48
48
  },
49
49
  emits: [
50
+ 'update:groupSelectedLabel',
50
51
  'update:zoomStartIdx',
51
52
  'update:zoomEndIdx',
52
53
  ],
53
- setup(props) {
54
+ setup(props, { emit }) {
54
55
  const {
55
56
  getNormalizedOptions,
56
57
  isExecuteZoom,
@@ -62,8 +63,10 @@ export default {
62
63
  provide('isExecuteZoom', isExecuteZoom);
63
64
  provide('isChartGroup', true);
64
65
  provide('brushSeries', brushSeries);
65
-
66
- const groupSelectedLabel = computed(() => props.groupSelectedLabel);
66
+ const groupSelectedLabel = computed({
67
+ get: () => props.groupSelectedLabel,
68
+ set: val => emit('update:groupSelectedLabel', val),
69
+ });
67
70
  provide('groupSelectedLabel', groupSelectedLabel);
68
71
 
69
72
  const {