@oliasoft-open-source/charts-library 2.17.2 → 2.17.4
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 +5 -5
- package/release-notes.md +8 -0
- package/src/components/controls/axes-options/axes-options.jsx +3 -3
- package/src/components/line-chart/controls/axes-options/axes-options-form-state.js +1 -6
- package/src/components/line-chart/utils/line-chart-utils.js +1 -5
- package/src/helpers/chart-consts.js +3 -1
- package/src/helpers/range/estimate-data-series-have-close-values.js +4 -4
- package/src/helpers/range/range.js +6 -5
- package/src/helpers/numbers/numbers.js +0 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oliasoft-open-source/charts-library",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.4",
|
|
4
4
|
"description": "React Chart Library (based on Chart.js and react-chart-js-2)",
|
|
5
5
|
"homepage": "https://gitlab.com/oliasoft-open-source/charts-library",
|
|
6
6
|
"bugs": {
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@babel/eslint-parser": "^7.18.9",
|
|
50
50
|
"@babel/preset-env": "^7.18.10",
|
|
51
51
|
"@babel/preset-react": "^7.18.6",
|
|
52
|
-
"@oliasoft-open-source/react-ui-library": "3.
|
|
53
|
-
"@oliasoft-open-source/units": "2.1
|
|
52
|
+
"@oliasoft-open-source/react-ui-library": "^3.4.2",
|
|
53
|
+
"@oliasoft-open-source/units": "^2.6.1",
|
|
54
54
|
"@storybook/addon-actions": "^6.5.10",
|
|
55
55
|
"@storybook/addon-docs": "^6.5.10",
|
|
56
56
|
"@storybook/addon-links": "^6.5.10",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"webpack-merge": "^5.8.0"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"@oliasoft-open-source/react-ui-library": "^3",
|
|
99
|
-
"@oliasoft-open-source/units": "^2.1",
|
|
98
|
+
"@oliasoft-open-source/react-ui-library": "^3.4.2",
|
|
99
|
+
"@oliasoft-open-source/units": "^2.6.1",
|
|
100
100
|
"immer": "^9",
|
|
101
101
|
"prop-types": "^15",
|
|
102
102
|
"react": "^17",
|
package/release-notes.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Charts Library Release Notes
|
|
2
2
|
|
|
3
|
+
## 2.17.4
|
|
4
|
+
|
|
5
|
+
- Use new `<NumberInput>` component from GUI Library in charts controls, to simplify validation ([OW-11773](https://oliasoft.atlassian.net/browse/OW-11773))
|
|
6
|
+
|
|
7
|
+
## 2.17.3
|
|
8
|
+
|
|
9
|
+
- Replace legacy internal implementation of `isEqualWithTolerance` with `isCloseTo` from units package ([OW-11767](https://oliasoft.atlassian.net/browse/OW-11767))
|
|
10
|
+
|
|
3
11
|
## 2.17.2
|
|
4
12
|
|
|
5
13
|
- Fix release CI/CD pipeline ([OW-11691](https://oliasoft.atlassian.net/browse/OW-11691))
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ButtonGroup,
|
|
5
5
|
Field,
|
|
6
6
|
Flex,
|
|
7
|
-
|
|
7
|
+
NumberInput,
|
|
8
8
|
InputGroup,
|
|
9
9
|
InputGroupAddon,
|
|
10
10
|
Popover,
|
|
@@ -122,7 +122,7 @@ const AxesOptionsPopover = ({
|
|
|
122
122
|
return (
|
|
123
123
|
<Field key={i} label={axisLabel || axis.id || ''}>
|
|
124
124
|
<InputGroup small>
|
|
125
|
-
<
|
|
125
|
+
<NumberInput
|
|
126
126
|
name="min"
|
|
127
127
|
value={min}
|
|
128
128
|
error={translations[minError]}
|
|
@@ -138,7 +138,7 @@ const AxesOptionsPopover = ({
|
|
|
138
138
|
onFocus={handleInputFocus}
|
|
139
139
|
/>
|
|
140
140
|
<InputGroupAddon>to</InputGroupAddon>
|
|
141
|
-
<
|
|
141
|
+
<NumberInput
|
|
142
142
|
name="max"
|
|
143
143
|
value={max}
|
|
144
144
|
error={translations[maxError]}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { produce } from 'immer';
|
|
2
|
-
import {
|
|
3
|
-
isGreaterThanMin,
|
|
4
|
-
isLessThanMax,
|
|
5
|
-
validNumber,
|
|
6
|
-
} from '../../utils/line-chart-utils';
|
|
2
|
+
import { isGreaterThanMin, isLessThanMax } from '../../utils/line-chart-utils';
|
|
7
3
|
import { actionTypes } from './action-types';
|
|
8
4
|
|
|
9
5
|
/**
|
|
@@ -37,7 +33,6 @@ const isEmptyString = (value) => value === '';
|
|
|
37
33
|
const createErrorMessages = (value, compareTo, type) => {
|
|
38
34
|
const errors = [];
|
|
39
35
|
if (isEmptyString(value)) errors.push('mustHaveAValue');
|
|
40
|
-
if (!validNumber(value)) errors.push('mustBeANumber');
|
|
41
36
|
|
|
42
37
|
if (type === 'min' && !isLessThanMax(value, compareTo)) {
|
|
43
38
|
errors.push('mustBeLessThanMax');
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { toNum as toNumber
|
|
2
|
-
|
|
3
|
-
const isOnlyNumbers = (str) => /^-?\d*\.?\d+$/.test(str);
|
|
4
|
-
|
|
5
|
-
export const validNumber = (input) => isValidNum(input) && isOnlyNumbers(input);
|
|
1
|
+
import { toNum as toNumber } from '@oliasoft-open-source/units';
|
|
6
2
|
|
|
7
3
|
export const toNum = (value) => {
|
|
8
4
|
const asNumber = toNumber(value);
|
|
@@ -59,4 +59,6 @@ export const DEFAULT_CHART_NAME = 'new_chart';
|
|
|
59
59
|
|
|
60
60
|
export const CUSTOM_LEGEND_PLUGIN_NAME = 'htmlLegend';
|
|
61
61
|
|
|
62
|
-
export const DECIMAL_POINT_TOLERANCE = 9;
|
|
62
|
+
export const DECIMAL_POINT_TOLERANCE = 9;
|
|
63
|
+
|
|
64
|
+
export const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { isCloseTo } from '@oliasoft-open-source/units';
|
|
2
|
+
import { MAX_DECIMAL_DIFF } from '../chart-consts';
|
|
3
3
|
/**
|
|
4
4
|
* Estimates whether any of the data series has values that are all close together
|
|
5
5
|
* - checks only the first and last values in each series (i.e. assumes they are ordered)
|
|
@@ -46,8 +46,8 @@ export const estimateDataSeriesHaveCloseValues = (generatedDatasets) => {
|
|
|
46
46
|
return Object.values(axesFirstLast).some(
|
|
47
47
|
({ xFirst, xLast, yFirst, yLast }) => {
|
|
48
48
|
return (
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
isCloseTo(xFirst, xLast, { absoluteDiff: MAX_DECIMAL_DIFF }) ||
|
|
50
|
+
isCloseTo(yFirst, yLast, { absoluteDiff: MAX_DECIMAL_DIFF })
|
|
51
51
|
);
|
|
52
52
|
},
|
|
53
53
|
);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { round } from '@oliasoft-open-source/units';
|
|
2
|
-
import {
|
|
3
|
-
import { DECIMAL_POINT_TOLERANCE } from '../chart-consts';
|
|
1
|
+
import { round, isCloseTo } from '@oliasoft-open-source/units';
|
|
2
|
+
import { DECIMAL_POINT_TOLERANCE, MAX_DECIMAL_DIFF } from '../chart-consts';
|
|
4
3
|
|
|
5
4
|
const whiteSpacePercentage = 0.05; // relative amount of white space on each "side" of the data points
|
|
6
5
|
|
|
@@ -39,7 +38,8 @@ export const getSuggestedAxisRange = ({
|
|
|
39
38
|
);
|
|
40
39
|
const isNegative = Math.sign(dataMin) === -1 || Math.sign(dataMax) === -1;
|
|
41
40
|
const isCloseToZeroWithTolerance =
|
|
42
|
-
|
|
41
|
+
isCloseTo(dataMin, 0, { absoluteDiff: MAX_DECIMAL_DIFF }) &&
|
|
42
|
+
isCloseTo(dataMax, 0, { absoluteDiff: MAX_DECIMAL_DIFF });
|
|
43
43
|
|
|
44
44
|
/*
|
|
45
45
|
Use default range upon no data or when all values are close to 0
|
|
@@ -51,7 +51,8 @@ export const getSuggestedAxisRange = ({
|
|
|
51
51
|
/*
|
|
52
52
|
When all values are close to the same, always add some padding OW-4327
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
|
|
55
|
+
if (isCloseTo(dataMin, dataMax, { absoluteDiff: MAX_DECIMAL_DIFF })) {
|
|
55
56
|
const point = dataMax;
|
|
56
57
|
const padding = point * whiteSpacePercentage;
|
|
57
58
|
const minAxisValue = beginAtZero && !isNegative ? 0 : point - padding;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { round } from '@oliasoft-open-source/units';
|
|
2
|
-
import { DECIMAL_POINT_TOLERANCE } from '../chart-consts';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Determines whether two numbers are close in value with a tolerance
|
|
6
|
-
* (mitigates excess JavaScript floating point precision quirks)
|
|
7
|
-
*
|
|
8
|
-
* Inspired by WellDesign implementations:
|
|
9
|
-
* - isCloseTo in rounding.js
|
|
10
|
-
* - isEqual in TDHYDutils.js (recommended by Truls, but quirks comparing values close to 0 need testing)
|
|
11
|
-
* - TODO: replace this with a universal Oliasoft implementation when ready
|
|
12
|
-
*
|
|
13
|
-
* @param {number} a
|
|
14
|
-
* @param {number} b
|
|
15
|
-
* @returns {boolean}
|
|
16
|
-
*/
|
|
17
|
-
export const isEqualWithTolerance = (a, b) => {
|
|
18
|
-
if (typeof a == 'number' && typeof b === typeof a) {
|
|
19
|
-
const tolerance = 10 ** -DECIMAL_POINT_TOLERANCE;
|
|
20
|
-
const difference = Math.abs(b - a);
|
|
21
|
-
const roundedDifference = round(difference, DECIMAL_POINT_TOLERANCE);
|
|
22
|
-
return roundedDifference <= tolerance;
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
};
|