evui 3.4.152 → 3.4.154

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.4.152",
3
+ "version": "3.4.154",
4
4
  "description": "A EXEM Library project",
5
5
  "author": "exem <dev_client@ex-em.com>",
6
6
  "license": "MIT",
@@ -127,6 +127,10 @@ class EvChart {
127
127
  this.axesX = this.createAxes('x', axesX);
128
128
  this.axesY = this.createAxes('y', axesY);
129
129
 
130
+ if (axesX?.[0]?.scrollbar?.use || axesY?.[0]?.scrollbar?.use) {
131
+ this.initScrollbar();
132
+ }
133
+
130
134
  this.initDefaultSelectInfo();
131
135
 
132
136
  this.drawChart();
@@ -162,10 +166,6 @@ class EvChart {
162
166
  this.setLegendPosition();
163
167
  }
164
168
 
165
- if (opt.axesX?.[0]?.scrollbar?.use || opt.axesY?.[0]?.scrollbar?.use) {
166
- this.initScrollbar();
167
- }
168
-
169
169
  this.chartRect = this.getChartRect();
170
170
  }
171
171
 
@@ -277,7 +277,6 @@ class EvChart {
277
277
  this.drawSeries(hitInfo);
278
278
 
279
279
  if (this.scrollbar?.x?.use || this.scrollbar?.y?.use) {
280
- this.initScrollbar();
281
280
  this.updateScrollbarPosition();
282
281
  }
283
282
 
@@ -852,6 +851,21 @@ class EvChart {
852
851
  return labelOffset;
853
852
  }
854
853
 
854
+ /**
855
+ * Update scrollbar information
856
+ * @param {boolean} updateData is update data
857
+ * @returns {undefined}
858
+ */
859
+ updateScrollbar(updateData) {
860
+ if (this.scrollbar?.x?.isInit || this.options.axesX?.[0]?.scrollbar?.use) {
861
+ this.updateScrollbarInfo('x', updateData);
862
+ }
863
+
864
+ if (this.scrollbar?.y?.isInit || this.options.axesY?.[0]?.scrollbar?.use) {
865
+ this.updateScrollbarInfo('y', updateData);
866
+ }
867
+ }
868
+
855
869
  /**
856
870
  * To re-render chart, reset properties, canvas and then render chart.
857
871
  * @param {object} updateInfo information for each components are needed to update
@@ -871,7 +885,6 @@ class EvChart {
871
885
  updateLegend,
872
886
  updateData,
873
887
  updateTooltip,
874
- updateByScrollbar,
875
888
  lightUpdate,
876
889
  } = updateInfo;
877
890
 
@@ -879,9 +892,7 @@ class EvChart {
879
892
  return;
880
893
  }
881
894
 
882
- if (updateByScrollbar) {
883
- this.updateScrollbar?.(updateData);
884
- }
895
+ this.updateScrollbar(updateData);
885
896
 
886
897
  this.resetProps();
887
898
 
@@ -992,7 +1003,6 @@ class EvChart {
992
1003
 
993
1004
  this.initDefaultSelectInfo();
994
1005
 
995
-
996
1006
  let renderHitInfo = updateInfo?.hitInfo;
997
1007
  if (!renderHitInfo?.legend && this.legendHover?.sId) {
998
1008
  renderHitInfo = { ...(renderHitInfo || {}), legend: this.legendHover };
@@ -1065,20 +1075,16 @@ class EvChart {
1065
1075
  * @returns {undefined}
1066
1076
  */
1067
1077
  resize(promiseRes) {
1068
- // 차트 크기가 변경될 때 저장된 스크롤 픽셀 위치를 초기화하여
1069
- // 새로운 크기에 맞춰 스크롤바 크기/위치를 재계산하도록 함
1070
- if (this.scrollbar?.x) {
1071
- delete this.scrollbar.x.savedPosition;
1072
- }
1073
- if (this.scrollbar?.y) {
1074
- delete this.scrollbar.y.savedPosition;
1075
- }
1076
-
1077
1078
  this.clear();
1078
1079
  this.bufferCtx.restore();
1079
1080
  this.bufferCtx.save();
1080
1081
 
1081
1082
  this.initRect();
1083
+
1084
+ if (this.options.axesX?.[0]?.scrollbar?.use || this.options.axesY?.[0]?.scrollbar?.use) {
1085
+ this.initScrollbar();
1086
+ }
1087
+
1082
1088
  this.initScale();
1083
1089
  this.chartRect = this.getChartRect();
1084
1090
  this.drawChart();
@@ -1018,8 +1018,11 @@ const modules = {
1018
1018
  const isHorizontal = !!this.options.horizontal;
1019
1019
  const mousePos = isHorizontal ? yp : xp;
1020
1020
 
1021
- // 번째 표시 중인 시리즈를 기준으로 라벨 위치 확인
1022
- const referenceSeries = sIds.find(sId => this.seriesList[sId]?.show);
1021
+ // 데이터 있는 시리즈를 기준으로 라벨 위치 확인
1022
+ const referenceSeries = sIds.find((sId) => {
1023
+ const series = this.seriesList[sId];
1024
+ return series?.show && series?.data?.length > 0;
1025
+ });
1023
1026
  if (!referenceSeries || !this.seriesList[referenceSeries]?.data) {
1024
1027
  return -1;
1025
1028
  }
@@ -29,6 +29,8 @@ const module = {
29
29
  scrollbarOpt[key] = merged[key];
30
30
  });
31
31
 
32
+ delete scrollbarOpt.savedPosition;
33
+
32
34
  if (!scrollbarOpt.isInit) {
33
35
  scrollbarOpt.type = axisOpt?.[0]?.type;
34
36
  scrollbarOpt.range = axisOpt?.[0]?.range?.length ? [...axisOpt?.[0]?.range] : null;
@@ -83,14 +85,6 @@ const module = {
83
85
  }
84
86
  },
85
87
 
86
- /**
87
- * update scrollbar information
88
- */
89
- updateScrollbar(updateData) {
90
- this.updateScrollbarInfo('x', updateData);
91
- this.updateScrollbarInfo('y', updateData);
92
- },
93
-
94
88
  /**
95
89
  * Updated scrollbar information with updated axis information
96
90
  * @param dir axis direction (x | y)
@@ -449,7 +443,6 @@ const module = {
449
443
  this.update({
450
444
  updateSeries: false,
451
445
  updateSelTip: { update: false, keepDomain: false },
452
- updateByScrollbar: true,
453
446
  lightUpdate: minValue > 1,
454
447
  });
455
448
  }
@@ -44,100 +44,6 @@ class TimeScale extends Scale {
44
44
  }
45
45
  return Math.ceil((max - min) / step);
46
46
  }
47
-
48
- /**
49
- * With range information, calculate how many labels in axis
50
- * @param {object} range min/max information
51
- *
52
- * @returns {object} steps, interval, min/max graph value
53
- */
54
- calculateSteps(range) {
55
- const { maxValue, minValue, maxSteps } = range;
56
-
57
- // 사용자 interval로 인식하는 경우: 숫자 또는 객체({ time, unit }) 형태만
58
- // 문자열('hour', 'second' 등)은 기존 로직(분기 D)으로 처리
59
- const hasUserRange = Array.isArray(this.range) && this.range.length === 2;
60
- const hasUserInterval = (
61
- typeof this.interval === 'number'
62
- || (typeof this.interval === 'object' && this.interval !== null)
63
- );
64
-
65
- const resolvedInterval = hasUserInterval ? this.getInterval(range) : null;
66
- const isValidInterval = (
67
- resolvedInterval != null
68
- && resolvedInterval > 0
69
- && isFinite(resolvedInterval)
70
- );
71
-
72
- const graphMin = +minValue;
73
- let graphMax = +maxValue;
74
- const graphRange = graphMax - graphMin;
75
-
76
- let interval;
77
- let steps;
78
-
79
- if (hasUserRange && isValidInterval) {
80
- // 1) user range + interval
81
- const candidateSteps = graphRange / resolvedInterval;
82
- const isExactlyDividable = Math.abs(candidateSteps - Math.round(candidateSteps)) < 1e-10;
83
- if (isExactlyDividable && candidateSteps <= maxSteps) {
84
- // 1-1) interval 호환되는 경우
85
- interval = resolvedInterval;
86
- steps = Math.round(candidateSteps);
87
- } else {
88
- // 1-2) interval 호환되지 않음 -> 사용자 interval을 사용하지 않음
89
- steps = maxSteps;
90
- interval = graphRange / steps;
91
- }
92
- } else if (hasUserRange) {
93
- // 2) user range only
94
- steps = maxSteps;
95
- interval = graphRange / steps;
96
- } else if (isValidInterval) {
97
- // 3) user interval only
98
- interval = resolvedInterval;
99
- steps = Math.ceil(graphRange / interval);
100
- while (steps > maxSteps) {
101
- interval *= 2;
102
- steps = Math.ceil(graphRange / interval);
103
- }
104
- graphMax = graphMin + (interval * steps);
105
- } else {
106
- // 4) 기존 로직
107
- interval = this.getInterval(range);
108
- let increase = minValue;
109
- let numberOfSteps;
110
-
111
- while (increase < maxValue) {
112
- increase += interval;
113
- }
114
-
115
- graphMax = increase;
116
-
117
- numberOfSteps = Math.round(graphRange / interval);
118
-
119
- while (numberOfSteps > maxSteps) {
120
- interval *= 2;
121
- numberOfSteps = Math.round(graphRange / interval);
122
- const tempInterval = graphRange / numberOfSteps;
123
- interval = this.decimalPoint ? tempInterval : Math.ceil(tempInterval);
124
- }
125
-
126
- if (graphMax - graphMin > (numberOfSteps * interval)) {
127
- const tempInterval = (graphMax - graphMin) / numberOfSteps;
128
- interval = this.decimalPoint ? tempInterval : Math.ceil(tempInterval);
129
- }
130
-
131
- steps = numberOfSteps;
132
- }
133
-
134
- return {
135
- steps,
136
- interval,
137
- graphMin,
138
- graphMax,
139
- };
140
- }
141
47
  }
142
48
 
143
49
  export default TimeScale;