@oliasoft-open-source/charts-library 2.5.8 → 2.5.9

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": "@oliasoft-open-source/charts-library",
3
- "version": "2.5.8",
3
+ "version": "2.5.9",
4
4
  "description": "React Chart Library (based on Chart.js and react-chart-js-2)",
5
5
  "main": "index.js",
6
6
  "files": [
package/release-notes.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Charts Library Release Notes
2
2
 
3
+ ## 2.5.9
4
+
5
+ - Fix validation for two and more decimal places in charts settings
6
+
3
7
  ## 2.5.8
4
8
 
5
9
  - Disable tooltip animations in `performanceMode`
@@ -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: stateAxis.min?.valid
61
- ? stateAxis.min?.value
62
- : additionalAxesOptions?.range?.[axisType]?.min,
63
- max: stateAxis.max?.valid
64
- ? stateAxis.max?.value
65
- : additionalAxesOptions?.range?.[axisType]?.max,
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,7 +144,9 @@ export const toNum = (value) => {
144
144
  };
145
145
 
146
146
  export const isLessThanMax = (value, max) => {
147
- return value === undefined || max === undefined || value < max;
147
+ return (
148
+ value === undefined || max === undefined || Number(value) < Number(max)
149
+ );
148
150
  };
149
151
 
150
152
  export const isGreaterThanMin = (value, min) => {
@@ -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 = isNaN(nextInputValue)
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);