@oliasoft-open-source/charts-library 2.5.9 → 2.5.11
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/controls/axes-options.jsx +11 -2
- package/src/components/controls/controls.jsx +2 -1
- package/src/components/line-chart/line-chart-utils.js +3 -1
- package/src/components/line-chart/line-chart.jsx +4 -4
- package/src/components/line-chart/line-chart.stories.jsx +53 -12
- package/src/components/line-chart/state/line-chart-reducer.js +9 -2
package/package.json
CHANGED
package/release-notes.md
CHANGED
|
@@ -25,6 +25,7 @@ const AxesOptionsPopover = ({
|
|
|
25
25
|
axes.filter((axis) => axis.max.displayValue || axis.min.displayValue)
|
|
26
26
|
.length > 0;
|
|
27
27
|
const handleInputFocus = (e) => e.target.select();
|
|
28
|
+
const zoomOrPanEnabled = zoomEnabled || panEnabled;
|
|
28
29
|
return (
|
|
29
30
|
<>
|
|
30
31
|
{axes.map((axis, i) => {
|
|
@@ -36,7 +37,11 @@ const AxesOptionsPopover = ({
|
|
|
36
37
|
<Input
|
|
37
38
|
name="min"
|
|
38
39
|
// TODO: Fix input values not updating first time when scales reset
|
|
39
|
-
value={
|
|
40
|
+
value={
|
|
41
|
+
(zoomOrPanEnabled
|
|
42
|
+
? axis.min.displayValue
|
|
43
|
+
: axis.min.inputValue) || scalesMaxMin[axis?.id]?.min
|
|
44
|
+
}
|
|
40
45
|
error={
|
|
41
46
|
!axis.min.valid
|
|
42
47
|
? 'Invalid value' //t(InputWarningType.MustBeNumericAndLessThanMax)
|
|
@@ -61,7 +66,11 @@ const AxesOptionsPopover = ({
|
|
|
61
66
|
<Input
|
|
62
67
|
name="max"
|
|
63
68
|
// TODO: Fix input values not updating first time when scales reset
|
|
64
|
-
value={
|
|
69
|
+
value={
|
|
70
|
+
(zoomOrPanEnabled
|
|
71
|
+
? axis.max.displayValue
|
|
72
|
+
: axis.max.inputValue) || scalesMaxMin[axis?.id]?.max
|
|
73
|
+
}
|
|
65
74
|
error={
|
|
66
75
|
!axis.max.valid
|
|
67
76
|
? 'Invalid value' //t(InputWarningType.MustBeNumericAndGreaterThanMin)
|
|
@@ -37,7 +37,8 @@ const Controls = ({
|
|
|
37
37
|
return (
|
|
38
38
|
<>
|
|
39
39
|
<div className={styles.controls}>
|
|
40
|
-
{
|
|
40
|
+
{!!chart.options.title && <Text bold>{chart.options.title}</Text>}
|
|
41
|
+
{headerComponent}
|
|
41
42
|
<div className={styles.buttons}>
|
|
42
43
|
{!showTable && (
|
|
43
44
|
<>
|
|
@@ -150,7 +150,9 @@ export const isLessThanMax = (value, max) => {
|
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
export const isGreaterThanMin = (value, min) => {
|
|
153
|
-
return
|
|
153
|
+
return (
|
|
154
|
+
value === undefined || min === undefined || Number(value) > Number(min)
|
|
155
|
+
);
|
|
154
156
|
};
|
|
155
157
|
|
|
156
158
|
/**
|
|
@@ -346,22 +346,22 @@ const LineChart = (props) => {
|
|
|
346
346
|
payload: [
|
|
347
347
|
{
|
|
348
348
|
name: 'min',
|
|
349
|
-
value: chart.scales?.x?.min ? chart.scales.x.min
|
|
349
|
+
value: chart.scales?.x?.min ? chart.scales.x.min : 0,
|
|
350
350
|
id: 'x',
|
|
351
351
|
},
|
|
352
352
|
{
|
|
353
353
|
name: 'max',
|
|
354
|
-
value: chart.scales?.x?.max ? chart.scales.x.max
|
|
354
|
+
value: chart.scales?.x?.max ? chart.scales.x.max : 0,
|
|
355
355
|
id: 'x',
|
|
356
356
|
},
|
|
357
357
|
{
|
|
358
358
|
name: 'min',
|
|
359
|
-
value: chart.scales?.y?.min ? chart.scales.y.min
|
|
359
|
+
value: chart.scales?.y?.min ? chart.scales.y.min : 0,
|
|
360
360
|
id: 'y',
|
|
361
361
|
},
|
|
362
362
|
{
|
|
363
363
|
name: 'max',
|
|
364
|
-
value: chart.scales?.y?.max ? chart.scales.y.max
|
|
364
|
+
value: chart.scales?.y?.max ? chart.scales.y.max : 0,
|
|
365
365
|
id: 'y',
|
|
366
366
|
},
|
|
367
367
|
],
|
|
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
Flex,
|
|
4
4
|
Menu,
|
|
5
|
+
Select,
|
|
5
6
|
Slider,
|
|
6
7
|
Table,
|
|
7
8
|
Text,
|
|
@@ -461,7 +462,7 @@ SquareAspectRatio.args = {
|
|
|
461
462
|
},
|
|
462
463
|
};
|
|
463
464
|
|
|
464
|
-
export const
|
|
465
|
+
export const HeaderComponentNoTitle = (args) => {
|
|
465
466
|
const options = ['Category A', 'Category B', 'Category C'];
|
|
466
467
|
|
|
467
468
|
const suboptions = ['Chart 1', 'Chart 2', 'Chart 3'];
|
|
@@ -482,7 +483,7 @@ export const HeaderComponent = (args) => {
|
|
|
482
483
|
|
|
483
484
|
const chart = {
|
|
484
485
|
...basicChart,
|
|
485
|
-
options: { ...basicChart.options, title:
|
|
486
|
+
options: { ...basicChart.options, title: null },
|
|
486
487
|
};
|
|
487
488
|
|
|
488
489
|
return (
|
|
@@ -521,21 +522,53 @@ export const HeaderComponent = (args) => {
|
|
|
521
522
|
/>
|
|
522
523
|
);
|
|
523
524
|
};
|
|
525
|
+
HeaderComponentNoTitle.parameters = {
|
|
526
|
+
docs: {
|
|
527
|
+
description: {
|
|
528
|
+
story:
|
|
529
|
+
'If no chart title is set, a `headerComponent` can take its place.',
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
};
|
|
524
533
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
534
|
+
const testComponent = (
|
|
535
|
+
<div
|
|
536
|
+
style={{
|
|
537
|
+
flexGrow: 1,
|
|
538
|
+
minWidth: 280,
|
|
539
|
+
margin: '-9px 0',
|
|
540
|
+
display: 'flex',
|
|
541
|
+
alignItems: 'center',
|
|
542
|
+
}}
|
|
543
|
+
>
|
|
544
|
+
<Select
|
|
545
|
+
options={['Aardvarks', 'Kangaroos']}
|
|
546
|
+
value="Aardvarks"
|
|
547
|
+
small
|
|
548
|
+
width="90px"
|
|
549
|
+
autoLayerWidth
|
|
550
|
+
/>
|
|
551
|
+
<Slider max={100} min={0} onChange={() => {}} showArrows value={50} />
|
|
552
|
+
<Text>180s</Text>
|
|
553
|
+
</div>
|
|
554
|
+
);
|
|
555
|
+
|
|
556
|
+
export const HeaderComponentWithTitle = Template.bind({});
|
|
557
|
+
HeaderComponentWithTitle.args = {
|
|
558
|
+
headerComponent: testComponent,
|
|
559
|
+
};
|
|
560
|
+
HeaderComponentWithTitle.parameters = {
|
|
561
|
+
docs: {
|
|
562
|
+
description: {
|
|
563
|
+
story:
|
|
564
|
+
"If a chart title is set, the `headerComponent` will be displayed to the right of it. Setting a `minWidth` on the `headerComponent` will make sure it isn't squashed.",
|
|
565
|
+
},
|
|
566
|
+
},
|
|
532
567
|
};
|
|
533
568
|
|
|
534
569
|
export const SubheaderComponent = Template.bind({});
|
|
535
570
|
SubheaderComponent.args = {
|
|
536
|
-
subheaderComponent:
|
|
537
|
-
<Slider max={100} min={0} onChange={() => {}} showArrows value={50} />
|
|
538
|
-
),
|
|
571
|
+
subheaderComponent: testComponent,
|
|
539
572
|
};
|
|
540
573
|
|
|
541
574
|
const table = {
|
|
@@ -576,6 +609,14 @@ const table = {
|
|
|
576
609
|
},
|
|
577
610
|
],
|
|
578
611
|
};
|
|
612
|
+
SubheaderComponent.parameters = {
|
|
613
|
+
docs: {
|
|
614
|
+
description: {
|
|
615
|
+
story:
|
|
616
|
+
'This will be displayed between the title/controls and the chart itself.',
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
};
|
|
579
620
|
|
|
580
621
|
export const WithTable = (args) => {
|
|
581
622
|
return <LineChart chart={basicChart} table={<Table table={table} />} />;
|
|
@@ -87,11 +87,18 @@ export const reducer = (state, action) => {
|
|
|
87
87
|
axis.min.valid =
|
|
88
88
|
validNumber(axis.min.inputValue ?? '') &&
|
|
89
89
|
isLessThanMax(axis.min.value, axis.max.value);
|
|
90
|
-
axis.min.displayValue =
|
|
90
|
+
axis.min.displayValue =
|
|
91
|
+
axis.min.valid && axis.min.value
|
|
92
|
+
? Number(axis.min.value).toFixed(1)
|
|
93
|
+
: undefined;
|
|
94
|
+
|
|
91
95
|
axis.max.valid =
|
|
92
96
|
validNumber(axis.max.inputValue ?? '') &&
|
|
93
97
|
isGreaterThanMin(axis.max.value, axis.min.value);
|
|
94
|
-
axis.max.displayValue =
|
|
98
|
+
axis.max.displayValue =
|
|
99
|
+
axis.max.valid && axis.max.value
|
|
100
|
+
? Number(axis.max.value).toFixed(1)
|
|
101
|
+
: undefined;
|
|
95
102
|
|
|
96
103
|
const elementValue = axis[name];
|
|
97
104
|
if (elementValue.valid) {
|