@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.
Files changed (99) hide show
  1. package/dist/index.js +39230 -0
  2. package/dist/index.js.map +1 -0
  3. package/package.json +6 -1
  4. package/index.js +0 -14
  5. package/release-notes.md +0 -378
  6. package/src/assets/circle.svg +0 -1
  7. package/src/assets/icons/line-and-point.svg +0 -1
  8. package/src/assets/icons/line-only.svg +0 -1
  9. package/src/assets/icons/list-hide.svg +0 -1
  10. package/src/assets/icons/point-only.svg +0 -1
  11. package/src/assets/rect.svg +0 -1
  12. package/src/assets/rectRot.svg +0 -1
  13. package/src/assets/triangle.svg +0 -1
  14. package/src/components/bar-chart/bar-chart-prop-types.js +0 -209
  15. package/src/components/bar-chart/bar-chart.interface.ts +0 -98
  16. package/src/components/bar-chart/bar-chart.jsx +0 -247
  17. package/src/components/bar-chart/bar-chart.module.less +0 -61
  18. package/src/components/bar-chart/get-bar-chart-data-labels.js +0 -42
  19. package/src/components/bar-chart/get-bar-chart-scales.js +0 -138
  20. package/src/components/bar-chart/get-bar-chart-tooltips.js +0 -102
  21. package/src/components/controls/axes-options/axes-options.jsx +0 -271
  22. package/src/components/line-chart/constants/default-translations.js +0 -24
  23. package/src/components/line-chart/constants/line-chart-consts.js +0 -12
  24. package/src/components/line-chart/controls/axes-options/action-types.js +0 -5
  25. package/src/components/line-chart/controls/axes-options/axes-options-form-state.js +0 -97
  26. package/src/components/line-chart/controls/controls-portal.jsx +0 -12
  27. package/src/components/line-chart/controls/controls.jsx +0 -176
  28. package/src/components/line-chart/controls/controls.module.less +0 -12
  29. package/src/components/line-chart/controls/drag-options.jsx +0 -124
  30. package/src/components/line-chart/controls/line-options.jsx +0 -64
  31. package/src/components/line-chart/hooks/use-chart-functions.js +0 -261
  32. package/src/components/line-chart/hooks/use-chart-options.js +0 -181
  33. package/src/components/line-chart/hooks/use-chart-plugins.js +0 -35
  34. package/src/components/line-chart/hooks/use-toggle-handler.js +0 -33
  35. package/src/components/line-chart/initialize/config.js +0 -23
  36. package/src/components/line-chart/initialize/initialize-line-chart.js +0 -25
  37. package/src/components/line-chart/legend/legend-constants.js +0 -1
  38. package/src/components/line-chart/legend/legend-dropzone.jsx +0 -74
  39. package/src/components/line-chart/legend/legend-item.jsx +0 -105
  40. package/src/components/line-chart/legend/legend-panel.jsx +0 -86
  41. package/src/components/line-chart/legend/legend.jsx +0 -54
  42. package/src/components/line-chart/legend/legend.module.less +0 -192
  43. package/src/components/line-chart/line-chart-prop-types.js +0 -298
  44. package/src/components/line-chart/line-chart.interface.ts +0 -128
  45. package/src/components/line-chart/line-chart.jsx +0 -180
  46. package/src/components/line-chart/line-chart.module.less +0 -78
  47. package/src/components/line-chart/plugins/chart-area-text-plugin.js +0 -246
  48. package/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.js +0 -88
  49. package/src/components/line-chart/plugins/plugin-constants.js +0 -11
  50. package/src/components/line-chart/state/action-types.js +0 -12
  51. package/src/components/line-chart/state/initial-state.js +0 -89
  52. package/src/components/line-chart/state/line-chart-reducer.js +0 -101
  53. package/src/components/line-chart/state/manage-state-in-local-storage.js +0 -86
  54. package/src/components/line-chart/state/use-chart-state.js +0 -141
  55. package/src/components/line-chart/utils/axis-formatting/axis-formatting.js +0 -69
  56. package/src/components/line-chart/utils/axis-scales/axis-scales.js +0 -165
  57. package/src/components/line-chart/utils/datalabels-alignment/get-alignment-condition.js +0 -13
  58. package/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.js +0 -20
  59. package/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.js +0 -25
  60. package/src/components/line-chart/utils/generate-line-chart-datasets.js +0 -122
  61. package/src/components/line-chart/utils/get-axes-ranges-from-chart.js +0 -13
  62. package/src/components/line-chart/utils/get-line-chart-data-labels.js +0 -21
  63. package/src/components/line-chart/utils/get-line-chart-scales.js +0 -117
  64. package/src/components/line-chart/utils/get-line-chart-tooltips.js +0 -94
  65. package/src/components/line-chart/utils/line-chart-utils.js +0 -62
  66. package/src/components/line-chart/utils/translations/get-translations.js +0 -17
  67. package/src/components/pie-chart/pie-chart-prop-types.js +0 -111
  68. package/src/components/pie-chart/pie-chart-utils.js +0 -32
  69. package/src/components/pie-chart/pie-chart.interface.ts +0 -61
  70. package/src/components/pie-chart/pie-chart.jsx +0 -458
  71. package/src/components/pie-chart/pie-chart.module.less +0 -61
  72. package/src/components/scatter-chart/scatter-chart.intefrace.ts +0 -33
  73. package/src/components/scatter-chart/scatter-chart.jsx +0 -21
  74. package/src/components/scatter-chart/scatter-chart.module.less +0 -4
  75. package/src/helpers/chart-border-plugin.js +0 -19
  76. package/src/helpers/chart-consts.js +0 -64
  77. package/src/helpers/chart-interface.ts +0 -94
  78. package/src/helpers/chart-utils.js +0 -178
  79. package/src/helpers/container.jsx +0 -60
  80. package/src/helpers/disabled-context.js +0 -8
  81. package/src/helpers/enums.js +0 -107
  82. package/src/helpers/get-chart-annotation.js +0 -102
  83. package/src/helpers/get-custom-legend-plugin-example.js +0 -80
  84. package/src/helpers/get-draggableData.js +0 -32
  85. package/src/helpers/range/estimate-data-series-have-close-values.js +0 -54
  86. package/src/helpers/range/range.js +0 -100
  87. package/src/helpers/text.js +0 -6
  88. package/src/style/external.less +0 -4
  89. package/src/style/fonts/lato/Lato-Bold.woff2 +0 -0
  90. package/src/style/fonts/lato/Lato-BoldItalic.woff2 +0 -0
  91. package/src/style/fonts/lato/Lato-Italic.woff2 +0 -0
  92. package/src/style/fonts/lato/Lato-Regular.woff2 +0 -0
  93. package/src/style/fonts.less +0 -27
  94. package/src/style/global.less +0 -43
  95. package/src/style/reset/reset.less +0 -28
  96. package/src/style/shared.less +0 -11
  97. package/src/style/variables.less +0 -91
  98. package/vite.config.mjs +0 -49
  99. package/vitest.config.mjs +0 -8
@@ -1,458 +0,0 @@
1
- import React, { useRef, useState } from 'react';
2
- import cx from 'classnames';
3
- import {
4
- ArcElement,
5
- CategoryScale,
6
- Chart as ChartJS,
7
- Filler,
8
- Legend,
9
- LinearScale,
10
- LogarithmicScale,
11
- Title,
12
- Tooltip,
13
- } from 'chart.js';
14
- import zoomPlugin from 'chartjs-plugin-zoom';
15
- import dataLabelsPlugin from 'chartjs-plugin-datalabels';
16
- import { Pie } from 'react-chartjs-2';
17
-
18
- import { round } from '@oliasoft-open-source/units';
19
- import { roundNumberToPrecision } from '@oliasoft-open-source/units/dist/rounding/rounding';
20
- import { ANIMATION_DURATION } from '../../helpers/chart-consts';
21
- import styles from './pie-chart.module.less';
22
- import { colors, generateRandomColor } from './pie-chart-utils';
23
- import { getDefaultProps, PieChartPropTypes } from './pie-chart-prop-types';
24
- import { setDefaultTheme } from '../../helpers/chart-utils';
25
-
26
- ChartJS.register(
27
- LinearScale,
28
- CategoryScale,
29
- LogarithmicScale,
30
- ArcElement,
31
- Legend,
32
- Tooltip,
33
- Title,
34
- Filler,
35
- zoomPlugin,
36
- dataLabelsPlugin,
37
- );
38
-
39
- /**
40
- * this is a pie chart component
41
- * @param {} props
42
- * @param {import('./pie-chart.interface').IPieChartProps} IPieChartProps
43
- * ./pie-chart.interface
44
- */
45
- const PieChart = (props) => {
46
- setDefaultTheme();
47
- const chart = getDefaultProps(props);
48
- const chartRef = useRef(null);
49
- const [pointHover, setPointHover] = useState(false);
50
- const { data, options, testId } = chart;
51
-
52
- const generateDatasets = (datasets) => {
53
- const copyDataset = JSON.parse(JSON.stringify(datasets));
54
-
55
- if (options.graph.stacked) {
56
- const generatedDataset = {
57
- label: copyDataset[0].label,
58
- backgroundColor: [],
59
- borderColor: [],
60
- borderWidth: parseFloat(copyDataset[0].borderWidth) || '1',
61
- data: [],
62
- };
63
- data.labels.map((label, labelIndex) => {
64
- copyDataset.map((arc, arcIndex) => {
65
- generatedDataset.data.push(arc.data[labelIndex]);
66
- const { backgroundColor } = arc;
67
- const { borderColor } = arc;
68
- generatedDataset.backgroundColor.push(
69
- (Array.isArray(backgroundColor)
70
- ? backgroundColor[labelIndex % borderColor.length]
71
- : backgroundColor) ||
72
- colors[labelIndex] + `${99 - 10 * arcIndex}`,
73
- );
74
- generatedDataset.borderColor.push(
75
- (Array.isArray(borderColor)
76
- ? borderColor[labelIndex % borderColor.length]
77
- : borderColor) || colors[labelIndex],
78
- );
79
- });
80
- });
81
- return [generatedDataset];
82
- }
83
-
84
- const generatedDatasets = copyDataset.map((pieDataset, index) => {
85
- const borderWidth = parseFloat(pieDataset.borderWidth) || '1';
86
- const color = pieDataset.data.map(
87
- (pie, i) => colors[i] || generateRandomColor(),
88
- );
89
- const borderColor = pieDataset.borderColor || color;
90
- const backgroundColor =
91
- pieDataset.backgroundColor ||
92
- color.map((col) => col + `${99 - 11 * index}`);
93
-
94
- return {
95
- ...pieDataset,
96
- borderWidth,
97
- borderColor,
98
- backgroundColor,
99
- };
100
- });
101
- return generatedDatasets;
102
- };
103
-
104
- const generatedDatasets = generateDatasets(data.datasets);
105
-
106
- const getTitle = () => {
107
- return options.title !== ''
108
- ? {
109
- display: true,
110
- text: chart.options.title,
111
- }
112
- : {};
113
- };
114
-
115
- const legendClick = (e, legendItem, legend) => {
116
- const chartInstance = legend.chart;
117
- const { datasets } = chartInstance.data;
118
- const { index } = legendItem;
119
-
120
- if (options.graph.stacked) {
121
- if (options.legend.useDataset) {
122
- for (
123
- let i = 0;
124
- i < chartInstance.config._config.data.datasets[0].data.length;
125
- i++
126
- ) {
127
- if (i % data.datasets.length === index) {
128
- const meta = chartInstance.getDatasetMeta(0);
129
- const arc = meta.data[i];
130
- arc.hidden = !arc.hidden;
131
- }
132
- }
133
- } else {
134
- for (
135
- let i = 0;
136
- i < chartInstance.config._config.data.datasets[0].data.length;
137
- i++
138
- ) {
139
- if (parseInt(i / data.datasets.length) === index) {
140
- const meta = chartInstance.getDatasetMeta(0);
141
- const arc = meta.data[i];
142
- arc.hidden = !arc.hidden;
143
- }
144
- }
145
- }
146
- } else {
147
- if (options.legend.useDataset) {
148
- const meta = chartInstance.getDatasetMeta(index);
149
- meta.hidden = !meta.hidden;
150
- } else {
151
- if (datasets.length > 1) {
152
- for (let i = 0; i < data.datasets.length; i++) {
153
- const meta = chartInstance.getDatasetMeta(i);
154
-
155
- const arc = meta.data[index];
156
- arc.hidden = !arc.hidden;
157
- }
158
- } else {
159
- const meta = chartInstance.getDatasetMeta(0);
160
- const arc = meta.data[index];
161
- arc.hidden = !arc.hidden;
162
- }
163
- }
164
- }
165
-
166
- if (options.interactions.onLegendClick)
167
- options.interactions.onLegendClick(legendItem?.text, legendItem.hidden);
168
-
169
- chartInstance.update();
170
- };
171
-
172
- const onClick = (evt, elements, chartInstance) => {
173
- chartInstance.resetZoom();
174
- // TODO: Restore redux-logic for zoom
175
- };
176
-
177
- const onHover = (evt, hoveredItems) => {
178
- if (pointHover && !hoveredItems?.length) {
179
- setPointHover(false);
180
- if (options.interactions.onPieUnhover) {
181
- options.interactions.onPieUnhover(evt);
182
- }
183
- }
184
- if (!pointHover && hoveredItems?.length) {
185
- setPointHover(true);
186
- if (options.interactions.onPieHover) {
187
- const { index, datasetIndex } = hoveredItems[0];
188
- const generatedDataset = generatedDatasets;
189
- options.interactions.onPieHover(
190
- evt,
191
- datasetIndex,
192
- index,
193
- generatedDataset,
194
- );
195
- }
196
- }
197
- };
198
-
199
- const getDatalabels = () => {
200
- return options.graph.showDataLabels
201
- ? {
202
- display: 'auto',
203
- align: 'center',
204
- anchor: 'center',
205
- formatter: (value, context) => {
206
- if (
207
- context.chart.getDatasetMeta(
208
- options.graph.stacked ? 0 : context.datasetIndex,
209
- ).data[context.dataIndex].hidden
210
- )
211
- return '';
212
- const dataElement = context.dataset.data[context.dataIndex];
213
- const label =
214
- dataElement?.label ||
215
- (typeof dataElement === 'number'
216
- ? dataElement
217
- : Array.isArray(dataElement)
218
- ? dataElement.reduce((acc, curr, i) => {
219
- if (i === 0) return `${acc} ${curr}`;
220
- return `${acc}, ${curr}`;
221
- }, '')
222
- : '');
223
- const dataLabel =
224
- typeof dataElement === 'number'
225
- ? Number.isInteger(label)
226
- ? label
227
- : label.toFixed(2)
228
- : label;
229
- return dataLabel;
230
- },
231
- }
232
- : {
233
- display: false,
234
- };
235
- };
236
-
237
- const getLegend = () => {
238
- return {
239
- position: options.legend.position,
240
- display: options.legend.display,
241
- align: options.legend.align,
242
- labels: {
243
- generateLabels(chartInstance) {
244
- if (options.graph.stacked) {
245
- const meta = chartInstance.getDatasetMeta(0);
246
- if (options.legend.useDataset) {
247
- return data.datasets.map((data, i) => {
248
- const { label } = data.datasets[i % data.datasets.length];
249
- const arc = meta.data[i];
250
- const text = arc.hidden
251
- ? label.split('').reduce((acc, curr) => acc + '-', '')
252
- : label;
253
- const backgroundColor = data.datasets[i]?.backgroundColor;
254
- const borderColor = data.datasets[i]?.borderColor;
255
- return {
256
- text,
257
- fillStyle:
258
- (Array.isArray(backgroundColor)
259
- ? backgroundColor[0]
260
- : backgroundColor) || colors[0] + `${99 - 20 * i}`,
261
- strokeStyle:
262
- (Array.isArray(borderColor)
263
- ? borderColor[0]
264
- : borderColor) || colors[0],
265
- index: i,
266
- };
267
- });
268
- } else {
269
- return data.labels.map((data, i) => {
270
- const label = data.labels[i];
271
- const arc = meta.data[parseInt(i * data.datasets.length)];
272
- const text = arc.hidden
273
- ? label.split('').reduce((acc, curr) => acc + '-', '')
274
- : label;
275
- const backgroundColor = data.datasets[0]?.backgroundColor;
276
- const borderColor = data.datasets[0]?.borderColor;
277
- return {
278
- text,
279
- fillStyle:
280
- (Array.isArray(backgroundColor)
281
- ? backgroundColor[i % backgroundColor.length]
282
- : backgroundColor) || colors[i] + '99',
283
- strokeStyle:
284
- (Array.isArray(borderColor)
285
- ? borderColor[i % backgroundColor.length]
286
- : borderColor) || colors[i],
287
- index: i,
288
- };
289
- });
290
- }
291
- }
292
- if (options.legend.useDataset) {
293
- return data.datasets.map((dataset, i) => {
294
- const meta = chartInstance.getDatasetMeta(i);
295
- const text = meta.hidden
296
- ? dataset.label.split('').reduce((acc, curr) => acc + '-', '')
297
- : dataset.label;
298
- const backgroundColor = data.datasets[i]?.backgroundColor;
299
- const borderColor = data.datasets[i]?.borderColor;
300
- return {
301
- text,
302
- fillStyle:
303
- (Array.isArray(backgroundColor)
304
- ? backgroundColor[0]
305
- : backgroundColor) || colors[0] + `${99 - 20 * i}`,
306
- strokeStyle:
307
- (Array.isArray(borderColor) ? borderColor[0] : borderColor) ||
308
- colors[0],
309
- index: i,
310
- };
311
- });
312
- } else {
313
- return data.labels.map((label, i) => {
314
- const meta = chartInstance.getDatasetMeta(0);
315
- const arc = meta.data[i];
316
- const text = arc.hidden
317
- ? label.split('').reduce((acc, curr) => acc + '-', '')
318
- : label;
319
- const backgroundColor = data.datasets[0]?.backgroundColor;
320
- const borderColor = data.datasets[0]?.borderColor;
321
- return {
322
- text,
323
- fillStyle:
324
- (Array.isArray(backgroundColor)
325
- ? backgroundColor[i % backgroundColor.length]
326
- : backgroundColor) || colors[i] + '99',
327
- strokeStyle:
328
- (Array.isArray(borderColor)
329
- ? borderColor[i % backgroundColor.length]
330
- : borderColor) || colors[i],
331
- index: i,
332
- };
333
- });
334
- }
335
- },
336
- boxHeight: 6,
337
- boxWidth: 6,
338
- usePointStyle: true,
339
- filter: (item, data) => {
340
- if (!options.legend.useDataset) return true;
341
- return !data.datasets[item.index]?.hideLegend;
342
- },
343
- },
344
- onClick: legendClick,
345
- };
346
- };
347
-
348
- const getToolTips = () => {
349
- return {
350
- callbacks: {
351
- title: (tooltipItem) => {
352
- const { dataIndex } = tooltipItem[0];
353
- const index = options.graph.stacked
354
- ? parseInt(dataIndex / data.labels.length)
355
- : dataIndex;
356
- const label = data.labels[index];
357
- return `${label}`;
358
- },
359
- label: (tooltipItem) => {
360
- const { dataIndex } = tooltipItem;
361
- const datasetIndex = options.graph.stacked
362
- ? dataIndex % data.datasets.length
363
- : tooltipItem.datasetIndex;
364
- const dataLabel =
365
- data.datasets.length > 1
366
- ? `${data.datasets[datasetIndex]?.label}: `
367
- : '';
368
- const value = tooltipItem.dataset.data[dataIndex];
369
- const labelValue =
370
- typeof value === 'object'
371
- ? `${value.value || ''} ${
372
- options.tooltip.showLabelsInTooltips && value.label
373
- ? '(' + value.label + ')'
374
- : ''
375
- }`
376
- : value;
377
- const unit = data?.yUnit ? `[${data?.yUnit}]` : '';
378
- const formattedValue =
379
- Math.abs(labelValue) < 1
380
- ? roundNumberToPrecision(labelValue, { n: 3 })
381
- : round(labelValue, 3);
382
-
383
- return `${dataLabel} ${formattedValue} ${unit}`;
384
- },
385
- },
386
- };
387
- };
388
- return (
389
- <div
390
- className={cx(
391
- styles.chart,
392
- !options.chartStyling.width || !options.chartStyling.height
393
- ? options.chartStyling.staticChartHeight
394
- ? styles.fixedHeight
395
- : styles.stretchHeight
396
- : '',
397
- )}
398
- style={{
399
- width: options.chartStyling.width || 'auto',
400
- height: options.chartStyling.height || 'auto',
401
- }}
402
- data-testid={testId}
403
- >
404
- <Pie
405
- ref={chartRef}
406
- data={{
407
- datasets: generatedDatasets,
408
- labels: options.graph.stacked ? undefined : data.labels,
409
- }}
410
- options={{
411
- cutout: options.graph.cutout,
412
- onClick,
413
- responsive: true, // Defaults to true, should be removed
414
- maintainAspectRatio: options.chartStyling.maintainAspectRatio,
415
- animation: options.chartStyling.performanceMode
416
- ? false
417
- : {
418
- duration: ANIMATION_DURATION.FAST,
419
- },
420
- hover: {
421
- mode: 'nearest',
422
- intersect: 'true',
423
- },
424
- onHover,
425
- elements: {
426
- pie: {
427
- pointStyle: 'circle',
428
- },
429
- },
430
- plugins: {
431
- annotation: false, // Disable globally-registered annotation plugin
432
- title: getTitle(),
433
- datalabels: getDatalabels(),
434
- // zoom: {
435
- // pan: {
436
- // enabled: ,
437
- // mode: ,
438
- // },
439
- // zoom: {
440
- // drag: {
441
- // enabled:,
442
- // },
443
- // mode: ,
444
- // speed: ,
445
- // },
446
- // },
447
- tooltip: getToolTips(),
448
- legend: getLegend(),
449
- },
450
- }}
451
- />
452
- </div>
453
- );
454
- };
455
-
456
- PieChart.propTypes = PieChartPropTypes;
457
-
458
- export { PieChart };
@@ -1,61 +0,0 @@
1
- html[data-theme='dark'] .chart canvas {
2
- // Flip chart colors if dark mode enabled
3
- filter: invert(1) hue-rotate(180deg);
4
- }
5
-
6
- .chart {
7
- border: 1px solid rgba(255, 255, 255, 0);
8
- padding-top: 10px;
9
- position: relative;
10
-
11
- canvas {
12
- width: 100% !important; // Fix for resizing bug
13
- height: 100% !important; // Remove if stretched when maintainAspectRatio=true
14
- }
15
-
16
- &.fixedHeight {
17
- display: flex;
18
- align-items: flex-start;
19
- justify-content: flex-start;
20
- height: auto;
21
- }
22
-
23
- &.stretchHeight {
24
- display: flex;
25
- align-items: stretch;
26
- justify-content: stretch;
27
- height: 100%;
28
- }
29
-
30
- &:focus {
31
- border: 1px solid #85b7d9;
32
- outline: none; // Remove dotted outline on FF
33
- }
34
-
35
- &::-moz-focus-inner {
36
- border: 0; // Remove dotted outline on FF
37
- }
38
- }
39
-
40
- .zoomForm {
41
- position: absolute;
42
- display: flex;
43
- align-items: center;
44
- justify-content: center;
45
- top: 0;
46
- right: 0;
47
-
48
- .zoomReset {
49
- margin-left: 10px;
50
- }
51
-
52
- .help {
53
- margin-left: 5px;
54
- line-height: 0; // Strip whitespace from icon
55
- }
56
- }
57
-
58
- .autoWeight {
59
- width: 'auto';
60
- height: 'auto';
61
- }
@@ -1,33 +0,0 @@
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
- testId: string | null;
25
- data: {
26
- datasets: IScatterChartDataset[]
27
- };
28
- options: IScatterChartOptions;
29
- }
30
-
31
- export interface IScatterChartProps {
32
- chart: IScatterChartData;
33
- }
@@ -1,21 +0,0 @@
1
- import React from 'react';
2
- import { Scatter } from 'react-chartjs-2';
3
-
4
- import { setDefaultTheme } from '../../helpers/chart-utils';
5
- import styles from './scatter-chart.module.less';
6
-
7
- /**
8
- *
9
- * @param {import('./scatter-chart.intefrace').IScatterChartProps} props
10
- */
11
- const ScatterChart = (props) => {
12
- setDefaultTheme();
13
- const { data, options, testId = null } = props.chart;
14
- return (
15
- <div className={styles.chart}>
16
- <Scatter options={options} data={data} data-testid={testId} />
17
- </div>
18
- );
19
- };
20
-
21
- export default ScatterChart;
@@ -1,4 +0,0 @@
1
- html[data-theme='dark'] .chart canvas {
2
- // Flip chart colors if dark mode enabled
3
- filter: invert(1) hue-rotate(180deg);
4
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * Chart border plugin config
3
- */
4
- export const chartAreaBorderPlugin = {
5
- id: 'chartAreaBorder',
6
- beforeDraw(chart, args, options) {
7
- const {
8
- ctx,
9
- chartArea: { left, top, width, height },
10
- } = chart;
11
- ctx.save();
12
- ctx.strokeStyle = options.borderColor;
13
- ctx.lineWidth = options.borderWidth;
14
- ctx.setLineDash(options.borderDash || []);
15
- ctx.lineDashOffset = options.borderDashOffset;
16
- ctx.strokeRect(left, top, width, height);
17
- ctx.restore();
18
- },
19
- };
@@ -1,64 +0,0 @@
1
- export const BORDER_WIDTH = {
2
- INITIAL: 2,
3
- HOVERED: 6,
4
- };
5
- export const BORDER_COLOR = 'rgba(0,0,0,0.1)';
6
-
7
- export const ANNOTATION_DASH = [10, 2];
8
- export const DEFAULT_FONT_SIZE = 13;
9
- export const DEFAULT_FONT_FAMILY = '"Lato", sans-serif';
10
- export const DEFAULT_COLOR = 'rgba(0,0,0,.87)';
11
- export const LEGEND_LABEL_BOX_SIZE = 6;
12
-
13
- export const LOGARITHMIC_STEPS = [1, 10, 100, 1000, 10000];
14
-
15
- export const COLORS = [
16
- '#3366cc',
17
- '#dc3912',
18
- '#ff9900',
19
- '#109618',
20
- '#990099',
21
- '#0099c6',
22
- '#dd4477',
23
- '#66aa00',
24
- '#b82e2e',
25
- '#316395',
26
- '#994499',
27
- '#22aa99',
28
- '#aaaa11',
29
- '#6633cc',
30
- '#e67300',
31
- '#8b0707',
32
- '#651067',
33
- '#329262',
34
- '#5574a6',
35
- '#3b3eac',
36
- ];
37
-
38
- /**
39
- * @type {string}
40
- * @desc equivalent of 0.6 rgba alpha chanel
41
- */
42
- export const ALPHA_CHANEL = '99';
43
-
44
- /**
45
- * @type {number}
46
- * @desc #FFFFFF as decimal number
47
- */
48
- export const WHITE_COLOR_AS_DECIMAL = 16777215;
49
-
50
- export const AUTO = 'auto';
51
-
52
- export const ANIMATION_DURATION = {
53
- NO: 0,
54
- SLOW: 400,
55
- FAST: 1000,
56
- };
57
-
58
- export const DEFAULT_CHART_NAME = 'new_chart';
59
-
60
- export const CUSTOM_LEGEND_PLUGIN_NAME = 'htmlLegend';
61
-
62
- export const DECIMAL_POINT_TOLERANCE = 9;
63
-
64
- export const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;