@oliasoft-open-source/charts-library 2.4.1 → 2.4.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 +1 -1
- package/release-notes.md +8 -0
- package/src/components/line-chart/Controls/Layer.jsx +2 -2
- package/src/components/line-chart/line-chart-utils.js +7 -3
- package/src/components/line-chart/line-chart.jsx +6 -9
- package/src/components/line-chart/line-chart.module.less +3 -3
- package/src/components/line-chart/line-chart.stories.jsx +43 -0
- package/src/components/line-chart/state/line-chart-reducer.js +6 -0
- package/src/helpers/chart-utils.js +0 -1
package/package.json
CHANGED
package/release-notes.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Charts Library Release Notes
|
|
2
2
|
|
|
3
|
+
## 2.4.3
|
|
4
|
+
|
|
5
|
+
- Fix crashes when type a non-number into the axis range OW-9924
|
|
6
|
+
|
|
7
|
+
## 2.4.2
|
|
8
|
+
|
|
9
|
+
- Square aspect ratio charts can fill height/width
|
|
10
|
+
|
|
3
11
|
## 2.4.1
|
|
4
12
|
|
|
5
13
|
- Remove dependency on http-server (moved to dev dependencies)
|
|
@@ -108,7 +108,7 @@ export const Layer = ({
|
|
|
108
108
|
value={axis.min.inputValue || scalesMaxMin[axis?.id]?.min}
|
|
109
109
|
error={
|
|
110
110
|
!axis.min.valid
|
|
111
|
-
? '
|
|
111
|
+
? 'Invalid value' //t(InputWarningType.MustBeNumericAndLessThanMax)
|
|
112
112
|
: undefined
|
|
113
113
|
}
|
|
114
114
|
size={5}
|
|
@@ -131,7 +131,7 @@ export const Layer = ({
|
|
|
131
131
|
value={axis.max.inputValue || scalesMaxMin[axis?.id].max}
|
|
132
132
|
error={
|
|
133
133
|
!axis.max.valid
|
|
134
|
-
? '
|
|
134
|
+
? 'Invalid value' //t(InputWarningType.MustBeNumericAndGreaterThanMin)
|
|
135
135
|
: undefined
|
|
136
136
|
}
|
|
137
137
|
size={5}
|
|
@@ -9,6 +9,7 @@ const hasDivisor = (str) =>
|
|
|
9
9
|
export const isEmptyString = (str) => str === '';
|
|
10
10
|
const isTrailingPeriodSeparator = (str) => str && str[str.length - 1] === '.';
|
|
11
11
|
const isTrailingCommaSeparator = (str) => str && str[str.length - 1] === ',';
|
|
12
|
+
const isOnlyNumbers = (str) => /^-?\d*\.?\d+$/.test(str);
|
|
12
13
|
|
|
13
14
|
export const charCount = (chr, str) => {
|
|
14
15
|
let total = 0,
|
|
@@ -80,7 +81,8 @@ export const isValidNum = (input) => {
|
|
|
80
81
|
isTrailingPeriodSeparator(input) ||
|
|
81
82
|
isTrailingCommaSeparator(input) ||
|
|
82
83
|
isArray(input) ||
|
|
83
|
-
isObject(input)
|
|
84
|
+
isObject(input) ||
|
|
85
|
+
!isOnlyNumbers(input)
|
|
84
86
|
)
|
|
85
87
|
) {
|
|
86
88
|
let number;
|
|
@@ -132,11 +134,13 @@ export const toNumber = (input, defaultValue, minimum) => {
|
|
|
132
134
|
return result;
|
|
133
135
|
};
|
|
134
136
|
|
|
135
|
-
export const validNumber = (value) =>
|
|
137
|
+
export const validNumber = (value) => {
|
|
138
|
+
return isValidNum(value);
|
|
139
|
+
};
|
|
136
140
|
|
|
137
141
|
export const toNum = (value) => {
|
|
138
142
|
const asNumber = toNumber(value);
|
|
139
|
-
return value === '' || isNaN(asNumber) ?
|
|
143
|
+
return value === '' || isNaN(asNumber) ? '' : asNumber;
|
|
140
144
|
};
|
|
141
145
|
|
|
142
146
|
export const isLessThanMax = (value, max) => {
|
|
@@ -383,14 +383,10 @@ const LineChart = (props) => {
|
|
|
383
383
|
return (
|
|
384
384
|
<div
|
|
385
385
|
className={getClassName(chartStyling, styles)}
|
|
386
|
-
style={
|
|
387
|
-
chartStyling.
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
width: chartStyling.width || AUTO,
|
|
391
|
-
height: chartStyling.height || AUTO,
|
|
392
|
-
}
|
|
393
|
-
}
|
|
386
|
+
style={{
|
|
387
|
+
width: chartStyling.width || AUTO,
|
|
388
|
+
height: chartStyling.height || AUTO,
|
|
389
|
+
}}
|
|
394
390
|
tabIndex={0} //eslint-disable-line jsx-a11y/no-noninteractive-tabindex
|
|
395
391
|
onKeyDown={handleKeyDown}
|
|
396
392
|
onKeyUp={handleKeyUp}
|
|
@@ -428,7 +424,8 @@ const LineChart = (props) => {
|
|
|
428
424
|
options={{
|
|
429
425
|
onClick,
|
|
430
426
|
onHover,
|
|
431
|
-
maintainAspectRatio:
|
|
427
|
+
maintainAspectRatio:
|
|
428
|
+
chartStyling.squareAspectRatio || chartStyling.maintainAspectRatio,
|
|
432
429
|
aspectRatio: chartStyling.squareAspectRatio ? 1 : null, // 1 equals square aspect ratio
|
|
433
430
|
animation: {
|
|
434
431
|
duration: chartStyling.performanceMode
|
|
@@ -149,6 +149,26 @@ const TemplateWithCustomLegendContainer = (args) => {
|
|
|
149
149
|
|
|
150
150
|
export const Default = Template.bind({});
|
|
151
151
|
|
|
152
|
+
export const FillContainer = Template.bind({});
|
|
153
|
+
FillContainer.args = {
|
|
154
|
+
chart: {
|
|
155
|
+
...basicChart,
|
|
156
|
+
options: {
|
|
157
|
+
...basicChart.options,
|
|
158
|
+
chartStyling: {
|
|
159
|
+
height: '100%',
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
FillContainer.decorators = [
|
|
165
|
+
(Story) => (
|
|
166
|
+
<div style={{ height: 400, width: 500 }}>
|
|
167
|
+
<Story />
|
|
168
|
+
</div>
|
|
169
|
+
),
|
|
170
|
+
];
|
|
171
|
+
|
|
152
172
|
export const DataGaps = Template.bind({});
|
|
153
173
|
DataGaps.args = {
|
|
154
174
|
chart: {
|
|
@@ -422,3 +442,26 @@ SquareAspectRatio.args = {
|
|
|
422
442
|
},
|
|
423
443
|
},
|
|
424
444
|
};
|
|
445
|
+
|
|
446
|
+
export const SquareAspectRatioFillContainer = Template.bind({});
|
|
447
|
+
SquareAspectRatioFillContainer.args = {
|
|
448
|
+
chart: {
|
|
449
|
+
...basicChart,
|
|
450
|
+
options: {
|
|
451
|
+
...basicChart.options,
|
|
452
|
+
title: 'Square aspect ratio',
|
|
453
|
+
chartStyling: {
|
|
454
|
+
squareAspectRatio: true,
|
|
455
|
+
maintainAspectRatio: true,
|
|
456
|
+
height: '100%',
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
},
|
|
460
|
+
};
|
|
461
|
+
SquareAspectRatioFillContainer.decorators = [
|
|
462
|
+
(Story) => (
|
|
463
|
+
<div style={{ display: 'flex', height: 400, width: 600 }}>
|
|
464
|
+
<Story />
|
|
465
|
+
</div>
|
|
466
|
+
),
|
|
467
|
+
];
|
|
@@ -75,6 +75,7 @@ export const reducer = (state, action) => {
|
|
|
75
75
|
const nextValue = isNaN(nextInputValue)
|
|
76
76
|
? cleanNumStr(nextInputValue)
|
|
77
77
|
: toNum(nextInputValue);
|
|
78
|
+
|
|
78
79
|
const axis = newState.axes.find((a) => a.id === id);
|
|
79
80
|
axis.min = getAxisValue(name === 'min' ? nextValue : axis.min?.value);
|
|
80
81
|
axis.max = getAxisValue(name === 'max' ? nextValue : axis.max?.value);
|
|
@@ -86,6 +87,11 @@ export const reducer = (state, action) => {
|
|
|
86
87
|
validNumber(axis.max.inputValue ?? '') &&
|
|
87
88
|
isGreaterThanMin(axis.max.value, axis.min.value);
|
|
88
89
|
axis.max.displayValue = axis.max.valid ? axis.max.value : undefined;
|
|
90
|
+
|
|
91
|
+
const elementValue = axis[name];
|
|
92
|
+
if (elementValue.valid) {
|
|
93
|
+
elementValue.value = nextValue;
|
|
94
|
+
}
|
|
89
95
|
};
|
|
90
96
|
if (Array.isArray(action.payload)) {
|
|
91
97
|
action.payload.forEach((element) => {
|