evui 3.4.138 → 3.4.140
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/dist/evui.common.js +56 -20
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +56 -20
- package/dist/evui.umd.js.map +1 -1
- package/dist/evui.umd.min.js +1 -1
- package/dist/evui.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chart/chart.core.js +11 -3
- package/src/components/chart/helpers/helpers.constant.js +1 -0
- package/src/components/chart/scale/scale.js +18 -2
- package/src/components/chart/scale/scale.linear.js +8 -4
- package/src/components/chart/scale/scale.step.js +5 -4
- package/src/components/chart/scale/scale.time.category.js +5 -4
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mobileCheck } from '@/common/utils';
|
|
1
|
+
import { mobileCheck, truthyNumber } from '@/common/utils';
|
|
2
2
|
import Model from './model';
|
|
3
3
|
import TimeScale from './scale/scale.time';
|
|
4
4
|
import LinearScale from './scale/scale.linear';
|
|
@@ -196,21 +196,29 @@ class EvChart {
|
|
|
196
196
|
const notFormattedXLabels = getNotFormattedLabels(this.axesSteps?.x[0]);
|
|
197
197
|
const notFormattedYLabels = getNotFormattedLabels(this.axesSteps?.y[0]);
|
|
198
198
|
|
|
199
|
+
const yFixWidth = truthyNumber(this.axesY[0]?.labelStyle?.fixWidth)
|
|
200
|
+
? this.axesY[0]?.labelStyle?.fixWidth
|
|
201
|
+
: 0;
|
|
202
|
+
const xFixWidth = truthyNumber(this.axesX[0]?.labelStyle?.fixWidth)
|
|
203
|
+
? this.axesX[0]?.labelStyle?.fixWidth
|
|
204
|
+
: 0;
|
|
205
|
+
|
|
199
206
|
const xMaxWidth = this.axesX[0]?.getLabelWidthHasMaxLength(notFormattedXLabels);
|
|
200
207
|
const yMaxWidth = this.axesY[0]?.getLabelWidthHasMaxLength(notFormattedYLabels);
|
|
201
208
|
|
|
209
|
+
|
|
202
210
|
const adjustedRange = {
|
|
203
211
|
x: !isStepXAxisUseFitWidth ? this.axesRange?.x?.map(value => ({
|
|
204
212
|
...value,
|
|
205
213
|
size: {
|
|
206
|
-
width: Math.max(xMaxWidth, value.size.width),
|
|
214
|
+
width: xFixWidth || Math.max(xMaxWidth, value.size.width),
|
|
207
215
|
height: value.size.height,
|
|
208
216
|
},
|
|
209
217
|
})) : this.axesRange?.x,
|
|
210
218
|
y: !isStepYAxisUseFitWidth ? this.axesRange?.y?.map(value => ({
|
|
211
219
|
...value,
|
|
212
220
|
size: {
|
|
213
|
-
width: Math.max(yMaxWidth, value.size.width),
|
|
221
|
+
width: yFixWidth || Math.max(yMaxWidth, value.size.width),
|
|
214
222
|
height: value.size.height,
|
|
215
223
|
},
|
|
216
224
|
})) : this.axesRange?.y,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Canvas from '@/components/chart/helpers/helpers.canvas';
|
|
2
2
|
import { defaultsDeep } from 'lodash-es';
|
|
3
|
+
import { truthyNumber } from '@/common/utils';
|
|
3
4
|
import {
|
|
4
5
|
AXIS_OPTION,
|
|
5
6
|
AXIS_UNITS,
|
|
@@ -382,7 +383,7 @@ class Scale {
|
|
|
382
383
|
if (this.type === 'x') {
|
|
383
384
|
labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
|
|
384
385
|
if (options?.brush?.showLabel || !options?.brush) {
|
|
385
|
-
ctx.fillText(labelText, labelCenter, labelPoint);
|
|
386
|
+
ctx.fillText(this.checkFixWidth(labelText), labelCenter, labelPoint);
|
|
386
387
|
}
|
|
387
388
|
|
|
388
389
|
if (!isBlurredLabel
|
|
@@ -429,7 +430,7 @@ class Scale {
|
|
|
429
430
|
} else {
|
|
430
431
|
labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
|
|
431
432
|
if (options?.brush?.showLabel || !options?.brush) {
|
|
432
|
-
ctx.fillText(labelText, labelPoint, labelCenter);
|
|
433
|
+
ctx.fillText(this.checkFixWidth(labelText), labelPoint, labelCenter);
|
|
433
434
|
}
|
|
434
435
|
|
|
435
436
|
if (ix === steps) {
|
|
@@ -949,6 +950,21 @@ class Scale {
|
|
|
949
950
|
ctx.fillText(label, textX, textY);
|
|
950
951
|
ctx.closePath();
|
|
951
952
|
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Check if the label width is greater than the fix width
|
|
956
|
+
* @param {string} value label value
|
|
957
|
+
* @returns
|
|
958
|
+
*/
|
|
959
|
+
checkFixWidth(value) {
|
|
960
|
+
const { fixWidth, fitDir } = this.labelStyle;
|
|
961
|
+
|
|
962
|
+
if (truthyNumber(fixWidth) && fixWidth > 0) {
|
|
963
|
+
return Util.truncateLabelWithEllipsis(value, fixWidth, this.ctx, fitDir);
|
|
964
|
+
}
|
|
965
|
+
return value;
|
|
966
|
+
}
|
|
952
967
|
}
|
|
953
968
|
|
|
969
|
+
|
|
954
970
|
export default Scale;
|
|
@@ -10,14 +10,16 @@ class LinearScale extends Scale {
|
|
|
10
10
|
*
|
|
11
11
|
* @returns {string} formatted label
|
|
12
12
|
*/
|
|
13
|
+
getTruthyValue(value) {
|
|
14
|
+
return truthyNumber(value) ? Number(value.toFixed(this.decimalPoint)) : value;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
getLabelFormat(value, data = {}) {
|
|
14
18
|
if (this.formatter) {
|
|
15
|
-
const formattedLabel = this.formatter(
|
|
19
|
+
const formattedLabel = this.formatter(this.getTruthyValue(value), {
|
|
16
20
|
...data,
|
|
17
21
|
prevOriginalValue: data?.prev,
|
|
18
|
-
prevDecimalPointValue:
|
|
19
|
-
? Number(data?.prev.toFixed(this.decimalPoint))
|
|
20
|
-
: null,
|
|
22
|
+
prevDecimalPointValue: this.getTruthyValue(data?.prev),
|
|
21
23
|
currentOriginalValue: value,
|
|
22
24
|
currentDecimalPointValue: Number(value.toFixed(this.decimalPoint)),
|
|
23
25
|
});
|
|
@@ -27,9 +29,11 @@ class LinearScale extends Scale {
|
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
|
|
30
33
|
return Util.labelSignFormat(value, this.decimalPoint);
|
|
31
34
|
}
|
|
32
35
|
|
|
36
|
+
|
|
33
37
|
/**
|
|
34
38
|
* Calculate interval
|
|
35
39
|
* @param {object} range range information
|
|
@@ -223,7 +223,7 @@ class StepScale extends Scale {
|
|
|
223
223
|
if (this.type === 'x') {
|
|
224
224
|
labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
|
|
225
225
|
const xPoint = alignToGridLine ? labelCenter : labelCenter + (labelGap / 2);
|
|
226
|
-
ctx.fillText(labelText, xPoint, labelPoint);
|
|
226
|
+
ctx.fillText(this.checkFixWidth(labelText), xPoint, labelPoint);
|
|
227
227
|
|
|
228
228
|
if (!isBlurredLabel
|
|
229
229
|
&& selectItemOpt?.showLabelTip
|
|
@@ -267,7 +267,7 @@ class StepScale extends Scale {
|
|
|
267
267
|
} else {
|
|
268
268
|
labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
|
|
269
269
|
const yPoint = alignToGridLine ? labelCenter : labelCenter + (labelGap / 2);
|
|
270
|
-
ctx.fillText(labelText, labelPoint, yPoint);
|
|
270
|
+
ctx.fillText(this.checkFixWidth(labelText), labelPoint, yPoint);
|
|
271
271
|
drawnLabels.push(labelText);
|
|
272
272
|
|
|
273
273
|
if (this.showAxisTick) {
|
|
@@ -307,13 +307,13 @@ class StepScale extends Scale {
|
|
|
307
307
|
|
|
308
308
|
const lastLabelText = this.getLabelFormat(`${lastLabelValue}`, maxWidth);
|
|
309
309
|
if (this.type === 'x') {
|
|
310
|
-
ctx.fillText(lastLabelText, labelCenter, labelPoint);
|
|
310
|
+
ctx.fillText(this.checkFixWidth(lastLabelText), labelCenter, labelPoint);
|
|
311
311
|
if (this.showGrid) {
|
|
312
312
|
ctx.moveTo(linePosition, offsetPoint);
|
|
313
313
|
ctx.lineTo(linePosition, offsetCounterPoint);
|
|
314
314
|
}
|
|
315
315
|
} else {
|
|
316
|
-
ctx.fillText(lastLabelText, labelPoint, labelCenter);
|
|
316
|
+
ctx.fillText(this.checkFixWidth(lastLabelText), labelPoint, labelCenter);
|
|
317
317
|
if (this.showGrid) {
|
|
318
318
|
ctx.moveTo(offsetPoint, linePosition);
|
|
319
319
|
ctx.lineTo(offsetCounterPoint, linePosition);
|
|
@@ -406,6 +406,7 @@ class StepScale extends Scale {
|
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
+
|
|
409
410
|
return this.labelStyle.fitWidth ? this.fittingString(value, maxWidth) : value;
|
|
410
411
|
}
|
|
411
412
|
|
|
@@ -26,6 +26,7 @@ class TimeCategoryScale extends Scale {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
|
|
29
30
|
return dayjs(value).format(this.timeFormat);
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -231,7 +232,7 @@ class TimeCategoryScale extends Scale {
|
|
|
231
232
|
|
|
232
233
|
if (this.type === 'x') {
|
|
233
234
|
labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
|
|
234
|
-
ctx.fillText(labelText, labelCenter, labelPoint);
|
|
235
|
+
ctx.fillText(this.checkFixWidth(labelText), labelCenter, labelPoint);
|
|
235
236
|
if (!isBlurredLabel
|
|
236
237
|
&& this.options?.selectItem?.showLabelTip
|
|
237
238
|
&& hitInfo?.label
|
|
@@ -279,7 +280,7 @@ class TimeCategoryScale extends Scale {
|
|
|
279
280
|
}
|
|
280
281
|
} else {
|
|
281
282
|
labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
|
|
282
|
-
ctx.fillText(labelText, labelPoint, labelCenter);
|
|
283
|
+
ctx.fillText(this.checkFixWidth(labelText), labelPoint, labelCenter);
|
|
283
284
|
|
|
284
285
|
if (this.showAxisTick) {
|
|
285
286
|
ctx.beginPath();
|
|
@@ -316,13 +317,13 @@ class TimeCategoryScale extends Scale {
|
|
|
316
317
|
linePosition = labelCenter + aliasPixel;
|
|
317
318
|
|
|
318
319
|
if (this.type === 'x') {
|
|
319
|
-
ctx.fillText(labelLastText, labelCenter, labelPoint);
|
|
320
|
+
ctx.fillText(this.checkFixWidth(labelLastText), labelCenter, labelPoint);
|
|
320
321
|
if (this.showGrid) {
|
|
321
322
|
ctx.moveTo(linePosition, offsetPoint);
|
|
322
323
|
ctx.lineTo(linePosition, offsetCounterPoint);
|
|
323
324
|
}
|
|
324
325
|
} else {
|
|
325
|
-
ctx.fillText(labelLastText, labelPoint, labelCenter);
|
|
326
|
+
ctx.fillText(this.checkFixWidth(labelLastText), labelPoint, labelCenter);
|
|
326
327
|
if (this.showGrid) {
|
|
327
328
|
ctx.moveTo(offsetPoint, linePosition);
|
|
328
329
|
ctx.lineTo(offsetCounterPoint, linePosition);
|