@oliasoft-open-source/charts-library 2.13.4 → 2.14.0-beta-1

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.
Files changed (36) hide show
  1. package/package.json +2 -2
  2. package/release-notes.md +4 -0
  3. package/src/components/controls/axes-options/axes-options.jsx +43 -9
  4. package/src/components/line-chart/constants/default-translations.js +24 -0
  5. package/src/components/line-chart/{line-chart-consts.js → constants/line-chart-consts.js} +1 -0
  6. package/src/components/line-chart/controls/axes-options/action-types.js +5 -0
  7. package/src/components/{controls → line-chart/controls}/axes-options/axes-options-form-state.js +19 -20
  8. package/src/components/line-chart/controls/controls.jsx +174 -0
  9. package/src/components/line-chart/controls/drag-options.jsx +112 -0
  10. package/src/components/line-chart/controls/legend-options.jsx +36 -0
  11. package/src/components/{controls → line-chart/controls}/line-options.jsx +18 -8
  12. package/src/components/line-chart/hooks/use-chart-functions.js +257 -0
  13. package/src/components/line-chart/hooks/use-chart-options.js +155 -0
  14. package/src/components/line-chart/hooks/use-chart-plugins.js +26 -0
  15. package/src/components/line-chart/hooks/use-toggle-handler.js +33 -0
  16. package/src/components/line-chart/line-chart.jsx +54 -447
  17. package/src/components/line-chart/state/initial-state.js +7 -8
  18. package/src/components/line-chart/state/line-chart-reducer.js +68 -86
  19. package/src/components/line-chart/state/use-chart-state.js +73 -12
  20. package/src/components/line-chart/{axis-scales → utils/axis-scales}/axis-scales.js +3 -3
  21. package/src/components/line-chart/{datalabels-alignment → utils/datalabels-alignment}/get-datalabels-position.js +1 -1
  22. package/src/components/line-chart/utils/generate-line-chart-datasets.js +114 -0
  23. package/src/components/line-chart/{get-line-chart-data-labels.js → utils/get-line-chart-data-labels.js} +2 -2
  24. package/src/components/line-chart/{get-line-chart-scales.js → utils/get-line-chart-scales.js} +11 -11
  25. package/src/components/line-chart/{get-line-chart-tooltips.js → utils/get-line-chart-tooltips.js} +6 -3
  26. package/src/components/line-chart/utils/get-translations/get-translations.js +17 -0
  27. package/src/helpers/chart-utils.js +3 -5
  28. package/src/helpers/enums.js +9 -0
  29. package/src/components/controls/controls.jsx +0 -114
  30. package/src/components/controls/drag-options.jsx +0 -98
  31. package/src/components/controls/legend-options.jsx +0 -25
  32. /package/src/components/{controls → line-chart/controls}/controls.module.less +0 -0
  33. /package/src/components/line-chart/{datalabels-alignment → utils/datalabels-alignment}/get-alignment-condition.js +0 -0
  34. /package/src/components/line-chart/{datalabels-alignment → utils/datalabels-alignment}/get-alignment-data.js +0 -0
  35. /package/src/components/line-chart/{get-axes-ranges-from-chart.js → utils/get-axes-ranges-from-chart.js} +0 -0
  36. /package/src/components/line-chart/{line-chart-utils.js → utils/line-chart-utils.js} +0 -0
@@ -1,114 +0,0 @@
1
- import React from 'react';
2
- import { Button, Text, Tooltip } from '@oliasoft-open-source/react-ui-library';
3
- import {
4
- RiFileDownloadLine,
5
- RiLineChartLine,
6
- RiTableLine,
7
- } from 'react-icons/ri';
8
- import { LineOptions } from './line-options';
9
- import { DragOptions } from './drag-options';
10
- import { AxesOptions } from './axes-options/axes-options';
11
- import { LegendOptions } from './legend-options';
12
- import styles from './controls.module.less';
13
-
14
- const Controls = ({
15
- axes,
16
- controlsAxesLabels,
17
- chart,
18
- headerComponent,
19
- legendEnabled,
20
- lineEnabled,
21
- onDownload,
22
- onResetAxes,
23
- onUpdateAxes,
24
- onToggleLegend,
25
- onToggleLine,
26
- onTogglePan,
27
- onTogglePoints,
28
- onToggleTable,
29
- onToggleZoom,
30
- panEnabled,
31
- pointsEnabled,
32
- initialAxesRanges,
33
- showTable,
34
- subheaderComponent,
35
- table,
36
- zoomEnabled,
37
- depthType,
38
- enableDragPoints,
39
- isDragDataAllowed,
40
- onToggleDragPoints,
41
- onDisableDragOptions,
42
- }) => {
43
- return (
44
- <>
45
- <div className={styles.controls}>
46
- {!!chart.options.title && <Text bold>{chart.options.title}</Text>}
47
- {headerComponent}
48
- <div className={styles.buttons}>
49
- {!showTable && (
50
- <>
51
- <AxesOptions
52
- initialAxesRanges={initialAxesRanges}
53
- axes={axes}
54
- controlsAxesLabels={controlsAxesLabels}
55
- onUpdateAxes={onUpdateAxes}
56
- onResetAxes={onResetAxes}
57
- depthType={depthType}
58
- />
59
- <LineOptions
60
- lineEnabled={lineEnabled}
61
- pointsEnabled={pointsEnabled}
62
- onToggleLine={onToggleLine}
63
- onTogglePoints={onTogglePoints}
64
- />
65
- <LegendOptions
66
- legendEnabled={legendEnabled}
67
- onToggleLegend={onToggleLegend}
68
- />
69
- <Tooltip text="Download as PNG" placement="bottom-end">
70
- <Button
71
- small
72
- basic
73
- colored="muted"
74
- round
75
- icon={<RiFileDownloadLine />}
76
- onClick={onDownload}
77
- />
78
- </Tooltip>
79
- <DragOptions
80
- panEnabled={panEnabled}
81
- zoomEnabled={zoomEnabled}
82
- onTogglePan={onTogglePan}
83
- onToggleZoom={onToggleZoom}
84
- enableDragPoints={enableDragPoints}
85
- isDragDataAllowed={isDragDataAllowed}
86
- onToggleDragPoints={onToggleDragPoints}
87
- onDisableDragOptions={onDisableDragOptions}
88
- />
89
- </>
90
- )}
91
-
92
- {table ? (
93
- <Tooltip
94
- text={showTable ? 'Show chart' : 'Show table'}
95
- placement="bottom-end"
96
- >
97
- <Button
98
- small
99
- basic
100
- colored="muted"
101
- round
102
- icon={showTable ? <RiLineChartLine /> : <RiTableLine />}
103
- onClick={onToggleTable}
104
- />
105
- </Tooltip>
106
- ) : null}
107
- </div>
108
- </div>
109
- {subheaderComponent}
110
- </>
111
- );
112
- };
113
-
114
- export default Controls;
@@ -1,98 +0,0 @@
1
- import React from 'react';
2
- import {
3
- Button,
4
- Flex,
5
- Menu,
6
- Text,
7
- Tooltip,
8
- } from '@oliasoft-open-source/react-ui-library';
9
- import { RiDragMove2Line, RiForbidLine, RiZoomInLine } from 'react-icons/ri';
10
- import { TbHandStop } from 'react-icons/tb';
11
-
12
- export const DragOptions = ({
13
- onTogglePan,
14
- onToggleZoom,
15
- panEnabled,
16
- zoomEnabled,
17
- enableDragPoints,
18
- isDragDataAllowed,
19
- onToggleDragPoints,
20
- onDisableDragOptions,
21
- }) => {
22
- // TODO: Translate strings
23
- const options = [
24
- {
25
- buttonLabel: 'Drag to zoom',
26
- label: (
27
- <Flex direction="column">
28
- <Text>Drag to zoom</Text>
29
- {/* <Text small muted>
30
- Hold shift to change axis
31
- </Text> */}
32
- <Text small muted>
33
- Double click on canvas to reset
34
- </Text>
35
- </Flex>
36
- ),
37
- icon: <RiZoomInLine />,
38
- selected: zoomEnabled,
39
- onClick: onToggleZoom,
40
- },
41
- {
42
- buttonLabel: 'Drag to pan',
43
- label: (
44
- <Flex direction="column">
45
- <Text>Drag to pan</Text>
46
- {/* <Text small muted>
47
- Hold shift to change axis
48
- </Text> */}
49
- <Text small muted>
50
- Double click on canvas to reset
51
- </Text>
52
- </Flex>
53
- ),
54
- icon: <RiDragMove2Line />,
55
- selected: panEnabled,
56
- onClick: onTogglePan,
57
- },
58
- ...(isDragDataAllowed
59
- ? [
60
- {
61
- label: 'Drag to move points',
62
- icon: <TbHandStop />,
63
- selected: enableDragPoints,
64
- type: 'Option',
65
- onClick: onToggleDragPoints,
66
- },
67
- ]
68
- : []),
69
- {
70
- label: 'Drag disabled',
71
- icon: <RiForbidLine />,
72
- selected: !zoomEnabled && !panEnabled && !enableDragPoints,
73
- onClick: onDisableDragOptions,
74
- },
75
- ];
76
-
77
- const selectedOption = options.filter((option) => option.selected)[0];
78
- const optionsWithDragPoints = options.map(
79
- ({ icon, label, onClick, selected }) => ({
80
- icon,
81
- label,
82
- type: 'Option',
83
- onClick,
84
- disabled: selected,
85
- }),
86
- );
87
-
88
- return (
89
- <Menu
90
- menu={{
91
- label: selectedOption.buttonLabel || selectedOption.label,
92
- sections: optionsWithDragPoints,
93
- trigger: 'DropDownButton',
94
- small: true,
95
- }}
96
- />
97
- );
98
- };
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import { Button, Icon, Tooltip } from '@oliasoft-open-source/react-ui-library';
3
- import { RiListUnordered } from 'react-icons/ri';
4
- import listHideIcon from '../../assets/icons/list-hide.svg';
5
-
6
- export const LegendOptions = ({ legendEnabled, onToggleLegend }) => {
7
- // TODO: Translate strings
8
- return (
9
- <Tooltip
10
- text={legendEnabled ? 'Legend shown' : 'Legend hidden'}
11
- placement="bottom"
12
- >
13
- <Button
14
- small
15
- basic
16
- colored="muted"
17
- round
18
- icon={
19
- legendEnabled ? <RiListUnordered /> : <Icon icon={listHideIcon} />
20
- }
21
- onClick={onToggleLegend}
22
- />
23
- </Tooltip>
24
- );
25
- };