evui 3.4.113 → 3.4.115

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.113",
3
+ "version": "3.4.115",
4
4
  "description": "A EXEM Library project",
5
5
  "author": "exem <dev_client@ex-em.com>",
6
6
  "license": "MIT",
@@ -171,47 +171,53 @@ class EvChart {
171
171
  this.drawSyncedIndicator({ horizontal, label, mousePosition });
172
172
  }
173
173
 
174
- adjustYAxisWidth() {
174
+ adjustXAndYAxisWidth() {
175
175
  // fitWidth(maxWidth에 넘을 시 말줄임표 들어가는 기능)을 사용중인 step Axis인 경우에는 적용 제외
176
- const isStepAxisUseFitWidth = this.options.axesY?.some(axisY => axisY.type === 'step' && axisY.labelStyle?.fitWidth);
176
+ const isStepXAxisUseFitWidth = this.options.axesX?.some(axisX => axisX.type === 'step' && axisX.labelStyle?.fitWidth);
177
+ const isStepYAxisUseFitWidth = this.options.axesY?.some(axisY => axisY.type === 'step' && axisY.labelStyle?.fitWidth);
177
178
 
178
- if (
179
- !this.axesY?.length
180
- || !this.axesRange?.y
181
- || !this.axesSteps?.y?.length
182
- || isStepAxisUseFitWidth
183
- ) {
184
- return;
185
- }
179
+ const getNotFormattedLabels = (axesSteps) => {
180
+ const { interval, graphMin, graphMax, steps = 0 } = axesSteps ?? {};
181
+ let result = [];
186
182
 
187
- let notFormattedLabels = [];
188
- const { interval, graphMin, graphMax, steps = 0 } = this.axesSteps?.y[0] ?? {};
189
- if (interval) {
190
- for (let i = 0; i < steps; i++) {
191
- notFormattedLabels.push(graphMin + (i * interval));
183
+ if (interval) {
184
+ result = Array.from({ length: steps }, (_, i) => graphMin + i * interval);
185
+ result.push(graphMax);
186
+ } else {
187
+ const { labels } = this.data;
188
+ result = labels?.y ?? labels ?? [];
192
189
  }
193
- notFormattedLabels.push(graphMax);
194
- } else {
195
- notFormattedLabels = this.data.labels?.y ?? this.data.labels ?? [];
196
- }
197
190
 
198
- const yMaxWidth = this.axesY[0]?.getLabelWidthHasMaxLength(notFormattedLabels);
199
- if (yMaxWidth > 0) {
200
- const adjustedRange = {
201
- x: this.axesRange.x,
202
- y: this.axesRange.y.map(value => ({
203
- ...value,
204
- size: {
205
- width: yMaxWidth,
206
- height: value.size.height,
207
- },
208
- })),
209
- };
191
+ return result;
192
+ };
210
193
 
211
- this.labelOffset = this.getLabelOffset(adjustedRange);
212
- this.labelRange = this.getAxesLabelRange();
213
- this.axesSteps = this.calculateSteps();
214
- }
194
+ const notFormattedXLabels = getNotFormattedLabels(this.axesSteps?.x[0]);
195
+ const notFormattedYLabels = getNotFormattedLabels(this.axesSteps?.y[0]);
196
+
197
+ const xMaxWidth = this.axesX[0]?.getLabelWidthHasMaxLength(notFormattedXLabels);
198
+ const yMaxWidth = this.axesY[0]?.getLabelWidthHasMaxLength(notFormattedYLabels);
199
+
200
+ const adjustedRange = {
201
+ x: !isStepXAxisUseFitWidth ? this.axesRange?.x?.map(value => ({
202
+ ...value,
203
+ size: {
204
+ width: Math.max(xMaxWidth, value.size.width),
205
+ height: value.size.height,
206
+ },
207
+ })) : this.axesRange?.x,
208
+ y: !isStepYAxisUseFitWidth ? this.axesRange?.y?.map(value => ({
209
+ ...value,
210
+ size: {
211
+ width: Math.max(yMaxWidth, value.size.width),
212
+ height: value.size.height,
213
+ },
214
+ })) : this.axesRange?.y,
215
+ };
216
+
217
+ this.axesRange = adjustedRange;
218
+ this.labelOffset = this.getLabelOffset(adjustedRange);
219
+ this.labelRange = this.getAxesLabelRange();
220
+ this.axesSteps = this.calculateSteps();
215
221
  }
216
222
 
217
223
  /**
@@ -228,7 +234,7 @@ class EvChart {
228
234
  this.labelRange = this.getAxesLabelRange();
229
235
  this.axesSteps = this.calculateSteps();
230
236
 
231
- this.adjustYAxisWidth();
237
+ this.adjustXAndYAxisWidth();
232
238
 
233
239
  this.drawAxis(hitInfo);
234
240
  this.drawSeries(hitInfo);
@@ -34,7 +34,7 @@ class Line {
34
34
  this.size = {
35
35
  comboOffset: 0,
36
36
  };
37
- this.usePassingValue = !isUndefined(this.passingValue) && this.interpolation === 'linear';
37
+ this.useLinearInterpolation = this.interpolation === 'linear' || (this.interpolation === 'none' && !!this.passingValue);
38
38
  }
39
39
 
40
40
  /**
@@ -129,7 +129,7 @@ class Line {
129
129
  let x = getXPos(curr.x);
130
130
  let y = getYPos(curr.y);
131
131
 
132
- if (this.isExistGrp && this.usePassingValue && curr.o === this.passingValue) {
132
+ if (this.isExistGrp && this.useLinearInterpolation && curr.o === null) {
133
133
  y = getYPos(curr.b ?? 0);
134
134
  }
135
135
 
@@ -140,16 +140,14 @@ class Line {
140
140
  curr.xp = x;
141
141
  curr.yp = y;
142
142
 
143
- if (this.usePassingValue && curr.o === this.passingValue) {
143
+ if (this.useLinearInterpolation && curr.o === null) {
144
144
  if (!this.isExistGrp) {
145
145
  return;
146
146
  }
147
147
  }
148
148
 
149
- if ((isNil(prevValid?.y) && this.usePassingValue && this.passingValue !== prevValid?.o)
150
- || (!this.usePassingValue && isNil(curr.o) && this.interpolation !== 'zero')
151
- || (!this.usePassingValue && isNil(prevValid?.y))
152
- || (isNil(curr.o) && curr.y == null && this.passingValue !== curr.o)) {
149
+ if ((isNil(prevValid?.y) && !this.isExistGrp)
150
+ || (!this.useLinearInterpolation && (isNil(prevValid?.y) || isNil(curr.o)))) {
153
151
  ctx.moveTo(x, y);
154
152
  } else {
155
153
  ctx.lineTo(x, y);
@@ -197,18 +195,17 @@ class Line {
197
195
  /** @type {Array<[number, number]>} */
198
196
  const needFillDataIndexList = [];
199
197
  for (let i = 0; i < valueArray.length + 1; i++) {
200
- const isNoneInterpolation = this.interpolation === 'none' || (this.usePassingValue && this.passingValue !== null);
201
-
202
- if (isNoneInterpolation ? isNil(valueArray[i]) : isUndefined(valueArray[i])) {
198
+ if ((this.useLinearInterpolation && isUndefined(valueArray[i]))
199
+ || (!this.useLinearInterpolation && isNil(valueArray[i]))) {
203
200
  if (start !== null && end !== null) {
204
201
  const temp = valueArray.slice(start, i);
205
202
  const lastNormalValueIndex = temp.findLastIndex(
206
- item => !isNil(item) && item !== this.passingValue);
203
+ item => !isNil(item) && item !== null);
207
204
  needFillDataIndexList.push([start, start + lastNormalValueIndex]);
208
205
  start = null;
209
206
  end = null;
210
207
  }
211
- } else if (this.usePassingValue && valueArray[i] === this.passingValue) {
208
+ } else if (this.useLinearInterpolation && valueArray[i] === null) {
212
209
  end = i;
213
210
  } else {
214
211
  start = start === null ? i : start;
@@ -232,7 +229,7 @@ class Line {
232
229
 
233
230
  if (ix === startIndex) {
234
231
  ctx.moveTo(currData.xp, currData.yp);
235
- } else if (this.isExistGrp || this.passingValue !== currData.o || (this.interpolation === 'zero' && isNil(currData.o))) {
232
+ } else if (this.isExistGrp || currData.o !== null) {
236
233
  ctx.lineTo(currData.xp, currData.yp);
237
234
  }
238
235
 
@@ -257,14 +254,18 @@ class Line {
257
254
  ctx.strokeStyle = Util.colorStringToRgba(mainColor, mainColorOpacity);
258
255
  const focusStyle = Util.colorStringToRgba(pointFillColor, 1);
259
256
  const blurStyle = Util.colorStringToRgba(pointFillColor, pointFillColorOpacity);
257
+ const isLinearSingle = this.interpolation === 'linear' && this.data.filter(item => item.o !== null).length === 1;
260
258
 
261
259
  this.data.forEach((curr, ix) => {
262
- if (curr.xp === null || curr.yp === null || curr.o === this.passingValue) {
260
+ if (curr.xp === null || curr.yp === null || curr.o === null) {
263
261
  return;
264
262
  }
265
263
 
266
- const isSingle = this.interpolation === 'none' && Util.isNullOrUndefined(this.data[ix - 1]?.o)
267
- && Util.isNullOrUndefined(this.data[ix + 1]?.o);
264
+ const prevData = this.data[ix - 1]?.o;
265
+ const nextData = this.data[ix + 1]?.o;
266
+
267
+ const isSingle = (!this.useLinearInterpolation && isNil(prevData) && isNil(nextData))
268
+ || isLinearSingle;
268
269
  const isSelectedLabel = selectedLabelIndexList.includes(ix);
269
270
  if (this.point || isSingle || isSelectedLabel) {
270
271
  ctx.fillStyle = isSelectedLabel && !legendHitInfo ? focusStyle : blurStyle;
@@ -291,7 +292,7 @@ class Line {
291
292
  const { xp, yp, o } = gdata;
292
293
 
293
294
  ctx.save();
294
- if (xp !== null && yp !== null && o !== this.passingValue && this.pointHighlight) {
295
+ if (xp !== null && yp !== null && o !== null && this.pointHighlight) {
295
296
  ctx.strokeStyle = Util.colorStringToRgba(this.color, 0);
296
297
  ctx.fillStyle = Util.colorStringToRgba(this.color, this.highlight.maxShadowOpacity);
297
298
  Canvas.drawPoint(ctx, this.pointStyle, this.highlight.maxShadowSize, xp, yp);
@@ -403,7 +404,7 @@ class Line {
403
404
  }
404
405
  }
405
406
 
406
- if (this.usePassingValue && item?.data?.o === this.passingValue) {
407
+ if (this.useLinearInterpolation && item?.data?.o === null) {
407
408
  item.data = null;
408
409
  }
409
410
 
@@ -46,17 +46,20 @@ const modules = {
46
46
  } else {
47
47
  seriesIDs.forEach((seriesID) => {
48
48
  const series = this.seriesList[seriesID];
49
- const sData = data[seriesID];
50
-
49
+ const sData = data[seriesID].map((item) => {
50
+ if (series.interpolation === 'zero' && !item) {
51
+ return 0;
52
+ }
53
+ if (item === series.passingValue) {
54
+ return null;
55
+ }
56
+ return item;
57
+ });
51
58
  if (series && sData) {
52
59
  if (series.isExistGrp && series.stackIndex && !series.isOverlapping) {
53
- series.data = this.addSeriesStackDS(
54
- sData, label, series.bsIds, series.stackIndex, series.interpolation,
55
- );
60
+ series.data = this.addSeriesStackDS(sData, label, series.bsIds, series.stackIndex);
56
61
  } else {
57
- series.data = this.addSeriesDS(
58
- sData, label, series.isExistGrp, series.interpolation,
59
- );
62
+ series.data = this.addSeriesDS(sData, label, series.isExistGrp);
60
63
  }
61
64
  series.minMax = this.getSeriesMinMax(series.data);
62
65
  }
@@ -389,13 +392,12 @@ const modules = {
389
392
  * @param {object} label chart label
390
393
  * @param {array} bsIds stacked base data ID List
391
394
  * @param {number} sIdx series ordered index
392
- * @param {import('./index').InterpolationType} interpolation interpolation type
393
395
  *
394
396
  * @typedef {import('./index').ChartSeriesDataPoint} ChartSeriesDataPoint
395
397
  *
396
398
  * @returns {ChartSeriesDataPoint[]} data for each series
397
399
  */
398
- addSeriesStackDS(data, label, bsIds, sIdx = 0, interpolation = 'none') {
400
+ addSeriesStackDS(data, label, bsIds, sIdx = 0) {
399
401
  const isHorizontal = this.options.horizontal;
400
402
  const sdata = [];
401
403
 
@@ -443,7 +445,7 @@ const modules = {
443
445
  gdata = oData;
444
446
  }
445
447
 
446
- sdata.push(this.addData(gdata, ldata, odata, bdata, interpolation));
448
+ sdata.push(this.addData(gdata, ldata, odata, bdata));
447
449
  }
448
450
  });
449
451
 
@@ -455,13 +457,12 @@ const modules = {
455
457
  * @param {object} data chart series info
456
458
  * @param {object} label chart label
457
459
  * @param {boolean} isBase is Base(bottommost) series at stack chart
458
- * @param {import('./index').InterpolationType} interpolation interpolation type
459
460
  *
460
461
  * @typedef {import('./index').ChartSeriesDataPoint} ChartSeriesDataPoint
461
462
  *
462
463
  * @returns {ChartSeriesDataPoint[]} data for each series
463
464
  */
464
- addSeriesDS(data, label, isBase, interpolation = 'none') {
465
+ addSeriesDS(data, label, isBase) {
465
466
  const isHorizontal = this.options.horizontal;
466
467
  const sdata = [];
467
468
  const passingValue = this.seriesList[Object.keys(this.seriesList)[0]]?.passingValue;
@@ -479,12 +480,7 @@ const modules = {
479
480
  const isPassingValueWithStack = isBase
480
481
  && !Util.isNullOrUndefined(passingValue)
481
482
  && gdata === passingValue;
482
- sdata.push(this.addData(
483
- isPassingValueWithStack ? 0 : gdata,
484
- ldata,
485
- gdata,
486
- null,
487
- interpolation,
483
+ sdata.push(this.addData(isPassingValueWithStack ? 0 : gdata, ldata, gdata,
488
484
  ));
489
485
  }
490
486
  });
@@ -535,13 +531,12 @@ const modules = {
535
531
  * @param {object} ldata label data (x-axis value for vertical chart)
536
532
  * @param {object} odata original data (without stacked value)
537
533
  * @param {object} bdata base data (stacked value)
538
- * @param {import('./index').InterpolationType} interpolation interpolation type
539
534
  *
540
535
  * @typedef {import('./index').ChartSeriesDataPoint} ChartSeriesDataPoint
541
536
  *
542
537
  * @returns {ChartSeriesDataPoint} data for each graph point
543
538
  */
544
- addData(gdata, ldata, odata = null, bdata = null, interpolation = 'none') {
539
+ addData(gdata, ldata, odata = null, bdata = null) {
545
540
  let data;
546
541
  let gdataValue = null;
547
542
  let odataValue = null;
@@ -554,7 +549,7 @@ const modules = {
554
549
  gdataColor = gdata.color;
555
550
  dataTextColor = gdata.textColor;
556
551
  } else {
557
- gdataValue = interpolation === 'zero' && !gdata ? bdata ?? 0 : gdata ?? null;
552
+ gdataValue = gdata ?? null;
558
553
  }
559
554
 
560
555
  if (odata !== null && typeof odata === 'object') {
@@ -804,6 +804,7 @@ export default {
804
804
  index,
805
805
  hiddenDisplay: false,
806
806
  ...column,
807
+ width: isFinite(column.width) ? column.width : undefined,
807
808
  sortOption: {
808
809
  sortType: column?.sortOption?.sortType || 'init',
809
810
  },
@@ -451,6 +451,7 @@ export default {
451
451
  index,
452
452
  hiddenDisplay: false,
453
453
  ...column,
454
+ width: isFinite(column.width) ? column.width : undefined,
454
455
  sortOption: {
455
456
  sortType: column?.sortOption?.sortType || 'init',
456
457
  },