@oliasoft-open-source/charts-library 2.17.6 → 2.18.0-beta-2
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 +40398 -0
- package/dist/style.css +177 -0
- package/package.json +26 -34
- package/index.js +0 -14
- package/release-notes.md +0 -310
- 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/components/bar-chart/bar-chart-prop-types.js +0 -209
- package/src/components/bar-chart/bar-chart.interface.ts +0 -91
- 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 -123
- package/src/components/bar-chart/get-bar-chart-tooltips.js +0 -102
- package/src/components/controls/axes-options/axes-options.jsx +0 -270
- 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.jsx +0 -174
- package/src/components/line-chart/controls/controls.module.less +0 -12
- package/src/components/line-chart/controls/drag-options.jsx +0 -112
- package/src/components/line-chart/controls/legend-options.jsx +0 -36
- package/src/components/line-chart/controls/line-options.jsx +0 -64
- package/src/components/line-chart/hooks/use-chart-functions.js +0 -257
- 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/line-chart-prop-types.js +0 -292
- package/src/components/line-chart/line-chart.interface.ts +0 -121
- package/src/components/line-chart/line-chart.jsx +0 -161
- package/src/components/line-chart/line-chart.module.less +0 -77
- 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 -100
- 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-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 -114
- 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 -120
- package/src/components/line-chart/utils/get-line-chart-tooltips.js +0 -94
- package/src/components/line-chart/utils/line-chart-utils.js +0 -77
- 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 -450
- 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 -182
- package/src/helpers/container.jsx +0 -60
- package/src/helpers/disabled-context.js +0 -8
- package/src/helpers/enums.js +0 -96
- package/src/helpers/get-chart-annotation.js +0 -106
- 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
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
ANIMATION_DURATION,
|
|
4
|
-
BORDER_COLOR,
|
|
5
|
-
CUSTOM_LEGEND_PLUGIN_NAME,
|
|
6
|
-
} from '../../../helpers/chart-consts';
|
|
7
|
-
import {
|
|
8
|
-
ChartHoverMode,
|
|
9
|
-
Events,
|
|
10
|
-
PanZoomMode,
|
|
11
|
-
PointStyle,
|
|
12
|
-
} from '../../../helpers/enums';
|
|
13
|
-
import { autoScale } from '../utils/axis-scales/axis-scales';
|
|
14
|
-
import getLineChartDataLabels from '../utils/get-line-chart-data-labels';
|
|
15
|
-
import getAnnotation from '../../../helpers/get-chart-annotation';
|
|
16
|
-
import { ZOOM_BOX_BACKGROUND_COLOR } from '../constants/line-chart-consts';
|
|
17
|
-
import getLineChartToolTips from '../utils/get-line-chart-tooltips';
|
|
18
|
-
import { getLegend } from '../../../helpers/chart-utils';
|
|
19
|
-
import getDraggableData from '../../../helpers/get-draggableData';
|
|
20
|
-
import { useChartFunctions } from './use-chart-functions';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Custom hook to generate chart options.
|
|
24
|
-
* @function
|
|
25
|
-
* @param {Object} chartRef - The chart reference.
|
|
26
|
-
* @param {Object} state - The chart state.
|
|
27
|
-
* @param {Object} options - The chart options.
|
|
28
|
-
* @param {Function} dispatch - The dispatch function for state management.
|
|
29
|
-
* @param {Array} generatedDatasets - The generated datasets.
|
|
30
|
-
* @returns {Object} The chart options object.
|
|
31
|
-
*/
|
|
32
|
-
export const useChartOptions = ({
|
|
33
|
-
chartRef,
|
|
34
|
-
state,
|
|
35
|
-
options,
|
|
36
|
-
dispatch,
|
|
37
|
-
generatedDatasets,
|
|
38
|
-
}) => {
|
|
39
|
-
const {
|
|
40
|
-
interactions: { onAnimationComplete },
|
|
41
|
-
annotations: {
|
|
42
|
-
labelAnnotation: {
|
|
43
|
-
showLabel,
|
|
44
|
-
text,
|
|
45
|
-
position,
|
|
46
|
-
fontSize,
|
|
47
|
-
xOffset,
|
|
48
|
-
yOffset,
|
|
49
|
-
maxWidth,
|
|
50
|
-
lineHeight,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
chartStyling: { layoutPadding },
|
|
54
|
-
} = options;
|
|
55
|
-
|
|
56
|
-
const {
|
|
57
|
-
enableDragPoints,
|
|
58
|
-
zoomEnabled,
|
|
59
|
-
panEnabled,
|
|
60
|
-
lineEnabled,
|
|
61
|
-
showAnnotationLineIndex,
|
|
62
|
-
legendEnabled,
|
|
63
|
-
} = state;
|
|
64
|
-
|
|
65
|
-
const [hoveredPoint, setHoveredPoint] = useState(null);
|
|
66
|
-
const { legendClick, updateAxesRangesFromChart, onHover } = useChartFunctions(
|
|
67
|
-
{
|
|
68
|
-
chartRef,
|
|
69
|
-
state,
|
|
70
|
-
options,
|
|
71
|
-
dispatch,
|
|
72
|
-
generatedDatasets,
|
|
73
|
-
},
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const datalabels = getLineChartDataLabels(options);
|
|
77
|
-
const tooltip = getLineChartToolTips(options);
|
|
78
|
-
const annotation = useMemo(
|
|
79
|
-
() => getAnnotation(options, state),
|
|
80
|
-
[showAnnotationLineIndex, legendClick],
|
|
81
|
-
);
|
|
82
|
-
const legend = useMemo(
|
|
83
|
-
() => getLegend(options, legendClick, state),
|
|
84
|
-
[legendEnabled],
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
const scales = useMemo(
|
|
88
|
-
() => autoScale(options, state, generatedDatasets),
|
|
89
|
-
[options, state, generatedDatasets],
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const dragData = useMemo(
|
|
93
|
-
() => enableDragPoints && getDraggableData(options),
|
|
94
|
-
[enableDragPoints, options],
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
const panOptions = useMemo(
|
|
98
|
-
() => ({
|
|
99
|
-
enabled: panEnabled,
|
|
100
|
-
mode: PanZoomMode.XY,
|
|
101
|
-
onPanComplete({ chart }) {
|
|
102
|
-
updateAxesRangesFromChart(chart);
|
|
103
|
-
},
|
|
104
|
-
}),
|
|
105
|
-
[panEnabled],
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const zoomOptions = useMemo(
|
|
109
|
-
() => ({
|
|
110
|
-
mode: PanZoomMode.XY,
|
|
111
|
-
drag: {
|
|
112
|
-
enabled: zoomEnabled,
|
|
113
|
-
threshold: 3,
|
|
114
|
-
backgroundColor: ZOOM_BOX_BACKGROUND_COLOR,
|
|
115
|
-
borderColor: BORDER_COLOR,
|
|
116
|
-
borderWidth: 1,
|
|
117
|
-
},
|
|
118
|
-
onZoomComplete({ chart }) {
|
|
119
|
-
updateAxesRangesFromChart(chart);
|
|
120
|
-
},
|
|
121
|
-
}),
|
|
122
|
-
[zoomEnabled],
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
const plugins = {
|
|
126
|
-
datalabels,
|
|
127
|
-
annotation,
|
|
128
|
-
zoom: { pan: panOptions, zoom: zoomOptions },
|
|
129
|
-
tooltip,
|
|
130
|
-
legend,
|
|
131
|
-
[CUSTOM_LEGEND_PLUGIN_NAME]: options.legend.customLegend
|
|
132
|
-
.customLegendPlugin && {
|
|
133
|
-
containerID: options.legend.customLegend.customLegendContainerID,
|
|
134
|
-
},
|
|
135
|
-
chartAreaBorder: {
|
|
136
|
-
borderColor: BORDER_COLOR,
|
|
137
|
-
},
|
|
138
|
-
chartAreaText: {
|
|
139
|
-
showLabel,
|
|
140
|
-
text,
|
|
141
|
-
position,
|
|
142
|
-
fontSize,
|
|
143
|
-
xOffset,
|
|
144
|
-
yOffset,
|
|
145
|
-
maxWidth,
|
|
146
|
-
lineHeight,
|
|
147
|
-
},
|
|
148
|
-
...dragData,
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
return useMemo(
|
|
152
|
-
() => ({
|
|
153
|
-
layout: {
|
|
154
|
-
padding: layoutPadding,
|
|
155
|
-
},
|
|
156
|
-
onHover: onHover(hoveredPoint, setHoveredPoint),
|
|
157
|
-
maintainAspectRatio: options.chartStyling.maintainAspectRatio,
|
|
158
|
-
aspectRatio: options.chartStyling.squareAspectRatio ? 1 : null,
|
|
159
|
-
animation: options.chartStyling.performanceMode
|
|
160
|
-
? false
|
|
161
|
-
: {
|
|
162
|
-
duration: ANIMATION_DURATION.FAST,
|
|
163
|
-
onComplete: onAnimationComplete,
|
|
164
|
-
},
|
|
165
|
-
hover: {
|
|
166
|
-
mode: ChartHoverMode.Nearest,
|
|
167
|
-
intersect: true,
|
|
168
|
-
},
|
|
169
|
-
elements: {
|
|
170
|
-
line: {
|
|
171
|
-
pointStyle: PointStyle.Circle,
|
|
172
|
-
showLine: lineEnabled,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
scales,
|
|
176
|
-
plugins,
|
|
177
|
-
events: Events,
|
|
178
|
-
}),
|
|
179
|
-
[state, options],
|
|
180
|
-
);
|
|
181
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'react';
|
|
2
|
-
import { debounce } from 'lodash';
|
|
3
|
-
import { getPlugins } from '../../../helpers/chart-utils';
|
|
4
|
-
import { DOUBLE_CLICK } from '../constants/line-chart-consts';
|
|
5
|
-
|
|
6
|
-
export const useChartPlugins = ({ options, resetZoom }) => {
|
|
7
|
-
const { graph, legend } = options;
|
|
8
|
-
|
|
9
|
-
const debouncedResetZoom = useCallback(
|
|
10
|
-
debounce(() => {
|
|
11
|
-
resetZoom();
|
|
12
|
-
}, 100), // 300ms debounce delay
|
|
13
|
-
[resetZoom],
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
const handleDoubleClick = useCallback(
|
|
17
|
-
(chart, args) => {
|
|
18
|
-
const { event } = args;
|
|
19
|
-
if (event.type === DOUBLE_CLICK) {
|
|
20
|
-
debouncedResetZoom();
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
[debouncedResetZoom],
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
return useMemo(() => {
|
|
27
|
-
return [
|
|
28
|
-
...getPlugins(graph, legend),
|
|
29
|
-
{
|
|
30
|
-
id: 'customEventCatcher',
|
|
31
|
-
beforeEvent: handleDoubleClick,
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
}, [handleDoubleClick]);
|
|
35
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
DISABLE_DRAG_OPTIONS,
|
|
4
|
-
TOGGLE_DRAG_POINTS,
|
|
5
|
-
TOGGLE_LEGEND,
|
|
6
|
-
TOGGLE_LINE,
|
|
7
|
-
TOGGLE_PAN,
|
|
8
|
-
TOGGLE_POINTS,
|
|
9
|
-
TOGGLE_TABLE,
|
|
10
|
-
TOGGLE_ZOOM,
|
|
11
|
-
} from '../state/action-types';
|
|
12
|
-
|
|
13
|
-
export const useToggleHandlers = (dispatch) => {
|
|
14
|
-
const createToggleHandler = useCallback(
|
|
15
|
-
(type) => () => {
|
|
16
|
-
dispatch({ type });
|
|
17
|
-
},
|
|
18
|
-
[dispatch],
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const toggleHandlers = {
|
|
22
|
-
onToggleLegend: createToggleHandler(TOGGLE_LEGEND),
|
|
23
|
-
onToggleLine: createToggleHandler(TOGGLE_LINE),
|
|
24
|
-
onTogglePan: createToggleHandler(TOGGLE_PAN),
|
|
25
|
-
onTogglePoints: createToggleHandler(TOGGLE_POINTS),
|
|
26
|
-
onToggleTable: createToggleHandler(TOGGLE_TABLE),
|
|
27
|
-
onToggleZoom: createToggleHandler(TOGGLE_ZOOM),
|
|
28
|
-
onToggleDragPoints: createToggleHandler(TOGGLE_DRAG_POINTS),
|
|
29
|
-
onDisableDragOptions: createToggleHandler(DISABLE_DRAG_OPTIONS),
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return toggleHandlers;
|
|
33
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { INIT_KEYS } from '../constants/line-chart-consts';
|
|
2
|
-
import { getTranslations } from '../utils/translations/get-translations';
|
|
3
|
-
|
|
4
|
-
const config = {
|
|
5
|
-
[INIT_KEYS.TRANSLATIONS]: getTranslations(),
|
|
6
|
-
[INIT_KEYS.LANGUAGE_KEY]: 'en',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Retrieve the value for the given key from the config object.
|
|
11
|
-
* @param {string} key - The key to access the corresponding value in the config object.
|
|
12
|
-
* @returns {*} - The value associated with the given key in the config object or config.
|
|
13
|
-
*/
|
|
14
|
-
export const getConfig = (key) => (key ? config[key] : config);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Set a new value for the given key in the config object.
|
|
18
|
-
* @param {string} key - The key to access the corresponding value in the config object.
|
|
19
|
-
* @param {*} newValue - The new value to be set for the given key.
|
|
20
|
-
*/
|
|
21
|
-
export const setConfig = (key, newValue) => {
|
|
22
|
-
config[key] = newValue;
|
|
23
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { INIT_KEYS } from '../constants/line-chart-consts';
|
|
2
|
-
import { setConfig } from './config';
|
|
3
|
-
import { getTranslations } from '../utils/translations/get-translations';
|
|
4
|
-
import { isPrimitiveValue } from '../utils/line-chart-utils';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Initialize the charts library with the provided configurations.
|
|
8
|
-
* This function will store the configuration options in a config object.
|
|
9
|
-
* @param {object} options - An object containing the configuration options for the library.
|
|
10
|
-
* @param {object} options.translations - The translations to be used in the library.
|
|
11
|
-
* @param {string} options.languageKey - The language key to be stored in the config object, used for translations.
|
|
12
|
-
* @param {...object} options - Any additional options to be stored in the config object.
|
|
13
|
-
*/
|
|
14
|
-
export const initializeLineChart = ({ languageKey = 'en', ...options }) => {
|
|
15
|
-
setConfig(INIT_KEYS.LANGUAGE_KEY, languageKey);
|
|
16
|
-
|
|
17
|
-
Object.entries(options).forEach(([key, value]) => {
|
|
18
|
-
if (key === INIT_KEYS.TRANSLATIONS) {
|
|
19
|
-
setConfig(key, getTranslations(value));
|
|
20
|
-
} else {
|
|
21
|
-
const newValue = isPrimitiveValue(value) ? value : { ...value };
|
|
22
|
-
setConfig(key, newValue);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
};
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import { TextLabelPosition } from './plugins/plugin-constants';
|
|
3
|
-
|
|
4
|
-
export const LineChartPropTypes = {
|
|
5
|
-
table: PropTypes.node,
|
|
6
|
-
chart: PropTypes.shape({
|
|
7
|
-
persistenceId: PropTypes.string,
|
|
8
|
-
testId: PropTypes.string,
|
|
9
|
-
data: PropTypes.object.isRequired,
|
|
10
|
-
options: PropTypes.shape({
|
|
11
|
-
title: PropTypes.oneOfType([
|
|
12
|
-
PropTypes.string,
|
|
13
|
-
PropTypes.arrayOf(PropTypes.string),
|
|
14
|
-
]),
|
|
15
|
-
axes: PropTypes.shape({
|
|
16
|
-
x: PropTypes.arrayOf(
|
|
17
|
-
PropTypes.shape({
|
|
18
|
-
label: PropTypes.string,
|
|
19
|
-
position: PropTypes.oneOf(['top', 'bottom']),
|
|
20
|
-
color: PropTypes.string,
|
|
21
|
-
unit: PropTypes.shape({
|
|
22
|
-
options: PropTypes.arrayOf(PropTypes.string),
|
|
23
|
-
selectedUnit: PropTypes.string,
|
|
24
|
-
setSelectedUnit: PropTypes.func,
|
|
25
|
-
}),
|
|
26
|
-
}),
|
|
27
|
-
),
|
|
28
|
-
y: PropTypes.arrayOf(
|
|
29
|
-
PropTypes.shape({
|
|
30
|
-
label: PropTypes.string,
|
|
31
|
-
position: PropTypes.oneOf(['left', 'right']),
|
|
32
|
-
color: PropTypes.string,
|
|
33
|
-
}),
|
|
34
|
-
),
|
|
35
|
-
}),
|
|
36
|
-
additionalAxesOptions: PropTypes.shape({
|
|
37
|
-
chartScaleType: PropTypes.oneOf(['linear', 'logarithmic']),
|
|
38
|
-
reverse: PropTypes.bool,
|
|
39
|
-
beginAtZero: PropTypes.bool,
|
|
40
|
-
stepSize: PropTypes.number,
|
|
41
|
-
truncateAxisNumbersToDigitsCallback: PropTypes.number,
|
|
42
|
-
suggestedMin: PropTypes.number,
|
|
43
|
-
suggestedMax: PropTypes.number,
|
|
44
|
-
range: PropTypes.shape({
|
|
45
|
-
x: PropTypes.shape({
|
|
46
|
-
min: PropTypes.number,
|
|
47
|
-
max: PropTypes.number,
|
|
48
|
-
}),
|
|
49
|
-
y: PropTypes.shape({
|
|
50
|
-
min: PropTypes.number,
|
|
51
|
-
max: PropTypes.number,
|
|
52
|
-
}),
|
|
53
|
-
}),
|
|
54
|
-
autoAxisPadding: PropTypes.bool,
|
|
55
|
-
}),
|
|
56
|
-
chartStyling: PropTypes.shape({
|
|
57
|
-
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
58
|
-
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
59
|
-
maintainAspectRatio: PropTypes.bool,
|
|
60
|
-
staticChartHeight: PropTypes.bool,
|
|
61
|
-
performanceMode: PropTypes.bool,
|
|
62
|
-
squareAspectRatio: PropTypes.bool,
|
|
63
|
-
layoutPadding: PropTypes.oneOfType([
|
|
64
|
-
PropTypes.number,
|
|
65
|
-
PropTypes.shape({
|
|
66
|
-
top: PropTypes.number,
|
|
67
|
-
bottom: PropTypes.number,
|
|
68
|
-
left: PropTypes.number,
|
|
69
|
-
right: PropTypes.number,
|
|
70
|
-
}),
|
|
71
|
-
]),
|
|
72
|
-
}),
|
|
73
|
-
tooltip: PropTypes.shape({
|
|
74
|
-
tooltips: PropTypes.bool,
|
|
75
|
-
showLabelsInTooltips: PropTypes.bool,
|
|
76
|
-
hideSimulationName: PropTypes.bool,
|
|
77
|
-
}),
|
|
78
|
-
graph: PropTypes.shape({
|
|
79
|
-
lineTension: PropTypes.number,
|
|
80
|
-
spanGaps: PropTypes.bool,
|
|
81
|
-
showDataLabels: PropTypes.bool,
|
|
82
|
-
showMinorGridlines: PropTypes.bool,
|
|
83
|
-
}),
|
|
84
|
-
annotations: PropTypes.shape({
|
|
85
|
-
labelAnnotation: PropTypes.shape({
|
|
86
|
-
showLabel: PropTypes.bool,
|
|
87
|
-
text: PropTypes.oneOfType([
|
|
88
|
-
PropTypes.string,
|
|
89
|
-
PropTypes.arrayOf(PropTypes.string),
|
|
90
|
-
]),
|
|
91
|
-
position: PropTypes.string,
|
|
92
|
-
fontSize: PropTypes.number,
|
|
93
|
-
xOffset: PropTypes.number,
|
|
94
|
-
yOffset: PropTypes.number,
|
|
95
|
-
maxWidth: PropTypes.number,
|
|
96
|
-
lineHeight: PropTypes.number,
|
|
97
|
-
}),
|
|
98
|
-
showAnnotations: PropTypes.bool,
|
|
99
|
-
controlAnnotation: PropTypes.bool,
|
|
100
|
-
annotationsData: PropTypes.arrayOf(
|
|
101
|
-
PropTypes.shape({
|
|
102
|
-
adjustScaleRange: PropTypes.bool,
|
|
103
|
-
annotationAxis: PropTypes.oneOf(['x', 'y']),
|
|
104
|
-
color: PropTypes.string,
|
|
105
|
-
endValue: PropTypes.number,
|
|
106
|
-
label: PropTypes.string,
|
|
107
|
-
type: PropTypes.string,
|
|
108
|
-
value: PropTypes.number,
|
|
109
|
-
xMin: PropTypes.number,
|
|
110
|
-
xMax: PropTypes.number,
|
|
111
|
-
yMin: PropTypes.number,
|
|
112
|
-
yMax: PropTypes.number,
|
|
113
|
-
}),
|
|
114
|
-
),
|
|
115
|
-
}),
|
|
116
|
-
legend: PropTypes.shape({
|
|
117
|
-
display: PropTypes.bool,
|
|
118
|
-
position: PropTypes.oneOf(['top', 'bottom', 'right', 'left']),
|
|
119
|
-
align: PropTypes.oneOf(['start', 'center', 'end']),
|
|
120
|
-
customLegend: PropTypes.shape({
|
|
121
|
-
customLegendPlugin: PropTypes.object,
|
|
122
|
-
customLegendContainerID: PropTypes.string,
|
|
123
|
-
}),
|
|
124
|
-
}),
|
|
125
|
-
chartOptions: PropTypes.shape({
|
|
126
|
-
showPoints: PropTypes.bool,
|
|
127
|
-
enableZoom: PropTypes.bool,
|
|
128
|
-
enablePan: PropTypes.bool,
|
|
129
|
-
closeOnOutsideClick: PropTypes.bool,
|
|
130
|
-
}),
|
|
131
|
-
interactions: PropTypes.shape({
|
|
132
|
-
onLegendClick: PropTypes.func,
|
|
133
|
-
onPointHover: PropTypes.func,
|
|
134
|
-
onPointUnhover: PropTypes.func,
|
|
135
|
-
onAnimationComplete: PropTypes.func,
|
|
136
|
-
}),
|
|
137
|
-
depthType: PropTypes.shape({
|
|
138
|
-
options: PropTypes.arrayOf(PropTypes.string),
|
|
139
|
-
selectedDepthType: PropTypes.string,
|
|
140
|
-
setSelectedDepthType: PropTypes.func,
|
|
141
|
-
}),
|
|
142
|
-
dragData: PropTypes.shape({
|
|
143
|
-
enableDragData: PropTypes.bool,
|
|
144
|
-
showTooltip: PropTypes.bool,
|
|
145
|
-
roundPoints: PropTypes.bool,
|
|
146
|
-
dragX: PropTypes.bool,
|
|
147
|
-
dragY: PropTypes.bool,
|
|
148
|
-
onDragStart: PropTypes.func,
|
|
149
|
-
onDrag: PropTypes.func,
|
|
150
|
-
onDragEnd: PropTypes.func,
|
|
151
|
-
}),
|
|
152
|
-
}),
|
|
153
|
-
}).isRequired,
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export const getDefaultProps = (props) => {
|
|
157
|
-
// Add missing nested objects
|
|
158
|
-
props.chart.options = props.chart.options || {};
|
|
159
|
-
props.chart.options.axes = props.chart.options.axes || {};
|
|
160
|
-
props.chart.options.additionalAxesOptions =
|
|
161
|
-
props.chart.options.additionalAxesOptions || {};
|
|
162
|
-
props.chart.options.chartStyling = props.chart.options.chartStyling || {};
|
|
163
|
-
props.chart.options.tooltip = props.chart.options.tooltip || {};
|
|
164
|
-
props.chart.options.graph = props.chart.options.graph || {};
|
|
165
|
-
props.chart.options.annotations = props.chart.options.annotations || {};
|
|
166
|
-
props.chart.options.legend = props.chart.options.legend || {};
|
|
167
|
-
props.chart.options.legend.customLegend = props.chart.options.legend
|
|
168
|
-
.customLegend || { customLegendPlugin: null, customLegendContainerID: '' };
|
|
169
|
-
props.chart.options.chartOptions = props.chart.options.chartOptions || {};
|
|
170
|
-
props.chart.options.interactions = props.chart.options.interactions || {};
|
|
171
|
-
props.chart.options.dragData = props.chart.options.dragData || {};
|
|
172
|
-
// Set defaults for missing properties
|
|
173
|
-
const chart = {
|
|
174
|
-
persistenceId: props.chart.persistenceId ?? '',
|
|
175
|
-
testId: props.chart.testId ?? null,
|
|
176
|
-
data: props.chart.data,
|
|
177
|
-
options: {
|
|
178
|
-
title: props.chart.options.title || '',
|
|
179
|
-
axes: {
|
|
180
|
-
x: props.chart.options.axes.x || [{}],
|
|
181
|
-
y: props.chart.options.axes.y || [{}],
|
|
182
|
-
},
|
|
183
|
-
additionalAxesOptions: {
|
|
184
|
-
chartScaleType:
|
|
185
|
-
props.chart.options.additionalAxesOptions.chartScaleType || 'linear',
|
|
186
|
-
reverse: props.chart.options.additionalAxesOptions.reverse || false,
|
|
187
|
-
beginAtZero:
|
|
188
|
-
props.chart.options.additionalAxesOptions.beginAtZero || false,
|
|
189
|
-
stepSize: props.chart.options.additionalAxesOptions.stepSize,
|
|
190
|
-
truncateAxisNumbersToDigitsCallback:
|
|
191
|
-
props.chart.options.additionalAxesOptions
|
|
192
|
-
.truncateAxisNumbersToDigitsCallback,
|
|
193
|
-
suggestedMin: props.chart.options.additionalAxesOptions.suggestedMin,
|
|
194
|
-
suggestedMax: props.chart.options.additionalAxesOptions.suggestedMax,
|
|
195
|
-
range: props.chart.options.additionalAxesOptions.range,
|
|
196
|
-
autoAxisPadding:
|
|
197
|
-
props.chart.options.additionalAxesOptions.autoAxisPadding ?? false,
|
|
198
|
-
},
|
|
199
|
-
chartStyling: {
|
|
200
|
-
width: props.chart.options.chartStyling.width,
|
|
201
|
-
height: props.chart.options.chartStyling.height,
|
|
202
|
-
maintainAspectRatio:
|
|
203
|
-
props.chart.options.chartStyling.maintainAspectRatio || false,
|
|
204
|
-
staticChartHeight:
|
|
205
|
-
props.chart.options.chartStyling.staticChartHeight || false,
|
|
206
|
-
performanceMode:
|
|
207
|
-
props.chart.options.chartStyling.performanceMode ?? true,
|
|
208
|
-
squareAspectRatio:
|
|
209
|
-
props.chart.options.chartStyling.squareAspectRatio || false,
|
|
210
|
-
layoutPadding: props.chart.options.chartStyling.layoutPadding || {
|
|
211
|
-
top: 0,
|
|
212
|
-
bottom: 20,
|
|
213
|
-
left: 0,
|
|
214
|
-
right: 0,
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
tooltip: {
|
|
218
|
-
tooltips: props.chart.options.tooltip.tooltips ?? true,
|
|
219
|
-
showLabelsInTooltips:
|
|
220
|
-
props.chart.options.tooltip.showLabelsInTooltips || false,
|
|
221
|
-
hideSimulationName:
|
|
222
|
-
props.chart.options.tooltip.hideSimulationName || false,
|
|
223
|
-
},
|
|
224
|
-
graph: {
|
|
225
|
-
lineTension: props.chart.options.graph.lineTension || 0.01,
|
|
226
|
-
spanGaps: props.chart.options.graph.spanGaps || false,
|
|
227
|
-
showDataLabels: props.chart.options.graph.showDataLabels || false,
|
|
228
|
-
showMinorGridlines:
|
|
229
|
-
props.chart.options.graph.showMinorGridlines || false,
|
|
230
|
-
},
|
|
231
|
-
annotations: {
|
|
232
|
-
labelAnnotation: {
|
|
233
|
-
showLabel:
|
|
234
|
-
props.chart.options.annotations.labelAnnotation?.showLabel ?? false,
|
|
235
|
-
text: props.chart.options.annotations.labelAnnotation?.text ?? '',
|
|
236
|
-
position:
|
|
237
|
-
props.chart.options.annotations.labelAnnotation?.position ??
|
|
238
|
-
TextLabelPosition.BOTTOM_RIGHT,
|
|
239
|
-
fontSize:
|
|
240
|
-
props.chart.options.annotations.labelAnnotation?.fontSize ?? 12,
|
|
241
|
-
xOffset:
|
|
242
|
-
props.chart.options.annotations.labelAnnotation?.xOffset ?? 5,
|
|
243
|
-
yOffset:
|
|
244
|
-
props.chart.options.annotations.labelAnnotation?.yOffset ?? 5,
|
|
245
|
-
maxWidth:
|
|
246
|
-
props.chart.options.annotations.labelAnnotation?.maxWidth ?? 300,
|
|
247
|
-
lineHeight:
|
|
248
|
-
props.chart.options.annotations.labelAnnotation?.lineHeight ?? 12,
|
|
249
|
-
},
|
|
250
|
-
showAnnotations:
|
|
251
|
-
props.chart.options.annotations.showAnnotations ?? false,
|
|
252
|
-
controlAnnotation:
|
|
253
|
-
props.chart.options.annotations.controlAnnotation || false,
|
|
254
|
-
annotationsData: props.chart.options.annotations.annotationsData || [],
|
|
255
|
-
},
|
|
256
|
-
legend: {
|
|
257
|
-
display: props.chart.options.legend.display ?? true,
|
|
258
|
-
position: props.chart.options.legend.position || 'bottom',
|
|
259
|
-
align: props.chart.options.legend.align || 'center',
|
|
260
|
-
customLegend: props.chart.options.legend.customLegend,
|
|
261
|
-
usePointStyle: props.chart.options.legend.usePointStyle ?? true,
|
|
262
|
-
},
|
|
263
|
-
chartOptions: {
|
|
264
|
-
showPoints: props.chart.options.chartOptions.showPoints ?? true,
|
|
265
|
-
enableZoom: props.chart.options.chartOptions.enableZoom || true,
|
|
266
|
-
enablePan: props.chart.options.chartOptions.enablePan || false,
|
|
267
|
-
showLine: props.chart.options.chartOptions.showLine ?? true,
|
|
268
|
-
closeOnOutsideClick:
|
|
269
|
-
props.chart.options.chartOptions.closeOnOutsideClick || false,
|
|
270
|
-
},
|
|
271
|
-
interactions: {
|
|
272
|
-
onLegendClick: props.chart.options.interactions.onLegendClick,
|
|
273
|
-
onPointHover: props.chart.options.interactions.onPointHover,
|
|
274
|
-
onPointUnhover: props.chart.options.interactions.onPointUnhover,
|
|
275
|
-
onAnimationComplete:
|
|
276
|
-
props.chart.options.interactions.onAnimationComplete,
|
|
277
|
-
},
|
|
278
|
-
depthType: props.chart.options.depthType,
|
|
279
|
-
dragData: {
|
|
280
|
-
enableDragData: props.chart.options.dragData.enableDragData || false,
|
|
281
|
-
showTooltip: props.chart.options.dragData.showTooltip || true,
|
|
282
|
-
roundPoints: props.chart.options.dragData.roundPoints || true,
|
|
283
|
-
dragX: props.chart.options.dragData.dragX || true,
|
|
284
|
-
dragY: props.chart.options.dragData.dragY || true,
|
|
285
|
-
onDragStart: props.chart.options.dragData.onDragStart,
|
|
286
|
-
onDrag: props.chart.options.dragData.onDrag,
|
|
287
|
-
onDragEnd: props.chart.options.dragData.onDragEnd,
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
};
|
|
291
|
-
return chart;
|
|
292
|
-
};
|