@oliasoft-open-source/charts-library 2.17.2 → 2.17.3
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.17.
|
|
3
|
+
"version": "2.17.3",
|
|
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": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@babel/preset-env": "^7.18.10",
|
|
51
51
|
"@babel/preset-react": "^7.18.6",
|
|
52
52
|
"@oliasoft-open-source/react-ui-library": "3.3.12",
|
|
53
|
-
"@oliasoft-open-source/units": "2.1
|
|
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",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
98
|
"@oliasoft-open-source/react-ui-library": "^3",
|
|
99
|
-
"@oliasoft-open-source/units": "^2.1",
|
|
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,9 @@
|
|
|
1
1
|
# Charts Library Release Notes
|
|
2
2
|
|
|
3
|
+
## 2.17.3
|
|
4
|
+
|
|
5
|
+
- Replace legacy internal implementation of `isEqualWithTolerance` with `isCloseTo` from units package [OW-11767](https://oliasoft.atlassian.net/browse/OW-11767)
|
|
6
|
+
|
|
3
7
|
## 2.17.2
|
|
4
8
|
|
|
5
9
|
- Fix release CI/CD pipeline ([OW-11691](https://oliasoft.atlassian.net/browse/OW-11691))
|
|
@@ -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
|
-
};
|