@oliasoft-open-source/charts-library 2.10.0-beta-2 → 2.10.0
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.10.0
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "React Chart Library (based on Chart.js and react-chart-js-2)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -83,7 +83,8 @@
|
|
|
83
83
|
"react-dom": "^17.0"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@oliasoft-open-source/react-ui-library": "^3.
|
|
86
|
+
"@oliasoft-open-source/react-ui-library": "^3.3",
|
|
87
|
+
"@oliasoft-open-source/units": "2.0.1",
|
|
87
88
|
"chart.js": "^3.9.1",
|
|
88
89
|
"chartjs-plugin-annotation": "^1.4.0",
|
|
89
90
|
"chartjs-plugin-datalabels": "^2.1.0",
|
package/release-notes.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
# Charts Library Release Notes
|
|
1
|
+
# Charts Library Release Notes
|
|
2
|
+
|
|
3
|
+
## 2.10.0
|
|
4
|
+
|
|
5
|
+
- Switch to standard `round()` function from units repo [OW-10972](https://oliasoft.atlassian.net/browse/OW-10972)
|
|
6
|
+
|
|
7
|
+
## 2.9.4
|
|
8
|
+
|
|
9
|
+
- Updated version of UI Library
|
|
10
|
+
|
|
11
|
+
## 2.9.3
|
|
12
|
+
|
|
13
|
+
- Add @oliasoft-open-source/units package and update pase method in BarChart ([OW-10670](https://oliasoft.atlassian.net/browse/OW-10670))
|
|
14
|
+
|
|
15
|
+
## 2.9.2
|
|
16
|
+
|
|
17
|
+
- Fix missing axis scale when in dataset is one point with negative values ([OW-10616](https://oliasoft.atlassian.net/browse/OW-10616))
|
|
18
|
+
|
|
19
|
+
## 2.9.1
|
|
20
|
+
|
|
21
|
+
- Fix decimal values in BarChart in tooltips for locales with comma decimal ([OW-10632](https://oliasoft.atlassian.net/browse/OW-10632))
|
|
2
22
|
|
|
3
23
|
## 2.9.0
|
|
4
24
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toNum } from '@oliasoft-open-source/units';
|
|
1
2
|
import {
|
|
2
3
|
afterLabelCallback,
|
|
3
4
|
getTooltipLabel,
|
|
@@ -46,7 +47,8 @@ const getBarChartToolTips = (options) => {
|
|
|
46
47
|
|
|
47
48
|
const getTooltipItemValue = () => {
|
|
48
49
|
const { formattedValue } = tooltipItem;
|
|
49
|
-
const
|
|
50
|
+
const formattedValueWithDotSeparator = formattedValue.replace(',', '.');
|
|
51
|
+
const labelNumber = toNum(formattedValueWithDotSeparator);
|
|
50
52
|
|
|
51
53
|
let labelNumberFormatted;
|
|
52
54
|
if (Math.abs(labelNumber) < 1) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { round } from '@oliasoft-open-source/units';
|
|
1
2
|
import { defaults } from 'chart.js';
|
|
2
3
|
import cx from 'classnames';
|
|
3
4
|
import { chartMinorGridlinesPlugin } from '../components/line-chart/line-chart.minor-gridlines-plugin';
|
|
@@ -151,7 +152,7 @@ export const getLegend = (options, clickHandler, state = null) => {
|
|
|
151
152
|
|
|
152
153
|
export const afterLabelCallback = (tooltipItem) => {
|
|
153
154
|
const { error } = tooltipItem.dataset.data[tooltipItem?.dataIndex];
|
|
154
|
-
return error ? `Error: ${
|
|
155
|
+
return error ? `Error: ${round(error, 4)}` : '';
|
|
155
156
|
};
|
|
156
157
|
|
|
157
158
|
export const getTooltipLabel = (tooltipItem, showLabelsInTooltips) => {
|
|
@@ -1,25 +1,6 @@
|
|
|
1
|
+
import { round } from '@oliasoft-open-source/units';
|
|
1
2
|
import { DECIMAL_POINT_TOLERANCE } from '../chart-consts';
|
|
2
3
|
|
|
3
|
-
/**
|
|
4
|
-
* Rounds a number to N decimal places
|
|
5
|
-
*
|
|
6
|
-
* @param {number} v value
|
|
7
|
-
* @param {number} n decimal count
|
|
8
|
-
* @returns {number}
|
|
9
|
-
*/
|
|
10
|
-
export const roundN = (v, n) => {
|
|
11
|
-
const factor = 10 ** n;
|
|
12
|
-
return Math.round(v * factor) / factor;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Rounds a number to DECIMAL_POINT_TOLERANCE decimal places
|
|
17
|
-
*
|
|
18
|
-
* @param {number} v value
|
|
19
|
-
* @returns {number}
|
|
20
|
-
*/
|
|
21
|
-
export const round = (v) => roundN(v, DECIMAL_POINT_TOLERANCE);
|
|
22
|
-
|
|
23
4
|
/**
|
|
24
5
|
* Determines whether two numbers are close in value with a tolerance
|
|
25
6
|
* (mitigates excess JavaScript floating point precision quirks)
|
|
@@ -37,7 +18,7 @@ export const isEqualWithTolerance = (a, b) => {
|
|
|
37
18
|
if (typeof a == 'number' && typeof b === typeof a) {
|
|
38
19
|
const tolerance = 10 ** -DECIMAL_POINT_TOLERANCE;
|
|
39
20
|
const difference = Math.abs(b - a);
|
|
40
|
-
const roundedDifference =
|
|
21
|
+
const roundedDifference = round(difference, DECIMAL_POINT_TOLERANCE);
|
|
41
22
|
return roundedDifference <= tolerance;
|
|
42
23
|
}
|
|
43
24
|
return false;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { round } from '@oliasoft-open-source/units';
|
|
2
|
+
import { isEqualWithTolerance } from '../numbers/numbers';
|
|
3
|
+
import { DECIMAL_POINT_TOLERANCE } from '../chart-consts';
|
|
2
4
|
|
|
3
5
|
const whiteSpacePercentage = 0.05; // relative amount of white space on each "side" of the data points
|
|
4
6
|
|
|
@@ -54,9 +56,11 @@ export const getSuggestedAxisRange = ({
|
|
|
54
56
|
const padding = point * whiteSpacePercentage;
|
|
55
57
|
const minAxisValue = beginAtZero && !isNegative ? 0 : point - padding;
|
|
56
58
|
const maxAxisValue = beginAtZero && isNegative ? 0 : point + padding;
|
|
59
|
+
const roundedMinAxisValue = round(maxAxisValue, DECIMAL_POINT_TOLERANCE);
|
|
60
|
+
const roundedMaxAxisValue = round(minAxisValue, DECIMAL_POINT_TOLERANCE);
|
|
57
61
|
return {
|
|
58
|
-
min:
|
|
59
|
-
max:
|
|
62
|
+
min: roundedMinAxisValue < 0 ? roundedMinAxisValue : roundedMaxAxisValue,
|
|
63
|
+
max: roundedMaxAxisValue < 0 ? roundedMaxAxisValue : roundedMinAxisValue,
|
|
60
64
|
};
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -89,7 +93,7 @@ export const getSuggestedAxisRange = ({
|
|
|
89
93
|
: dataMax + padding;
|
|
90
94
|
|
|
91
95
|
return {
|
|
92
|
-
min: round(minAxisValue),
|
|
93
|
-
max: round(maxAxisValue),
|
|
96
|
+
min: round(minAxisValue, DECIMAL_POINT_TOLERANCE),
|
|
97
|
+
max: round(maxAxisValue, DECIMAL_POINT_TOLERANCE),
|
|
94
98
|
};
|
|
95
99
|
};
|