@oliasoft-open-source/charts-library 2.0.0

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 (79) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +129 -0
  3. package/.gitlab-ci.yml +77 -0
  4. package/.husky/pre-commit +4 -0
  5. package/.prettierignore +3 -0
  6. package/.prettierrc +4 -0
  7. package/.storybook/main.js +40 -0
  8. package/LICENSE +21 -0
  9. package/README.md +5 -0
  10. package/babel.config.js +29 -0
  11. package/index.js +9 -0
  12. package/jest.config.js +9 -0
  13. package/package.json +96 -0
  14. package/src/components/bar-chart/bar-chart-prop-types.js +181 -0
  15. package/src/components/bar-chart/bar-chart.interface.ts +83 -0
  16. package/src/components/bar-chart/bar-chart.jsx +247 -0
  17. package/src/components/bar-chart/bar-chart.module.less +56 -0
  18. package/src/components/bar-chart/basic.stories.jsx +752 -0
  19. package/src/components/bar-chart/charts.stories.jsx +119 -0
  20. package/src/components/bar-chart/get-bar-chart-data-labels.js +45 -0
  21. package/src/components/bar-chart/get-bar-chart-scales.js +147 -0
  22. package/src/components/bar-chart/get-bar-chart-tooltips.js +100 -0
  23. package/src/components/line-chart/Controls/Controls.jsx +59 -0
  24. package/src/components/line-chart/Controls/Controls.module.less +21 -0
  25. package/src/components/line-chart/Controls/Layer.jsx +169 -0
  26. package/src/components/line-chart/basic.stories.jsx +735 -0
  27. package/src/components/line-chart/charts.stories.jsx +264 -0
  28. package/src/components/line-chart/get-line-chart-data-labels.js +24 -0
  29. package/src/components/line-chart/get-line-chart-scales.js +131 -0
  30. package/src/components/line-chart/get-line-chart-tooltips.js +91 -0
  31. package/src/components/line-chart/line-chart-consts.js +6 -0
  32. package/src/components/line-chart/line-chart-prop-types.js +187 -0
  33. package/src/components/line-chart/line-chart-utils.js +163 -0
  34. package/src/components/line-chart/line-chart.interface.ts +103 -0
  35. package/src/components/line-chart/line-chart.jsx +423 -0
  36. package/src/components/line-chart/line-chart.minor-gridlines-plugin.js +78 -0
  37. package/src/components/line-chart/line-chart.minor-gridlines-plugin.test.js +34 -0
  38. package/src/components/line-chart/line-chart.module.less +56 -0
  39. package/src/components/line-chart/state/action-types.js +9 -0
  40. package/src/components/line-chart/state/initial-state.js +51 -0
  41. package/src/components/line-chart/state/line-chart-reducer.js +115 -0
  42. package/src/components/line-chart/stories/shapes/cubes.stories.jsx +326 -0
  43. package/src/components/line-chart/stories/shapes/pyramid.stories.jsx +189 -0
  44. package/src/components/line-chart/stories/shapes/round.stories.jsx +339 -0
  45. package/src/components/line-chart/stories/shapes/triangle.stories.jsx +166 -0
  46. package/src/components/pie-chart/basic.stories.jsx +390 -0
  47. package/src/components/pie-chart/charts.stories.jsx +66 -0
  48. package/src/components/pie-chart/pie-chart-prop-types.js +111 -0
  49. package/src/components/pie-chart/pie-chart-utils.js +55 -0
  50. package/src/components/pie-chart/pie-chart.interface.ts +61 -0
  51. package/src/components/pie-chart/pie-chart.jsx +477 -0
  52. package/src/components/pie-chart/pie-chart.module.less +56 -0
  53. package/src/components/scatter-chart/scatter-chart.intefrace.ts +32 -0
  54. package/src/components/scatter-chart/scatter-chart.jsx +13 -0
  55. package/src/components/scatter-chart/scatter.stories.jsx +196 -0
  56. package/src/helpers/chart-consts.js +82 -0
  57. package/src/helpers/chart-interface.ts +54 -0
  58. package/src/helpers/chart-utils.js +178 -0
  59. package/src/helpers/container.jsx +60 -0
  60. package/src/helpers/disabled-context.js +8 -0
  61. package/src/helpers/enums.js +84 -0
  62. package/src/helpers/get-chart-annotation.js +91 -0
  63. package/src/helpers/styles.js +68 -0
  64. package/src/helpers/text.js +6 -0
  65. package/src/style/external.less +4 -0
  66. package/src/style/fonts/lato/Lato-Bold.woff2 +0 -0
  67. package/src/style/fonts/lato/Lato-BoldItalic.woff2 +0 -0
  68. package/src/style/fonts/lato/Lato-Italic.woff2 +0 -0
  69. package/src/style/fonts/lato/Lato-Regular.woff2 +0 -0
  70. package/src/style/fonts.less +27 -0
  71. package/src/style/global.less +43 -0
  72. package/src/style/reset/reset.less +28 -0
  73. package/src/style/shared.less +24 -0
  74. package/src/style/variables.less +91 -0
  75. package/webpack/webpack.common.js +39 -0
  76. package/webpack/webpack.common.rules.js +107 -0
  77. package/webpack/webpack.dev.js +22 -0
  78. package/webpack/webpack.prod.js +23 -0
  79. package/webpack/webpack.resolve.js +22 -0
@@ -0,0 +1,477 @@
1
+ import React, { useRef, useState } from 'react';
2
+ import cx from 'classnames';
3
+ import {
4
+ ArcElement,
5
+ CategoryScale,
6
+ Chart as ChartJS,
7
+ defaults,
8
+ Filler,
9
+ Legend,
10
+ LinearScale,
11
+ LogarithmicScale,
12
+ Title,
13
+ Tooltip,
14
+ } from 'chart.js';
15
+ import zoomPlugin from 'chartjs-plugin-zoom';
16
+ import dataLabelsPlugin from 'chartjs-plugin-datalabels';
17
+ import { Pie } from 'react-chartjs-2';
18
+
19
+ import styles from './pie-chart.module.less';
20
+ import { colors, colorsDarkmode, generateRandomColor } from './pie-chart-utils';
21
+ import { getDefaultProps, PieChartPropTypes } from './pie-chart-prop-types';
22
+ import {
23
+ DEFAULT_COLOR,
24
+ DEFAULT_DARK_MODE_BORDER_COLOR,
25
+ DEFAULT_DARK_MODE_COLOR,
26
+ } from '../../helpers/chart-consts';
27
+
28
+ ChartJS.register(
29
+ LinearScale,
30
+ CategoryScale,
31
+ LogarithmicScale,
32
+ ArcElement,
33
+ Legend,
34
+ Tooltip,
35
+ Title,
36
+ Filler,
37
+ zoomPlugin,
38
+ dataLabelsPlugin,
39
+ );
40
+
41
+ defaults.font.size = 13;
42
+ defaults.color = DEFAULT_COLOR;
43
+ defaults.font.family = '"Lato", sans-serif';
44
+ defaults.darkModeColor = DEFAULT_DARK_MODE_COLOR;
45
+ defaults.darkModeBorderColor = DEFAULT_DARK_MODE_BORDER_COLOR;
46
+
47
+ /**
48
+ * this is a pie chart component
49
+ * @param {} props
50
+ * @param {import('./pie-chart.interface').IPieChartProps} IPieChartProps
51
+ * ./pie-chart.interface
52
+ */
53
+ const PieChart = (props) => {
54
+ const chart = getDefaultProps(props);
55
+ const chartRef = useRef(null);
56
+ const [pointHover, setPointHover] = useState(false);
57
+
58
+ const generateDatasets = (datasets) => {
59
+ const copyDataset = JSON.parse(JSON.stringify(datasets));
60
+
61
+ if (chart.options.graph.stacked) {
62
+ const generatedDataset = {
63
+ label: copyDataset[0].label,
64
+ backgroundColor: [],
65
+ borderColor: [],
66
+ borderWidth: parseFloat(copyDataset[0].borderWidth) || '1',
67
+ data: [],
68
+ };
69
+ chart.data.labels.map((label, labelIndex) => {
70
+ copyDataset.map((arc, arcIndex) => {
71
+ generatedDataset.data.push(arc.data[labelIndex]);
72
+ const { backgroundColor } = arc;
73
+ const { borderColor } = arc;
74
+ generatedDataset.backgroundColor.push(
75
+ (Array.isArray(backgroundColor)
76
+ ? backgroundColor[labelIndex % borderColor.length]
77
+ : backgroundColor) ||
78
+ colors[labelIndex] + `${99 - 10 * arcIndex}`,
79
+ );
80
+ generatedDataset.borderColor.push(
81
+ (Array.isArray(borderColor)
82
+ ? borderColor[labelIndex % borderColor.length]
83
+ : borderColor) || colors[labelIndex],
84
+ );
85
+ });
86
+ });
87
+ return [generatedDataset];
88
+ }
89
+
90
+ const generatedDatasets = copyDataset.map((pieDataset, index) => {
91
+ const borderWidth = parseFloat(pieDataset.borderWidth) || '1';
92
+ const colorLightmode = pieDataset.data.map(
93
+ (pie, i) => colors[i] || generateRandomColor(),
94
+ );
95
+ const colorDarkmode = pieDataset.data.map(
96
+ (pie, i) => colorsDarkmode[i] || generateRandomColor(),
97
+ );
98
+ const color = chart.options.chartStyling.darkMode
99
+ ? colorDarkmode
100
+ : colorLightmode;
101
+ const borderColor = pieDataset.borderColor || color;
102
+ const backgroundColor =
103
+ pieDataset.backgroundColor ||
104
+ color.map((col) => col + `${99 - 11 * index}`);
105
+
106
+ return {
107
+ ...pieDataset,
108
+ borderWidth,
109
+ borderColor,
110
+ backgroundColor,
111
+ };
112
+ });
113
+ return generatedDatasets;
114
+ };
115
+
116
+ const generatedDatasets = generateDatasets(chart.data.datasets);
117
+
118
+ const getTitle = () => {
119
+ return chart.options.title !== ''
120
+ ? {
121
+ display: true,
122
+ text: chart.options.title,
123
+ color: chart.options.chartStyling.darkMode
124
+ ? defaults.darkModeColor
125
+ : undefined,
126
+ }
127
+ : {};
128
+ };
129
+
130
+ const legendClick = (e, legendItem, legend) => {
131
+ const chartInstance = legend.chart;
132
+ const { datasets } = chartInstance.data;
133
+ const { index } = legendItem;
134
+
135
+ if (chart.options.graph.stacked) {
136
+ if (chart.options.legend.useDataset) {
137
+ for (
138
+ let i = 0;
139
+ i < chartInstance.config._config.data.datasets[0].data.length;
140
+ i++
141
+ ) {
142
+ if (i % chart.data.datasets.length === index) {
143
+ const meta = chartInstance.getDatasetMeta(0);
144
+ const arc = meta.data[i];
145
+ arc.hidden = !arc.hidden;
146
+ }
147
+ }
148
+ } else {
149
+ for (
150
+ let i = 0;
151
+ i < chartInstance.config._config.data.datasets[0].data.length;
152
+ i++
153
+ ) {
154
+ if (parseInt(i / chart.data.datasets.length) === index) {
155
+ const meta = chartInstance.getDatasetMeta(0);
156
+ const arc = meta.data[i];
157
+ arc.hidden = !arc.hidden;
158
+ }
159
+ }
160
+ }
161
+ } else {
162
+ if (chart.options.legend.useDataset) {
163
+ const meta = chartInstance.getDatasetMeta(index);
164
+ meta.hidden = !meta.hidden;
165
+ } else {
166
+ if (datasets.length > 1) {
167
+ for (let i = 0; i < chart.data.datasets.length; i++) {
168
+ const meta = chartInstance.getDatasetMeta(i);
169
+
170
+ const arc = meta.data[index];
171
+ arc.hidden = !arc.hidden;
172
+ }
173
+ } else {
174
+ const meta = chartInstance.getDatasetMeta(0);
175
+ const arc = meta.data[index];
176
+ arc.hidden = !arc.hidden;
177
+ }
178
+ }
179
+ }
180
+
181
+ if (chart.options.interactions.onLegendClick)
182
+ chart.options.interactions.onLegendClick(
183
+ legendItem?.text,
184
+ legendItem.hidden,
185
+ );
186
+
187
+ chartInstance.update();
188
+ };
189
+
190
+ const onClick = (evt, elements, chartInstance) => {
191
+ chartInstance.resetZoom();
192
+ // TODO: Restore redux-logic for zoom
193
+ };
194
+
195
+ const onHover = (evt, hoveredItems) => {
196
+ if (pointHover && !hoveredItems?.length) {
197
+ setPointHover(false);
198
+ if (chart.options.interactions.onPieUnhover) {
199
+ chart.options.interactions.onPieUnhover(evt);
200
+ }
201
+ }
202
+ if (!pointHover && hoveredItems?.length) {
203
+ setPointHover(true);
204
+ if (chart.options.interactions.onPieHover) {
205
+ const { index, datasetIndex } = hoveredItems[0];
206
+ const generatedDataset = generatedDatasets;
207
+ chart.options.interactions.onPieHover(
208
+ evt,
209
+ datasetIndex,
210
+ index,
211
+ generatedDataset,
212
+ );
213
+ }
214
+ }
215
+ };
216
+
217
+ const getDatalabels = () => {
218
+ return chart.options.graph.showDataLabels
219
+ ? {
220
+ display: 'auto',
221
+ align: 'center',
222
+ anchor: 'center',
223
+ formatter: (value, context) => {
224
+ if (
225
+ context.chart.getDatasetMeta(
226
+ chart.options.graph.stacked ? 0 : context.datasetIndex,
227
+ ).data[context.dataIndex].hidden
228
+ )
229
+ return '';
230
+ const dataElement = context.dataset.data[context.dataIndex];
231
+ const label =
232
+ dataElement?.label ||
233
+ (typeof dataElement === 'number'
234
+ ? dataElement
235
+ : Array.isArray(dataElement)
236
+ ? dataElement.reduce((acc, curr, i) => {
237
+ if (i === 0) return `${acc} ${curr}`;
238
+ return `${acc}, ${curr}`;
239
+ }, '')
240
+ : '');
241
+ const dataLabel =
242
+ typeof dataElement === 'number'
243
+ ? Number.isInteger(label)
244
+ ? label
245
+ : label.toFixed(2)
246
+ : label;
247
+ return dataLabel;
248
+ },
249
+ color: chart.options.chartStyling.darkMode
250
+ ? defaults.darkModeColor
251
+ : undefined,
252
+ }
253
+ : {
254
+ display: false,
255
+ };
256
+ };
257
+
258
+ const getLegend = () => {
259
+ return {
260
+ position: chart.options.legend.position,
261
+ display: chart.options.legend.display,
262
+ align: chart.options.legend.align,
263
+ labels: {
264
+ generateLabels(chartInstance) {
265
+ if (chart.options.graph.stacked) {
266
+ const meta = chartInstance.getDatasetMeta(0);
267
+ if (chart.options.legend.useDataset) {
268
+ return chart.data.datasets.map((data, i) => {
269
+ const { label } =
270
+ chart.data.datasets[i % chart.data.datasets.length];
271
+ const arc = meta.data[i];
272
+ const text = arc.hidden
273
+ ? label.split('').reduce((acc, curr) => acc + '-', '')
274
+ : label;
275
+ const backgroundColor = chart.data.datasets[i]?.backgroundColor;
276
+ const borderColor = chart.data.datasets[i]?.borderColor;
277
+ return {
278
+ text,
279
+ fillStyle:
280
+ (Array.isArray(backgroundColor)
281
+ ? backgroundColor[0]
282
+ : backgroundColor) || colors[0] + `${99 - 20 * i}`,
283
+ strokeStyle:
284
+ (Array.isArray(borderColor)
285
+ ? borderColor[0]
286
+ : borderColor) || colors[0],
287
+ index: i,
288
+ };
289
+ });
290
+ } else {
291
+ return chart.data.labels.map((data, i) => {
292
+ const label = chart.data.labels[i];
293
+ const arc = meta.data[parseInt(i * chart.data.datasets.length)];
294
+ const text = arc.hidden
295
+ ? label.split('').reduce((acc, curr) => acc + '-', '')
296
+ : label;
297
+ const backgroundColor = chart.data.datasets[0]?.backgroundColor;
298
+ const borderColor = chart.data.datasets[0]?.borderColor;
299
+ return {
300
+ text,
301
+ fillStyle:
302
+ (Array.isArray(backgroundColor)
303
+ ? backgroundColor[i % backgroundColor.length]
304
+ : backgroundColor) || colors[i] + '99',
305
+ strokeStyle:
306
+ (Array.isArray(borderColor)
307
+ ? borderColor[i % backgroundColor.length]
308
+ : borderColor) || colors[i],
309
+ index: i,
310
+ };
311
+ });
312
+ }
313
+ }
314
+ if (chart.options.legend.useDataset) {
315
+ return chart.data.datasets.map((dataset, i) => {
316
+ const meta = chartInstance.getDatasetMeta(i);
317
+ const text = meta.hidden
318
+ ? dataset.label.split('').reduce((acc, curr) => acc + '-', '')
319
+ : dataset.label;
320
+ const backgroundColor = chart.data.datasets[i]?.backgroundColor;
321
+ const borderColor = chart.data.datasets[i]?.borderColor;
322
+ return {
323
+ text,
324
+ fillStyle:
325
+ (Array.isArray(backgroundColor)
326
+ ? backgroundColor[0]
327
+ : backgroundColor) || colors[0] + `${99 - 20 * i}`,
328
+ strokeStyle:
329
+ (Array.isArray(borderColor) ? borderColor[0] : borderColor) ||
330
+ colors[0],
331
+ index: i,
332
+ };
333
+ });
334
+ } else {
335
+ return chart.data.labels.map((label, i) => {
336
+ const meta = chartInstance.getDatasetMeta(0);
337
+ const arc = meta.data[i];
338
+ const text = arc.hidden
339
+ ? label.split('').reduce((acc, curr) => acc + '-', '')
340
+ : label;
341
+ const backgroundColor = chart.data.datasets[0]?.backgroundColor;
342
+ const borderColor = chart.data.datasets[0]?.borderColor;
343
+ return {
344
+ text,
345
+ fillStyle:
346
+ (Array.isArray(backgroundColor)
347
+ ? backgroundColor[i % backgroundColor.length]
348
+ : backgroundColor) || colors[i] + '99',
349
+ strokeStyle:
350
+ (Array.isArray(borderColor)
351
+ ? borderColor[i % backgroundColor.length]
352
+ : borderColor) || colors[i],
353
+ index: i,
354
+ };
355
+ });
356
+ }
357
+ },
358
+ boxHeight: 6,
359
+ boxWidth: 6,
360
+ usePointStyle: true,
361
+ color: chart.options.chartStyling.darkMode
362
+ ? defaults.darkModeColor
363
+ : undefined,
364
+ filter: (item, data) => {
365
+ if (!chart.options.legend.useDataset) return true;
366
+ return !chart.data.datasets[item.index]?.hideLegend;
367
+ },
368
+ },
369
+ onClick: legendClick,
370
+ };
371
+ };
372
+
373
+ const getToolTips = () => {
374
+ return {
375
+ callbacks: {
376
+ title: (tooltipItem) => {
377
+ const { dataIndex } = tooltipItem[0];
378
+ const index = chart.options.graph.stacked
379
+ ? parseInt(dataIndex / chart.data.labels.length)
380
+ : dataIndex;
381
+ const label = chart.data.labels[index];
382
+ return `${label}`;
383
+ },
384
+ label: (tooltipItem) => {
385
+ const { dataIndex } = tooltipItem;
386
+ const datasetIndex = chart.options.graph.stacked
387
+ ? dataIndex % chart.data.datasets.length
388
+ : tooltipItem.datasetIndex;
389
+ const dataLabel =
390
+ chart.data.datasets.length > 1
391
+ ? `${chart.data.datasets[datasetIndex]?.label}: `
392
+ : '';
393
+ const value = tooltipItem.dataset.data[dataIndex];
394
+ const labelValue =
395
+ typeof value === 'object'
396
+ ? `${value.value || ''} ${
397
+ chart.options.tooltip.showLabelsInTooltips && value.label
398
+ ? '(' + value.label + ')'
399
+ : ''
400
+ }`
401
+ : value;
402
+ const unit = chart.data?.yUnit ? `[${chart.data?.yUnit}]` : '';
403
+ return `${dataLabel} ${labelValue} ${unit}`;
404
+ },
405
+ },
406
+ };
407
+ };
408
+ return (
409
+ <div
410
+ className={cx(
411
+ styles.chart,
412
+ !chart.options.chartStyling.width || !chart.options.chartStyling.height
413
+ ? chart.options.chartStyling.staticChartHeight
414
+ ? styles.fixedHeight
415
+ : styles.stretchHeight
416
+ : '',
417
+ )}
418
+ style={{
419
+ width: chart.options.chartStyling.width || 'auto',
420
+ height: chart.options.chartStyling.height || 'auto',
421
+ }}
422
+ >
423
+ <Pie
424
+ ref={chartRef}
425
+ data={{
426
+ datasets: generatedDatasets,
427
+ labels: chart.options.graph.stacked ? undefined : chart.data.labels,
428
+ }}
429
+ options={{
430
+ cutout: chart.options.graph.cutout,
431
+ onClick,
432
+ responsive: true, // Defaults to true, should be removed
433
+ maintainAspectRatio: chart.options.chartStyling.maintainAspectRatio,
434
+ animation: {
435
+ duration: chart.options.chartStyling.performanceMode ? 0 : 1000,
436
+ },
437
+ hover: {
438
+ mode: 'nearest',
439
+ intersect: 'true',
440
+ animationDuration: chart.options.chartStyling.performanceMode
441
+ ? 0
442
+ : 400,
443
+ },
444
+ onHover,
445
+ elements: {
446
+ pie: {
447
+ pointStyle: 'circle',
448
+ },
449
+ },
450
+ plugins: {
451
+ title: getTitle(),
452
+ datalabels: getDatalabels(),
453
+ // zoom: {
454
+ // pan: {
455
+ // enabled: ,
456
+ // mode: ,
457
+ // },
458
+ // zoom: {
459
+ // drag: {
460
+ // enabled:,
461
+ // },
462
+ // mode: ,
463
+ // speed: ,
464
+ // },
465
+ // },
466
+ tooltip: getToolTips(),
467
+ legend: getLegend(),
468
+ },
469
+ }}
470
+ />
471
+ </div>
472
+ );
473
+ };
474
+
475
+ PieChart.propTypes = PieChartPropTypes;
476
+
477
+ export { PieChart };
@@ -0,0 +1,56 @@
1
+ .chart {
2
+ border: 1px solid rgba(255, 255, 255, 0);
3
+ padding-top: 10px;
4
+ position: relative;
5
+
6
+ canvas {
7
+ width: 100% !important; // Fix for resizing bug
8
+ height: 100% !important; // Remove if stretched when maintainAspectRatio=true
9
+ }
10
+
11
+ &.fixedHeight {
12
+ display: flex;
13
+ align-items: flex-start;
14
+ justify-content: flex-start;
15
+ height: auto;
16
+ }
17
+
18
+ &.stretchHeight {
19
+ display: flex;
20
+ align-items: stretch;
21
+ justify-content: stretch;
22
+ height: 100%;
23
+ }
24
+
25
+ &:focus {
26
+ border: 1px solid #85b7d9;
27
+ outline: none; // Remove dotted outline on FF
28
+ }
29
+
30
+ &::-moz-focus-inner {
31
+ border: 0; // Remove dotted outline on FF
32
+ }
33
+ }
34
+
35
+ .zoomForm {
36
+ position: absolute;
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+ top: 0;
41
+ right: 0;
42
+
43
+ .zoomReset {
44
+ margin-left: 10px;
45
+ }
46
+
47
+ .help {
48
+ margin-left: 5px;
49
+ line-height: 0; // Strip whitespace from icon
50
+ }
51
+ }
52
+
53
+ .autoWeight {
54
+ width: 'auto';
55
+ height: 'auto';
56
+ }
@@ -0,0 +1,32 @@
1
+ import { IChartPlugins } from "../../helpers/chart-interface";
2
+
3
+ export interface IScatterChartOptions {
4
+ responsive: boolean;
5
+ maintainAspectRatio: boolean;
6
+ plugins: IChartPlugins;
7
+ }
8
+
9
+ export interface IScatterChartPoint {
10
+ x: number | string;
11
+ y: number | string;
12
+ label?: string;
13
+ }
14
+
15
+ export interface IScatterChartDataset {
16
+ label: string;
17
+ data: IScatterChartPoint[];
18
+ borderColor: string;
19
+ backgroundColor: string;
20
+ showLine: Boolean
21
+ }
22
+
23
+ export interface IScatterChartData {
24
+ data: {
25
+ datasets: IScatterChartDataset[]
26
+ };
27
+ options: IScatterChartOptions;
28
+ }
29
+
30
+ export interface IScatterChartProps {
31
+ chart: IScatterChartData;
32
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { Scatter } from 'react-chartjs-2';
3
+
4
+ /**
5
+ *
6
+ * @param {import('./scatter-chart.intefrace').IScatterChartProps} props
7
+ */
8
+ const ScatterChart = (props) => {
9
+ const { data, options } = props.chart;
10
+ return <Scatter options={options} data={data} />;
11
+ };
12
+
13
+ export default ScatterChart;