@oliasoft-open-source/charts-library 2.5.7 → 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.7",
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,13 @@
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
+
7
+ ## 2.5.8
8
+
9
+ - Disable tooltip animations in `performanceMode`
10
+
3
11
  ## 2.5.7
4
12
 
5
13
  - Allow stretchy headerComponent in controls
@@ -201,17 +201,14 @@ const BarChart = (props) => {
201
201
  onHover,
202
202
  indexAxis: isVertical(options.direction) ? AxisType.X : AxisType.Y,
203
203
  maintainAspectRatio: chartStyling.maintainAspectRatio,
204
- animation: {
205
- duration: chartStyling.performanceMode
206
- ? ANIMATION_DURATION.NO
207
- : ANIMATION_DURATION.FAST,
208
- },
204
+ animation: chartStyling.performanceMode
205
+ ? false
206
+ : {
207
+ duration: ANIMATION_DURATION.FAST,
208
+ },
209
209
  hover: {
210
210
  mode: ChartHoverMode.Nearest,
211
211
  intersect: true,
212
- animationDuration: chartStyling.performanceMode
213
- ? ANIMATION_DURATION.NO
214
- : ANIMATION_DURATION.SLOW,
215
212
  },
216
213
  elements: {
217
214
  bar: { pointStyle: PointStyle.Circle },
@@ -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) => {
@@ -435,17 +435,14 @@ const LineChart = (props) => {
435
435
  onHover,
436
436
  maintainAspectRatio: chartStyling.maintainAspectRatio,
437
437
  aspectRatio: chartStyling.squareAspectRatio ? 1 : null, // 1 equals square aspect ratio
438
- animation: {
439
- duration: chartStyling.performanceMode
440
- ? ANIMATION_DURATION.NO
441
- : ANIMATION_DURATION.FAST,
442
- },
438
+ animation: chartStyling.performanceMode
439
+ ? false
440
+ : {
441
+ duration: ANIMATION_DURATION.FAST,
442
+ },
443
443
  hover: {
444
444
  mode: ChartHoverMode.Nearest,
445
445
  intersect: true,
446
- animationDuration: chartStyling.performanceMode
447
- ? ANIMATION_DURATION.NO
448
- : ANIMATION_DURATION.SLOW,
449
446
  },
450
447
  elements: {
451
448
  line: {
@@ -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);
@@ -15,6 +15,7 @@ import zoomPlugin from 'chartjs-plugin-zoom';
15
15
  import dataLabelsPlugin from 'chartjs-plugin-datalabels';
16
16
  import { Pie } from 'react-chartjs-2';
17
17
 
18
+ import { ANIMATION_DURATION } from '../../helpers/chart-consts';
18
19
  import styles from './pie-chart.module.less';
19
20
  import { colors, generateRandomColor } from './pie-chart-utils';
20
21
  import { getDefaultProps, PieChartPropTypes } from './pie-chart-prop-types';
@@ -404,13 +405,14 @@ const PieChart = (props) => {
404
405
  onClick,
405
406
  responsive: true, // Defaults to true, should be removed
406
407
  maintainAspectRatio: options.chartStyling.maintainAspectRatio,
407
- animation: {
408
- duration: options.chartStyling.performanceMode ? 0 : 1000,
409
- },
408
+ animation: options.chartStyling.performanceMode
409
+ ? false
410
+ : {
411
+ duration: ANIMATION_DURATION.FAST,
412
+ },
410
413
  hover: {
411
414
  mode: 'nearest',
412
415
  intersect: 'true',
413
- animationDuration: options.chartStyling.performanceMode ? 0 : 400,
414
416
  },
415
417
  onHover,
416
418
  elements: {