@oliasoft-open-source/charts-library 2.13.5 → 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 (35) hide show
  1. package/package.json +2 -2
  2. package/src/components/controls/axes-options/axes-options.jsx +43 -9
  3. package/src/components/line-chart/constants/default-translations.js +24 -0
  4. package/src/components/line-chart/{line-chart-consts.js → constants/line-chart-consts.js} +1 -0
  5. package/src/components/line-chart/controls/axes-options/action-types.js +5 -0
  6. package/src/components/{controls → line-chart/controls}/axes-options/axes-options-form-state.js +19 -20
  7. package/src/components/line-chart/controls/controls.jsx +174 -0
  8. package/src/components/line-chart/controls/drag-options.jsx +112 -0
  9. package/src/components/line-chart/controls/legend-options.jsx +36 -0
  10. package/src/components/{controls → line-chart/controls}/line-options.jsx +18 -8
  11. package/src/components/line-chart/hooks/use-chart-functions.js +257 -0
  12. package/src/components/line-chart/hooks/use-chart-options.js +155 -0
  13. package/src/components/line-chart/hooks/use-chart-plugins.js +26 -0
  14. package/src/components/line-chart/hooks/use-toggle-handler.js +33 -0
  15. package/src/components/line-chart/line-chart.jsx +53 -410
  16. package/src/components/line-chart/state/initial-state.js +7 -8
  17. package/src/components/line-chart/state/line-chart-reducer.js +68 -86
  18. package/src/components/line-chart/state/use-chart-state.js +2 -1
  19. package/src/components/line-chart/{axis-scales → utils/axis-scales}/axis-scales.js +3 -3
  20. package/src/components/line-chart/{datalabels-alignment → utils/datalabels-alignment}/get-datalabels-position.js +1 -1
  21. package/src/components/line-chart/utils/generate-line-chart-datasets.js +114 -0
  22. package/src/components/line-chart/{get-line-chart-data-labels.js → utils/get-line-chart-data-labels.js} +2 -2
  23. package/src/components/line-chart/{get-line-chart-scales.js → utils/get-line-chart-scales.js} +11 -11
  24. package/src/components/line-chart/{get-line-chart-tooltips.js → utils/get-line-chart-tooltips.js} +6 -3
  25. package/src/components/line-chart/utils/get-translations/get-translations.js +17 -0
  26. package/src/helpers/chart-utils.js +3 -5
  27. package/src/helpers/enums.js +9 -0
  28. package/src/components/controls/controls.jsx +0 -114
  29. package/src/components/controls/drag-options.jsx +0 -98
  30. package/src/components/controls/legend-options.jsx +0 -25
  31. /package/src/components/{controls → line-chart/controls}/controls.module.less +0 -0
  32. /package/src/components/line-chart/{datalabels-alignment → utils/datalabels-alignment}/get-alignment-condition.js +0 -0
  33. /package/src/components/line-chart/{datalabels-alignment → utils/datalabels-alignment}/get-alignment-data.js +0 -0
  34. /package/src/components/line-chart/{get-axes-ranges-from-chart.js → utils/get-axes-ranges-from-chart.js} +0 -0
  35. /package/src/components/line-chart/{line-chart-utils.js → utils/line-chart-utils.js} +0 -0
@@ -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
- };