@oliasoft-open-source/charts-library 3.3.6-beta-5 → 3.3.6
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/dist/index.js +39230 -0
- package/dist/index.js.map +1 -0
- package/package.json +6 -1
- package/index.js +0 -14
- package/release-notes.md +0 -378
- package/src/assets/circle.svg +0 -1
- package/src/assets/icons/line-and-point.svg +0 -1
- package/src/assets/icons/line-only.svg +0 -1
- package/src/assets/icons/list-hide.svg +0 -1
- package/src/assets/icons/point-only.svg +0 -1
- package/src/assets/rect.svg +0 -1
- package/src/assets/rectRot.svg +0 -1
- package/src/assets/triangle.svg +0 -1
- package/src/components/bar-chart/bar-chart-prop-types.js +0 -209
- package/src/components/bar-chart/bar-chart.interface.ts +0 -98
- package/src/components/bar-chart/bar-chart.jsx +0 -247
- package/src/components/bar-chart/bar-chart.module.less +0 -61
- package/src/components/bar-chart/get-bar-chart-data-labels.js +0 -42
- package/src/components/bar-chart/get-bar-chart-scales.js +0 -138
- package/src/components/bar-chart/get-bar-chart-tooltips.js +0 -102
- package/src/components/controls/axes-options/axes-options.jsx +0 -271
- package/src/components/line-chart/constants/default-translations.js +0 -24
- package/src/components/line-chart/constants/line-chart-consts.js +0 -12
- package/src/components/line-chart/controls/axes-options/action-types.js +0 -5
- package/src/components/line-chart/controls/axes-options/axes-options-form-state.js +0 -97
- package/src/components/line-chart/controls/controls-portal.jsx +0 -12
- package/src/components/line-chart/controls/controls.jsx +0 -176
- package/src/components/line-chart/controls/controls.module.less +0 -12
- package/src/components/line-chart/controls/drag-options.jsx +0 -124
- package/src/components/line-chart/controls/line-options.jsx +0 -64
- package/src/components/line-chart/hooks/use-chart-functions.js +0 -261
- package/src/components/line-chart/hooks/use-chart-options.js +0 -181
- package/src/components/line-chart/hooks/use-chart-plugins.js +0 -35
- package/src/components/line-chart/hooks/use-toggle-handler.js +0 -33
- package/src/components/line-chart/initialize/config.js +0 -23
- package/src/components/line-chart/initialize/initialize-line-chart.js +0 -25
- package/src/components/line-chart/legend/legend-constants.js +0 -1
- package/src/components/line-chart/legend/legend-dropzone.jsx +0 -74
- package/src/components/line-chart/legend/legend-item.jsx +0 -105
- package/src/components/line-chart/legend/legend-panel.jsx +0 -86
- package/src/components/line-chart/legend/legend.jsx +0 -54
- package/src/components/line-chart/legend/legend.module.less +0 -192
- package/src/components/line-chart/line-chart-prop-types.js +0 -298
- package/src/components/line-chart/line-chart.interface.ts +0 -128
- package/src/components/line-chart/line-chart.jsx +0 -180
- package/src/components/line-chart/line-chart.module.less +0 -78
- package/src/components/line-chart/plugins/chart-area-text-plugin.js +0 -246
- package/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.js +0 -88
- package/src/components/line-chart/plugins/plugin-constants.js +0 -11
- package/src/components/line-chart/state/action-types.js +0 -12
- package/src/components/line-chart/state/initial-state.js +0 -89
- package/src/components/line-chart/state/line-chart-reducer.js +0 -101
- package/src/components/line-chart/state/manage-state-in-local-storage.js +0 -86
- package/src/components/line-chart/state/use-chart-state.js +0 -141
- package/src/components/line-chart/utils/axis-formatting/axis-formatting.js +0 -69
- package/src/components/line-chart/utils/axis-scales/axis-scales.js +0 -165
- package/src/components/line-chart/utils/datalabels-alignment/get-alignment-condition.js +0 -13
- package/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.js +0 -20
- package/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.js +0 -25
- package/src/components/line-chart/utils/generate-line-chart-datasets.js +0 -122
- package/src/components/line-chart/utils/get-axes-ranges-from-chart.js +0 -13
- package/src/components/line-chart/utils/get-line-chart-data-labels.js +0 -21
- package/src/components/line-chart/utils/get-line-chart-scales.js +0 -117
- package/src/components/line-chart/utils/get-line-chart-tooltips.js +0 -94
- package/src/components/line-chart/utils/line-chart-utils.js +0 -62
- package/src/components/line-chart/utils/translations/get-translations.js +0 -17
- package/src/components/pie-chart/pie-chart-prop-types.js +0 -111
- package/src/components/pie-chart/pie-chart-utils.js +0 -32
- package/src/components/pie-chart/pie-chart.interface.ts +0 -61
- package/src/components/pie-chart/pie-chart.jsx +0 -458
- package/src/components/pie-chart/pie-chart.module.less +0 -61
- package/src/components/scatter-chart/scatter-chart.intefrace.ts +0 -33
- package/src/components/scatter-chart/scatter-chart.jsx +0 -21
- package/src/components/scatter-chart/scatter-chart.module.less +0 -4
- package/src/helpers/chart-border-plugin.js +0 -19
- package/src/helpers/chart-consts.js +0 -64
- package/src/helpers/chart-interface.ts +0 -94
- package/src/helpers/chart-utils.js +0 -178
- package/src/helpers/container.jsx +0 -60
- package/src/helpers/disabled-context.js +0 -8
- package/src/helpers/enums.js +0 -107
- package/src/helpers/get-chart-annotation.js +0 -102
- package/src/helpers/get-custom-legend-plugin-example.js +0 -80
- package/src/helpers/get-draggableData.js +0 -32
- package/src/helpers/range/estimate-data-series-have-close-values.js +0 -54
- package/src/helpers/range/range.js +0 -100
- package/src/helpers/text.js +0 -6
- package/src/style/external.less +0 -4
- package/src/style/fonts/lato/Lato-Bold.woff2 +0 -0
- package/src/style/fonts/lato/Lato-BoldItalic.woff2 +0 -0
- package/src/style/fonts/lato/Lato-Italic.woff2 +0 -0
- package/src/style/fonts/lato/Lato-Regular.woff2 +0 -0
- package/src/style/fonts.less +0 -27
- package/src/style/global.less +0 -43
- package/src/style/reset/reset.less +0 -28
- package/src/style/shared.less +0 -11
- package/src/style/variables.less +0 -91
- package/vite.config.mjs +0 -49
- package/vitest.config.mjs +0 -8
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import React, { useReducer, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Button,
|
|
4
|
-
ButtonGroup,
|
|
5
|
-
Field,
|
|
6
|
-
Flex,
|
|
7
|
-
NumberInput,
|
|
8
|
-
InputGroup,
|
|
9
|
-
InputGroupAddon,
|
|
10
|
-
Popover,
|
|
11
|
-
Select,
|
|
12
|
-
Spacer,
|
|
13
|
-
Text,
|
|
14
|
-
Tooltip,
|
|
15
|
-
} from '@oliasoft-open-source/react-ui-library';
|
|
16
|
-
import { RiRuler2Line } from 'react-icons/ri';
|
|
17
|
-
import PropTypes from 'prop-types';
|
|
18
|
-
import { toNum } from '@oliasoft-open-source/units';
|
|
19
|
-
import {
|
|
20
|
-
initializeFormState,
|
|
21
|
-
reducer,
|
|
22
|
-
validateAxes,
|
|
23
|
-
} from '../../line-chart/controls/axes-options/axes-options-form-state';
|
|
24
|
-
import { actionTypes } from '../../line-chart/controls/axes-options/action-types';
|
|
25
|
-
|
|
26
|
-
const AxesOptionsPopover = ({
|
|
27
|
-
initialAxesRanges,
|
|
28
|
-
axes,
|
|
29
|
-
controlsAxesLabels,
|
|
30
|
-
onUpdateAxes,
|
|
31
|
-
onResetAxes,
|
|
32
|
-
close,
|
|
33
|
-
depthType,
|
|
34
|
-
translations,
|
|
35
|
-
}) => {
|
|
36
|
-
const [depthTypeState, setDepthTypeState] = useState(
|
|
37
|
-
depthType?.selectedDepthType,
|
|
38
|
-
);
|
|
39
|
-
const [formState, dispatch] = useReducer(
|
|
40
|
-
reducer,
|
|
41
|
-
{
|
|
42
|
-
axes,
|
|
43
|
-
initialAxesRanges,
|
|
44
|
-
},
|
|
45
|
-
initializeFormState,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const { errors, valid } = validateAxes(formState);
|
|
49
|
-
|
|
50
|
-
const onEditValue = ({ name, value, id }) => {
|
|
51
|
-
dispatch({
|
|
52
|
-
type: actionTypes.valueUpdated,
|
|
53
|
-
payload: { name, value, id },
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const onEditUnit = ({ name, value, id }) => {
|
|
58
|
-
dispatch({
|
|
59
|
-
type: actionTypes.unitUpdated,
|
|
60
|
-
payload: { name, value, id },
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const onDone = (e) => {
|
|
65
|
-
e.preventDefault();
|
|
66
|
-
if (valid) {
|
|
67
|
-
const sanitizedFormState = formState.map((axis) => ({
|
|
68
|
-
...axis,
|
|
69
|
-
min: toNum(axis.min),
|
|
70
|
-
max: toNum(axis.max),
|
|
71
|
-
}));
|
|
72
|
-
onUpdateAxes({
|
|
73
|
-
axes: sanitizedFormState,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
//update units
|
|
77
|
-
sanitizedFormState.map((el, i) => {
|
|
78
|
-
if (el.unit?.selectedUnit) {
|
|
79
|
-
axes[i].unit.setSelectedUnit(el.unit.selectedUnit);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
//update depthType
|
|
83
|
-
if (depthType) {
|
|
84
|
-
depthType.setSelectedDepthType(depthTypeState);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
close();
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const onReset = () => {
|
|
91
|
-
//reset local form
|
|
92
|
-
dispatch({
|
|
93
|
-
type: actionTypes.reset,
|
|
94
|
-
payload: { axes, initialAxesRanges },
|
|
95
|
-
});
|
|
96
|
-
//update units
|
|
97
|
-
initialAxesRanges.map((el, i) => {
|
|
98
|
-
if (el?.unit?.selectedUnit) {
|
|
99
|
-
axes[i].unit.setSelectedUnit(el.unit.selectedUnit);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
//reset parent state
|
|
104
|
-
onResetAxes();
|
|
105
|
-
close();
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const isCustomValue = axes.filter((axis) => axis.max || axis.min).length > 0;
|
|
109
|
-
const handleInputFocus = (e) => e.target.select();
|
|
110
|
-
return (
|
|
111
|
-
<form onSubmit={onDone}>
|
|
112
|
-
{axes.map((axis, i) => {
|
|
113
|
-
const axisLabel = controlsAxesLabels.find(
|
|
114
|
-
(el) => el.id === axis.id,
|
|
115
|
-
)?.label;
|
|
116
|
-
|
|
117
|
-
const min = formState.find((a) => a.id === axis.id)?.min;
|
|
118
|
-
const max = formState.find((a) => a.id === axis.id)?.max;
|
|
119
|
-
const minError = errors?.find((a) => a.id === axis.id)?.min?.[0];
|
|
120
|
-
const maxError = errors?.find((a) => a.id === axis.id)?.max?.[0];
|
|
121
|
-
const unit = formState.find((a) => a.id === axis.id)?.unit;
|
|
122
|
-
return (
|
|
123
|
-
<Field key={i} label={axisLabel || axis.id || ''}>
|
|
124
|
-
<InputGroup small width="300px">
|
|
125
|
-
<NumberInput
|
|
126
|
-
name="min"
|
|
127
|
-
value={min}
|
|
128
|
-
error={translations[minError]}
|
|
129
|
-
size={5}
|
|
130
|
-
width="100%"
|
|
131
|
-
onChange={(evt) =>
|
|
132
|
-
onEditValue({
|
|
133
|
-
name: evt.target.name,
|
|
134
|
-
value: evt.target.value,
|
|
135
|
-
id: axis.id,
|
|
136
|
-
})
|
|
137
|
-
}
|
|
138
|
-
onFocus={handleInputFocus}
|
|
139
|
-
/>
|
|
140
|
-
<InputGroupAddon>to</InputGroupAddon>
|
|
141
|
-
<NumberInput
|
|
142
|
-
name="max"
|
|
143
|
-
value={max}
|
|
144
|
-
error={translations[maxError]}
|
|
145
|
-
size={5}
|
|
146
|
-
width="100%"
|
|
147
|
-
onChange={(evt) =>
|
|
148
|
-
onEditValue({
|
|
149
|
-
name: evt.target.name,
|
|
150
|
-
value: evt.target.value,
|
|
151
|
-
id: axis.id,
|
|
152
|
-
})
|
|
153
|
-
}
|
|
154
|
-
onFocus={handleInputFocus}
|
|
155
|
-
/>
|
|
156
|
-
{axis.unit ? (
|
|
157
|
-
<Select
|
|
158
|
-
name="selectedUnit"
|
|
159
|
-
options={axis?.unit?.options}
|
|
160
|
-
value={unit?.selectedUnit}
|
|
161
|
-
onChange={(e) => {
|
|
162
|
-
onEditUnit({
|
|
163
|
-
name: e.target.name,
|
|
164
|
-
value: e.target.value,
|
|
165
|
-
id: axis.id,
|
|
166
|
-
});
|
|
167
|
-
}}
|
|
168
|
-
autoLayerWidth
|
|
169
|
-
width="15%"
|
|
170
|
-
/>
|
|
171
|
-
) : null}
|
|
172
|
-
</InputGroup>
|
|
173
|
-
</Field>
|
|
174
|
-
);
|
|
175
|
-
})}
|
|
176
|
-
|
|
177
|
-
{depthType?.options?.length > 0 ? (
|
|
178
|
-
<>
|
|
179
|
-
<ButtonGroup
|
|
180
|
-
items={depthType.options.map((depth, i) => ({
|
|
181
|
-
key: i,
|
|
182
|
-
label: depth,
|
|
183
|
-
}))}
|
|
184
|
-
onSelected={(key) => {
|
|
185
|
-
setDepthTypeState(depthType.options[key]);
|
|
186
|
-
}}
|
|
187
|
-
small
|
|
188
|
-
value={depthType.options.indexOf(depthTypeState)}
|
|
189
|
-
/>
|
|
190
|
-
<Spacer />
|
|
191
|
-
</>
|
|
192
|
-
) : null}
|
|
193
|
-
|
|
194
|
-
<Flex gap="8px" alignItems="center">
|
|
195
|
-
<Button
|
|
196
|
-
type="submit"
|
|
197
|
-
small
|
|
198
|
-
colored
|
|
199
|
-
label={translations.done}
|
|
200
|
-
disabled={!valid}
|
|
201
|
-
/>
|
|
202
|
-
<Button
|
|
203
|
-
small
|
|
204
|
-
name="resetAxes"
|
|
205
|
-
label={translations.resetAxes}
|
|
206
|
-
onClick={onReset}
|
|
207
|
-
disabled={!isCustomValue}
|
|
208
|
-
/>
|
|
209
|
-
<Text small muted>
|
|
210
|
-
{translations.orDoubleClickToCanvas}
|
|
211
|
-
</Text>
|
|
212
|
-
</Flex>
|
|
213
|
-
</form>
|
|
214
|
-
);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
export const AxesOptions = ({
|
|
218
|
-
initialAxesRanges,
|
|
219
|
-
axes,
|
|
220
|
-
controlsAxesLabels,
|
|
221
|
-
onUpdateAxes,
|
|
222
|
-
onResetAxes,
|
|
223
|
-
depthType,
|
|
224
|
-
translations,
|
|
225
|
-
}) => {
|
|
226
|
-
return (
|
|
227
|
-
<Popover
|
|
228
|
-
placement="bottom"
|
|
229
|
-
overflowContainer
|
|
230
|
-
content={
|
|
231
|
-
<AxesOptionsPopover
|
|
232
|
-
initialAxesRanges={initialAxesRanges}
|
|
233
|
-
axes={axes}
|
|
234
|
-
controlsAxesLabels={controlsAxesLabels}
|
|
235
|
-
onUpdateAxes={onUpdateAxes}
|
|
236
|
-
onResetAxes={onResetAxes}
|
|
237
|
-
depthType={depthType}
|
|
238
|
-
translations={translations}
|
|
239
|
-
/>
|
|
240
|
-
}
|
|
241
|
-
>
|
|
242
|
-
<Tooltip
|
|
243
|
-
text={translations.axesOptions}
|
|
244
|
-
placement="bottom"
|
|
245
|
-
display="flex"
|
|
246
|
-
>
|
|
247
|
-
<Button small basic colored="muted" round icon={<RiRuler2Line />} />
|
|
248
|
-
</Tooltip>
|
|
249
|
-
</Popover>
|
|
250
|
-
);
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
AxesOptionsPopover.defaultProps = {
|
|
254
|
-
depthType: null,
|
|
255
|
-
initialAxesRanges: [],
|
|
256
|
-
close: () => {},
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
AxesOptionsPopover.propTypes = {
|
|
260
|
-
initialAxesRanges: PropTypes.arrayOf(PropTypes.shape({})),
|
|
261
|
-
axes: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
|
262
|
-
controlsAxesLabels: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
|
263
|
-
onUpdateAxes: PropTypes.func.isRequired,
|
|
264
|
-
onResetAxes: PropTypes.func.isRequired,
|
|
265
|
-
close: PropTypes.func,
|
|
266
|
-
depthType: PropTypes.shape({
|
|
267
|
-
selectedDepthType: PropTypes.string,
|
|
268
|
-
setSelectedDepthType: PropTypes.func,
|
|
269
|
-
options: PropTypes.arrayOf(PropTypes.string),
|
|
270
|
-
}),
|
|
271
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export const defaultTranslations = Object.freeze({
|
|
2
|
-
label: 'Label',
|
|
3
|
-
pointsLines: 'Points & lines',
|
|
4
|
-
linesOnly: 'Lines only',
|
|
5
|
-
pointsOnly: 'Points only',
|
|
6
|
-
axesOptions: 'Axes options',
|
|
7
|
-
resetAxes: 'Reset Axes',
|
|
8
|
-
done: 'Done',
|
|
9
|
-
downloadAsPNG: 'Download as PNG',
|
|
10
|
-
showChart: 'Show chart',
|
|
11
|
-
showTable: 'Show table',
|
|
12
|
-
dragToZoom: 'Drag to zoom',
|
|
13
|
-
dragToPan: 'Drag to pan',
|
|
14
|
-
dragToMovePoints: 'Drag to move points',
|
|
15
|
-
dragDisabled: 'Drag disabled',
|
|
16
|
-
hideLegend: 'Hide Legend',
|
|
17
|
-
showLegend: 'Show Legend',
|
|
18
|
-
mustHaveAValue: 'Must have a value',
|
|
19
|
-
mustBeANumber: 'Must be a number',
|
|
20
|
-
mustBeLessThanMax: 'Must be less than max',
|
|
21
|
-
mustBeGreaterThanMin: 'Must be greater than min',
|
|
22
|
-
doubleClickToReset: 'Double click on canvas to reset',
|
|
23
|
-
orDoubleClickToCanvas: 'or double click on canvas',
|
|
24
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_POINT_RADIUS = 2;
|
|
2
|
-
export const DEFAULT_HOVER_RADIUS = 5;
|
|
3
|
-
export const DEFAULT_BORDER_WIDTH = 1;
|
|
4
|
-
export const BORDER_JOIN_STYLE = 'round';
|
|
5
|
-
export const DEFAULT_LINE_POINT_RADIUS = 0;
|
|
6
|
-
export const DEFAULT_BACKGROUND_COLOR = 'transparent';
|
|
7
|
-
export const ZOOM_BOX_BACKGROUND_COLOR = 'rgba(0, 0, 0, 0.1)';
|
|
8
|
-
export const DOUBLE_CLICK = 'dblclick';
|
|
9
|
-
export const INIT_KEYS = {
|
|
10
|
-
TRANSLATIONS: 'translations',
|
|
11
|
-
LANGUAGE_KEY: 'languageKey',
|
|
12
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { produce } from 'immer';
|
|
2
|
-
import { isGreaterThanMin, isLessThanMax } from '../../utils/line-chart-utils';
|
|
3
|
-
import { actionTypes } from './action-types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Initialize local component form state for a custom loads density table
|
|
7
|
-
*
|
|
8
|
-
* @param {Object} args
|
|
9
|
-
* @param {Object} args.initialAxesRanges
|
|
10
|
-
* @param {Array} [args.axes]
|
|
11
|
-
* @returns {Object} formState
|
|
12
|
-
*/
|
|
13
|
-
export const initializeFormState = ({ initialAxesRanges, axes = [] }) => {
|
|
14
|
-
return initialAxesRanges.map((initialAxisRange) => {
|
|
15
|
-
const currentAxisRange = axes.find((a) => a.id === initialAxisRange.id);
|
|
16
|
-
return {
|
|
17
|
-
id: initialAxisRange.id,
|
|
18
|
-
min: currentAxisRange?.min ?? initialAxisRange?.min,
|
|
19
|
-
max: currentAxisRange?.max ?? initialAxisRange?.max,
|
|
20
|
-
unit: currentAxisRange?.unit,
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @typedef {Object} Action
|
|
27
|
-
* @property {String} type Action type
|
|
28
|
-
* @property {Object} [payload] Action payload (optional)
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
const isEmptyString = (value) => value === '';
|
|
32
|
-
|
|
33
|
-
const createErrorMessages = (value, compareTo, type) => {
|
|
34
|
-
const errors = [];
|
|
35
|
-
if (isEmptyString(value)) errors.push('mustHaveAValue');
|
|
36
|
-
|
|
37
|
-
if (type === 'min' && !isLessThanMax(value, compareTo)) {
|
|
38
|
-
errors.push('mustBeLessThanMax');
|
|
39
|
-
} else if (type === 'max' && !isGreaterThanMin(value, compareTo)) {
|
|
40
|
-
errors.push('mustBeGreaterThanMin');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return errors;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const validateAxes = (formState) => {
|
|
47
|
-
return formState.reduce(
|
|
48
|
-
(acc, { id, min, max }) => {
|
|
49
|
-
return produce(acc, (draft) => {
|
|
50
|
-
const errors = {
|
|
51
|
-
min: createErrorMessages(min, max, 'min'),
|
|
52
|
-
max: createErrorMessages(max, min, 'max'),
|
|
53
|
-
};
|
|
54
|
-
draft.errors.push({
|
|
55
|
-
id,
|
|
56
|
-
...errors,
|
|
57
|
-
});
|
|
58
|
-
draft.valid = !(
|
|
59
|
-
!acc.valid ||
|
|
60
|
-
!!errors.min.length ||
|
|
61
|
-
!!errors.max.length
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
{ errors: [], valid: true },
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Local component form state reducer for a axes options form
|
|
71
|
-
*
|
|
72
|
-
* @param {Object} state Local component form state
|
|
73
|
-
* @param {Action} action Action with type and payload
|
|
74
|
-
* @returns {Object} FormState
|
|
75
|
-
*/
|
|
76
|
-
export const reducer = (state, action) => {
|
|
77
|
-
switch (action.type) {
|
|
78
|
-
case actionTypes.reset: {
|
|
79
|
-
const { initialAxesRanges, axes } = action.payload;
|
|
80
|
-
return initializeFormState({ initialAxesRanges, axes });
|
|
81
|
-
}
|
|
82
|
-
case actionTypes.valueUpdated:
|
|
83
|
-
return produce(state, (draft) => {
|
|
84
|
-
const { name, value, id } = action.payload;
|
|
85
|
-
const axis = draft.find((a) => a.id === id);
|
|
86
|
-
axis[name] = value;
|
|
87
|
-
});
|
|
88
|
-
case actionTypes.unitUpdated:
|
|
89
|
-
return produce(state, (draft) => {
|
|
90
|
-
const { name, value, id } = action.payload;
|
|
91
|
-
const axis = draft.find((a) => a.id === id);
|
|
92
|
-
axis.unit[name] = value;
|
|
93
|
-
});
|
|
94
|
-
default:
|
|
95
|
-
return state;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Portal } from '@oliasoft-open-source/react-ui-library';
|
|
3
|
-
|
|
4
|
-
const ControlsPortal = ({ children, controlsPortalId }) => {
|
|
5
|
-
if (controlsPortalId && document.getElementById(controlsPortalId)) {
|
|
6
|
-
return <Portal id={controlsPortalId}>{children}</Portal>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return children;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default ControlsPortal;
|
|
@@ -1,176 +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 PropTypes from 'prop-types';
|
|
9
|
-
import { LineOptions } from './line-options';
|
|
10
|
-
import { DragOptions } from './drag-options';
|
|
11
|
-
import styles from './controls.module.less';
|
|
12
|
-
import { useToggleHandlers } from '../hooks/use-toggle-handler';
|
|
13
|
-
import { useChartFunctions } from '../hooks/use-chart-functions';
|
|
14
|
-
import { AxesOptions } from '../../controls/axes-options/axes-options';
|
|
15
|
-
import ControlsPortal from './controls-portal';
|
|
16
|
-
|
|
17
|
-
const Controls = ({
|
|
18
|
-
props: { headerComponent, subheaderComponent, table },
|
|
19
|
-
chartRef,
|
|
20
|
-
state,
|
|
21
|
-
options,
|
|
22
|
-
dispatch,
|
|
23
|
-
generatedDatasets,
|
|
24
|
-
translations,
|
|
25
|
-
controlsPortalId,
|
|
26
|
-
}) => {
|
|
27
|
-
const {
|
|
28
|
-
enableDragPoints,
|
|
29
|
-
initialAxesRanges,
|
|
30
|
-
lineEnabled,
|
|
31
|
-
panEnabled,
|
|
32
|
-
pointsEnabled,
|
|
33
|
-
showTable,
|
|
34
|
-
zoomEnabled,
|
|
35
|
-
} = state;
|
|
36
|
-
const { dragData } = options;
|
|
37
|
-
const {
|
|
38
|
-
onToggleLine,
|
|
39
|
-
onTogglePan,
|
|
40
|
-
onTogglePoints,
|
|
41
|
-
onToggleTable,
|
|
42
|
-
onToggleZoom,
|
|
43
|
-
onToggleDragPoints,
|
|
44
|
-
onDisableDragOptions,
|
|
45
|
-
} = useToggleHandlers(dispatch);
|
|
46
|
-
const {
|
|
47
|
-
handleDownload,
|
|
48
|
-
controlsAxes,
|
|
49
|
-
controlsAxesLabels,
|
|
50
|
-
onResetAxes,
|
|
51
|
-
onUpdateAxes,
|
|
52
|
-
} = useChartFunctions({
|
|
53
|
-
chartRef,
|
|
54
|
-
state,
|
|
55
|
-
options,
|
|
56
|
-
dispatch,
|
|
57
|
-
generatedDatasets,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<>
|
|
62
|
-
<div className={styles.controls}>
|
|
63
|
-
{!!options.title && <Text bold>{options.title}</Text>}
|
|
64
|
-
{headerComponent}
|
|
65
|
-
<ControlsPortal controlsPortalId={controlsPortalId}>
|
|
66
|
-
<div className={styles.buttons}>
|
|
67
|
-
{!showTable && (
|
|
68
|
-
<>
|
|
69
|
-
<AxesOptions
|
|
70
|
-
initialAxesRanges={initialAxesRanges}
|
|
71
|
-
axes={controlsAxes}
|
|
72
|
-
controlsAxesLabels={controlsAxesLabels}
|
|
73
|
-
onUpdateAxes={onUpdateAxes}
|
|
74
|
-
onResetAxes={onResetAxes}
|
|
75
|
-
depthType={options.depthType}
|
|
76
|
-
translations={translations}
|
|
77
|
-
/>
|
|
78
|
-
<LineOptions
|
|
79
|
-
lineEnabled={lineEnabled}
|
|
80
|
-
pointsEnabled={pointsEnabled}
|
|
81
|
-
onToggleLine={onToggleLine}
|
|
82
|
-
onTogglePoints={onTogglePoints}
|
|
83
|
-
translations={translations}
|
|
84
|
-
/>
|
|
85
|
-
<Tooltip
|
|
86
|
-
text={translations.downloadAsPNG}
|
|
87
|
-
placement="bottom-end"
|
|
88
|
-
>
|
|
89
|
-
<Button
|
|
90
|
-
small
|
|
91
|
-
basic
|
|
92
|
-
colored="muted"
|
|
93
|
-
round
|
|
94
|
-
icon={<RiFileDownloadLine />}
|
|
95
|
-
onClick={handleDownload}
|
|
96
|
-
/>
|
|
97
|
-
</Tooltip>
|
|
98
|
-
<DragOptions
|
|
99
|
-
panEnabled={panEnabled}
|
|
100
|
-
zoomEnabled={zoomEnabled}
|
|
101
|
-
onTogglePan={onTogglePan}
|
|
102
|
-
onToggleZoom={onToggleZoom}
|
|
103
|
-
enableDragPoints={enableDragPoints}
|
|
104
|
-
isDragDataAllowed={dragData.enableDragData}
|
|
105
|
-
onToggleDragPoints={onToggleDragPoints}
|
|
106
|
-
onDisableDragOptions={onDisableDragOptions}
|
|
107
|
-
translations={translations}
|
|
108
|
-
/>
|
|
109
|
-
</>
|
|
110
|
-
)}
|
|
111
|
-
|
|
112
|
-
{table ? (
|
|
113
|
-
<Tooltip
|
|
114
|
-
text={
|
|
115
|
-
showTable ? translations.showChart : translations.showTable
|
|
116
|
-
}
|
|
117
|
-
placement="bottom-end"
|
|
118
|
-
>
|
|
119
|
-
<Button
|
|
120
|
-
small
|
|
121
|
-
basic
|
|
122
|
-
colored="muted"
|
|
123
|
-
round
|
|
124
|
-
icon={showTable ? <RiLineChartLine /> : <RiTableLine />}
|
|
125
|
-
onClick={onToggleTable}
|
|
126
|
-
/>
|
|
127
|
-
</Tooltip>
|
|
128
|
-
) : null}
|
|
129
|
-
</div>
|
|
130
|
-
</ControlsPortal>
|
|
131
|
-
</div>
|
|
132
|
-
{subheaderComponent}
|
|
133
|
-
</>
|
|
134
|
-
);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
Controls.defaultProps = {
|
|
138
|
-
props: {
|
|
139
|
-
headerComponent: null,
|
|
140
|
-
subheaderComponent: null,
|
|
141
|
-
table: null,
|
|
142
|
-
controlsPortalId: null,
|
|
143
|
-
},
|
|
144
|
-
state: {
|
|
145
|
-
initialAxesRanges: [],
|
|
146
|
-
},
|
|
147
|
-
options: {},
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
Controls.propTypes = {
|
|
151
|
-
props: PropTypes.shape({
|
|
152
|
-
headerComponent: PropTypes.node,
|
|
153
|
-
subheaderComponent: PropTypes.node,
|
|
154
|
-
table: PropTypes.node,
|
|
155
|
-
controlsPortalId: PropTypes.string,
|
|
156
|
-
}),
|
|
157
|
-
chartRef: PropTypes.object.isRequired,
|
|
158
|
-
state: PropTypes.shape({
|
|
159
|
-
enableDragPoints: PropTypes.bool,
|
|
160
|
-
initialAxesRanges: PropTypes.arrayOf(PropTypes.shape({})),
|
|
161
|
-
lineEnabled: PropTypes.bool,
|
|
162
|
-
panEnabled: PropTypes.bool,
|
|
163
|
-
pointsEnabled: PropTypes.bool,
|
|
164
|
-
showTable: PropTypes.bool,
|
|
165
|
-
zoomEnabled: PropTypes.bool,
|
|
166
|
-
}),
|
|
167
|
-
options: PropTypes.shape({
|
|
168
|
-
dragData: PropTypes.shape({
|
|
169
|
-
enableDragData: PropTypes.bool,
|
|
170
|
-
}),
|
|
171
|
-
}),
|
|
172
|
-
dispatch: PropTypes.func.isRequired,
|
|
173
|
-
generatedDatasets: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export default Controls;
|