@oliasoft-open-source/charts-library 2.5.8 → 2.5.10
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 +1 -1
- package/release-notes.md +8 -0
- package/src/components/controls/axes-options.jsx +11 -2
- package/src/components/line-chart/get-line-chart-scales.js +9 -7
- package/src/components/line-chart/line-chart-utils.js +6 -2
- package/src/components/line-chart/line-chart.jsx +4 -4
- package/src/components/line-chart/state/line-chart-reducer.js +10 -5
package/package.json
CHANGED
package/release-notes.md
CHANGED
|
@@ -25,6 +25,7 @@ const AxesOptionsPopover = ({
|
|
|
25
25
|
axes.filter((axis) => axis.max.displayValue || axis.min.displayValue)
|
|
26
26
|
.length > 0;
|
|
27
27
|
const handleInputFocus = (e) => e.target.select();
|
|
28
|
+
const zoomOrPanEnabled = zoomEnabled || panEnabled;
|
|
28
29
|
return (
|
|
29
30
|
<>
|
|
30
31
|
{axes.map((axis, i) => {
|
|
@@ -36,7 +37,11 @@ const AxesOptionsPopover = ({
|
|
|
36
37
|
<Input
|
|
37
38
|
name="min"
|
|
38
39
|
// TODO: Fix input values not updating first time when scales reset
|
|
39
|
-
value={
|
|
40
|
+
value={
|
|
41
|
+
(zoomOrPanEnabled
|
|
42
|
+
? axis.min.displayValue
|
|
43
|
+
: axis.min.inputValue) || scalesMaxMin[axis?.id]?.min
|
|
44
|
+
}
|
|
40
45
|
error={
|
|
41
46
|
!axis.min.valid
|
|
42
47
|
? 'Invalid value' //t(InputWarningType.MustBeNumericAndLessThanMax)
|
|
@@ -61,7 +66,11 @@ const AxesOptionsPopover = ({
|
|
|
61
66
|
<Input
|
|
62
67
|
name="max"
|
|
63
68
|
// TODO: Fix input values not updating first time when scales reset
|
|
64
|
-
value={
|
|
69
|
+
value={
|
|
70
|
+
(zoomOrPanEnabled
|
|
71
|
+
? axis.max.displayValue
|
|
72
|
+
: axis.max.inputValue) || scalesMaxMin[axis?.id]?.max
|
|
73
|
+
}
|
|
65
74
|
error={
|
|
66
75
|
!axis.max.valid
|
|
67
76
|
? 'Invalid value' //t(InputWarningType.MustBeNumericAndGreaterThanMin)
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getAxisPosition,
|
|
4
4
|
} from '../../helpers/chart-utils';
|
|
5
5
|
import { COLORS, LOGARITHMIC_STEPS } from '../../helpers/chart-consts';
|
|
6
|
-
import { truncateDecimals } from './line-chart-utils';
|
|
6
|
+
import { truncateDecimals, validNumber } from './line-chart-utils';
|
|
7
7
|
import { AxisType, ScaleType } from '../../helpers/enums';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -57,12 +57,14 @@ const getLineChartAxis = (options, axisType, state, currentScales, i = 0) => {
|
|
|
57
57
|
reverse: axisType === AxisType.Y ? additionalAxesOptions.reverse : false,
|
|
58
58
|
suggestedMax: additionalAxesOptions.suggestedMax,
|
|
59
59
|
suggestedMin: additionalAxesOptions.suggestedMin,
|
|
60
|
-
min:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
min:
|
|
61
|
+
stateAxis.min?.valid && validNumber(stateAxis.min?.value)
|
|
62
|
+
? Number(stateAxis.min?.value)
|
|
63
|
+
: additionalAxesOptions?.range?.[axisType]?.min,
|
|
64
|
+
max:
|
|
65
|
+
stateAxis.max?.valid && validNumber(stateAxis.max?.value)
|
|
66
|
+
? Number(stateAxis.max?.value)
|
|
67
|
+
: additionalAxesOptions?.range?.[axisType]?.max,
|
|
66
68
|
title: {
|
|
67
69
|
display: axisData.label?.length,
|
|
68
70
|
text: axisData.label,
|
|
@@ -144,11 +144,15 @@ export const toNum = (value) => {
|
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
export const isLessThanMax = (value, max) => {
|
|
147
|
-
return
|
|
147
|
+
return (
|
|
148
|
+
value === undefined || max === undefined || Number(value) < Number(max)
|
|
149
|
+
);
|
|
148
150
|
};
|
|
149
151
|
|
|
150
152
|
export const isGreaterThanMin = (value, min) => {
|
|
151
|
-
return
|
|
153
|
+
return (
|
|
154
|
+
value === undefined || min === undefined || Number(value) > Number(min)
|
|
155
|
+
);
|
|
152
156
|
};
|
|
153
157
|
|
|
154
158
|
/**
|
|
@@ -346,22 +346,22 @@ const LineChart = (props) => {
|
|
|
346
346
|
payload: [
|
|
347
347
|
{
|
|
348
348
|
name: 'min',
|
|
349
|
-
value: chart.scales?.x?.min ? chart.scales.x.min
|
|
349
|
+
value: chart.scales?.x?.min ? chart.scales.x.min : 0,
|
|
350
350
|
id: 'x',
|
|
351
351
|
},
|
|
352
352
|
{
|
|
353
353
|
name: 'max',
|
|
354
|
-
value: chart.scales?.x?.max ? chart.scales.x.max
|
|
354
|
+
value: chart.scales?.x?.max ? chart.scales.x.max : 0,
|
|
355
355
|
id: 'x',
|
|
356
356
|
},
|
|
357
357
|
{
|
|
358
358
|
name: 'min',
|
|
359
|
-
value: chart.scales?.y?.min ? chart.scales.y.min
|
|
359
|
+
value: chart.scales?.y?.min ? chart.scales.y.min : 0,
|
|
360
360
|
id: 'y',
|
|
361
361
|
},
|
|
362
362
|
{
|
|
363
363
|
name: 'max',
|
|
364
|
-
value: chart.scales?.y?.max ? chart.scales.y.max
|
|
364
|
+
value: chart.scales?.y?.max ? chart.scales.y.max : 0,
|
|
365
365
|
id: 'y',
|
|
366
366
|
},
|
|
367
367
|
],
|
|
@@ -79,9 +79,7 @@ export const reducer = (state, action) => {
|
|
|
79
79
|
}
|
|
80
80
|
case SET_AXIS_VALUE: {
|
|
81
81
|
const valiateElement = (name, nextInputValue, id) => {
|
|
82
|
-
const nextValue =
|
|
83
|
-
? cleanNumStr(nextInputValue)
|
|
84
|
-
: toNum(nextInputValue);
|
|
82
|
+
const nextValue = cleanNumStr(nextInputValue);
|
|
85
83
|
|
|
86
84
|
const axis = newState.axes.find((a) => a.id === id);
|
|
87
85
|
axis.min = getAxisValue(name === 'min' ? nextValue : axis.min?.value);
|
|
@@ -89,11 +87,18 @@ export const reducer = (state, action) => {
|
|
|
89
87
|
axis.min.valid =
|
|
90
88
|
validNumber(axis.min.inputValue ?? '') &&
|
|
91
89
|
isLessThanMax(axis.min.value, axis.max.value);
|
|
92
|
-
axis.min.displayValue =
|
|
90
|
+
axis.min.displayValue =
|
|
91
|
+
axis.min.valid && axis.min.value
|
|
92
|
+
? Number(axis.min.value).toFixed(1)
|
|
93
|
+
: undefined;
|
|
94
|
+
|
|
93
95
|
axis.max.valid =
|
|
94
96
|
validNumber(axis.max.inputValue ?? '') &&
|
|
95
97
|
isGreaterThanMin(axis.max.value, axis.min.value);
|
|
96
|
-
axis.max.displayValue =
|
|
98
|
+
axis.max.displayValue =
|
|
99
|
+
axis.max.valid && axis.max.value
|
|
100
|
+
? Number(axis.max.value).toFixed(1)
|
|
101
|
+
: undefined;
|
|
97
102
|
|
|
98
103
|
const elementValue = axis[name];
|
|
99
104
|
if (elementValue.valid) {
|