@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,390 @@
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { PieChart } from './pie-chart';
4
+ import { Container } from '../../helpers/container';
5
+
6
+ const style = {
7
+ height: '1000px',
8
+ width: '1000px',
9
+ };
10
+
11
+ const darkmodeStyle = {
12
+ backgroundColor: '#232628',
13
+ };
14
+
15
+ const labels1 = ['label 1', 'label 2', 'label 3'];
16
+ const dataset1 = { label: 'data1', data: [3, 8, 7] };
17
+ const dataset2 = { label: 'data2', data: [1, 2, 3] };
18
+ const dataset3 = { label: 'data3', data: [5, 0, 4] };
19
+
20
+ const spacingDataset = {
21
+ label: 'spacing data',
22
+ spacing: 50,
23
+ data: [3, 8, 7],
24
+ };
25
+ const offsetDataset = {
26
+ label: 'spacing data',
27
+ offset: 40,
28
+ data: [3, 8, 7],
29
+ };
30
+ const circumferenceDataset = {
31
+ label: 'circumference data',
32
+ circumference: 270,
33
+ data: [3, 8, 7],
34
+ };
35
+ const borderWidthDataset = {
36
+ label: 'border data',
37
+ borderWidth: 8,
38
+ data: [3, 8, 7],
39
+ };
40
+ const hoverOffsetDataset = {
41
+ label: 'hover data',
42
+ data: [3, 8, 7],
43
+ hoverOffset: 40,
44
+ };
45
+
46
+ const datasetDatalabels = {
47
+ label: 'data',
48
+ data: [
49
+ {
50
+ value: 210,
51
+ label: 'label',
52
+ },
53
+ {
54
+ value: 333,
55
+ label: 'labal',
56
+ },
57
+ {
58
+ value: 248,
59
+ label: 'lebel',
60
+ },
61
+ ],
62
+ };
63
+ const datasetNoDataLabels = {
64
+ label: 'data',
65
+ data: [210, 333, 248],
66
+ };
67
+
68
+ const singleChart = {
69
+ data: {
70
+ labels: labels1,
71
+ datasets: [dataset1],
72
+ },
73
+ };
74
+
75
+ const multiplePieData = {
76
+ data: {
77
+ labels: labels1,
78
+ datasets: [dataset1, dataset2, dataset3],
79
+ },
80
+ };
81
+ const stackedMultiplePieData = {
82
+ data: {
83
+ labels: labels1,
84
+ datasets: [dataset1, dataset2, dataset3],
85
+ },
86
+ options: {
87
+ title: 'Stacked',
88
+ graph: { stacked: true },
89
+ },
90
+ };
91
+
92
+ const dataLabelsChart = {
93
+ data: {
94
+ labels: labels1,
95
+ datasets: [datasetDatalabels],
96
+ },
97
+ options: {
98
+ title: 'With custom datalabels',
99
+ graph: {
100
+ showDataLabels: true,
101
+ },
102
+ },
103
+ };
104
+ const dataLabelsNumberChart = {
105
+ data: {
106
+ labels: labels1,
107
+ datasets: [datasetNoDataLabels],
108
+ },
109
+ options: {
110
+ title: 'With value as datalabels',
111
+ graph: {
112
+ showDataLabels: true,
113
+ },
114
+ },
115
+ };
116
+
117
+ const dataLabelssTooltips = {
118
+ data: {
119
+ labels: labels1,
120
+ datasets: [datasetDatalabels],
121
+ },
122
+ options: {
123
+ title: 'With datalabels in tooltips',
124
+ tooltip: {
125
+ showLabelsInTooltips: true,
126
+ },
127
+ },
128
+ };
129
+
130
+ const lightMode = {
131
+ data: {
132
+ labels: labels1,
133
+ datasets: [dataset1, dataset2, dataset3],
134
+ },
135
+ options: {
136
+ title: 'Light mode',
137
+ axes: {
138
+ x: [
139
+ {
140
+ label: 'X',
141
+ },
142
+ ],
143
+ },
144
+ chartStyling: {
145
+ darkMode: false,
146
+ },
147
+ graph: {
148
+ showDataLabels: true,
149
+ showMinorGridlines: true,
150
+ },
151
+ annotations: {
152
+ annotationsData: [
153
+ {
154
+ label: 'Annotation 1',
155
+ value: 6,
156
+ },
157
+ ],
158
+ },
159
+ },
160
+ };
161
+ const darkMode = {
162
+ data: {
163
+ labels: labels1,
164
+ datasets: [dataset1, dataset2, dataset3],
165
+ },
166
+ options: {
167
+ title: 'Dark mode',
168
+ axes: {
169
+ x: [
170
+ {
171
+ label: 'X',
172
+ },
173
+ ],
174
+ },
175
+ chartStyling: {
176
+ darkMode: true,
177
+ },
178
+ graph: {
179
+ showDataLabels: true,
180
+ showMinorGridlines: true,
181
+ },
182
+ annotations: {
183
+ annotationsData: [
184
+ {
185
+ label: 'Annotation 1',
186
+ value: 6,
187
+ },
188
+ ],
189
+ },
190
+ },
191
+ };
192
+
193
+ const borderWidthChart = {
194
+ data: {
195
+ labels: labels1,
196
+ datasets: [borderWidthDataset],
197
+ },
198
+ options: { title: 'Custom border Width' },
199
+ };
200
+
201
+ const hoverOffsetChart = {
202
+ data: {
203
+ labels: labels1,
204
+ datasets: [hoverOffsetDataset],
205
+ },
206
+ options: { title: 'Hover offset' },
207
+ };
208
+
209
+ const spacingChart = {
210
+ data: {
211
+ labels: labels1,
212
+ datasets: [spacingDataset],
213
+ },
214
+ options: { title: 'Segment spacing' },
215
+ };
216
+
217
+ const offsetChart = {
218
+ data: {
219
+ labels: labels1,
220
+ datasets: [offsetDataset],
221
+ },
222
+ options: { title: 'Segment offset' },
223
+ };
224
+
225
+ const circumferenceChart = {
226
+ data: {
227
+ labels: labels1,
228
+ datasets: [circumferenceDataset],
229
+ },
230
+ options: { title: 'Using circumference' },
231
+ };
232
+
233
+ const datasetLegend = {
234
+ data: {
235
+ labels: labels1,
236
+ datasets: [dataset1, dataset2, dataset3],
237
+ },
238
+ options: {
239
+ title: 'Legend with dataset instead of label',
240
+ legend: {
241
+ useDataset: true,
242
+ },
243
+ },
244
+ };
245
+
246
+ const datasetLegendStacked = {
247
+ data: {
248
+ labels: labels1,
249
+ datasets: [dataset1, dataset2, dataset3],
250
+ },
251
+ options: {
252
+ title: 'Legend with stacked dataset',
253
+ legend: {
254
+ useDataset: true,
255
+ },
256
+ graph: {
257
+ stacked: true,
258
+ },
259
+ },
260
+ };
261
+
262
+ const legendRight = {
263
+ data: {
264
+ labels: labels1,
265
+ datasets: [dataset1],
266
+ },
267
+ options: {
268
+ title: 'Legend to the right',
269
+ legend: {
270
+ position: 'right',
271
+ },
272
+ },
273
+ };
274
+
275
+ const legendStart = {
276
+ data: {
277
+ labels: labels1,
278
+ datasets: [dataset1],
279
+ },
280
+ options: {
281
+ title: 'Legend aligned to start',
282
+ legend: {
283
+ align: 'start',
284
+ },
285
+ },
286
+ };
287
+
288
+ const animatedChart = {
289
+ data: {
290
+ labels: labels1,
291
+ datasets: [dataset1],
292
+ },
293
+ options: {
294
+ chartStyling: { performanceMode: false },
295
+ },
296
+ };
297
+
298
+ const animatedMultiChart = {
299
+ data: {
300
+ labels: labels1,
301
+ datasets: [dataset1, dataset2],
302
+ },
303
+ options: {
304
+ chartStyling: { performanceMode: false },
305
+ legend: {
306
+ useDataset: true,
307
+ },
308
+ },
309
+ };
310
+
311
+ const doughnutPercentage = {
312
+ data: {
313
+ labels: labels1,
314
+ datasets: [dataset1],
315
+ },
316
+ options: {
317
+ title: 'Cutout 50%',
318
+ graph: { cutout: '50%' },
319
+ },
320
+ };
321
+
322
+ const doughnutNumber = {
323
+ data: {
324
+ labels: labels1,
325
+ datasets: [dataset1],
326
+ },
327
+ options: {
328
+ title: 'Cutout 20 pixels',
329
+ graph: { cutout: 20 },
330
+ },
331
+ };
332
+
333
+ storiesOf('Charts/PieChart/Basics', module)
334
+ .add('Default', () => (
335
+ <Container style={style}>
336
+ <PieChart chart={singleChart} />
337
+ </Container>
338
+ ))
339
+ .add('Multiple Sets', () => (
340
+ <Container style={style}>
341
+ <PieChart chart={multiplePieData} />
342
+ <PieChart chart={stackedMultiplePieData} />
343
+ </Container>
344
+ ))
345
+ .add('Datalabels', () => (
346
+ <Container style={style}>
347
+ <PieChart chart={dataLabelsChart} />
348
+ <PieChart chart={dataLabelsNumberChart} />
349
+ <PieChart chart={dataLabelssTooltips} />
350
+ </Container>
351
+ ))
352
+ .add('Legend', () => (
353
+ <Container style={style}>
354
+ <PieChart chart={datasetLegend} />
355
+ <PieChart chart={datasetLegendStacked} />
356
+ <PieChart chart={legendRight} />
357
+ <PieChart chart={legendStart} />
358
+ </Container>
359
+ ))
360
+ .add('Animated', () => (
361
+ <Container style={style}>
362
+ <PieChart chart={animatedChart} />
363
+ <PieChart chart={animatedMultiChart} />
364
+ </Container>
365
+ ))
366
+ .add('Dark mode', () => (
367
+ <Container style={style}>
368
+ <Container>
369
+ <PieChart chart={lightMode} />
370
+ </Container>
371
+ <Container style={darkmodeStyle}>
372
+ <PieChart chart={darkMode} />
373
+ </Container>
374
+ </Container>
375
+ ))
376
+ .add('Doughnut', () => (
377
+ <Container style={style}>
378
+ <PieChart chart={doughnutPercentage} />
379
+ <PieChart chart={doughnutNumber} />
380
+ </Container>
381
+ ))
382
+ .add('Segment styling', () => (
383
+ <Container style={style}>
384
+ <PieChart chart={hoverOffsetChart} />
385
+ <PieChart chart={borderWidthChart} />
386
+ <PieChart chart={spacingChart} />
387
+ <PieChart chart={offsetChart} />
388
+ <PieChart chart={circumferenceChart} />
389
+ </Container>
390
+ ));
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { PieChart } from './pie-chart';
4
+ import { Container } from '../../helpers/container';
5
+
6
+ const style = {
7
+ height: '1000px',
8
+ width: '1000px',
9
+ };
10
+
11
+ const chart = {
12
+ data: {
13
+ labels: ['monday', 'tuesday', 'wednesday', 'friday'],
14
+ datasets: [
15
+ {
16
+ label: 'some data',
17
+ borderColor: ['blue', 'red', 'orange', 'green'],
18
+ backgroundColor: ['#333333', '#777777', '#bbbbbb', '#ffffff'],
19
+ borderWidth: 4,
20
+ offset: 100,
21
+ data: [2, 4, 8, 16],
22
+ },
23
+ {
24
+ label: 'some other data',
25
+ borderColor: ['#880088', '#ff8800'],
26
+ backgroundColor: ['#ff8800dd', '#880088dd'],
27
+ borderWidth: 10,
28
+ spacing: 50,
29
+ data: [42, 8, 22, 19],
30
+ },
31
+ {
32
+ label: 'some otter data',
33
+ circumference: 270,
34
+ hoverOffset: -40,
35
+
36
+ data: [10, 20, 22, 19],
37
+ },
38
+ ],
39
+ },
40
+ options: {
41
+ title: 'Take a piece of this pie!',
42
+ chartStyling: {
43
+ width: 1200,
44
+ height: 800,
45
+ performanceMode: false,
46
+ },
47
+ graph: {
48
+ showDataLabels: true,
49
+ cutout: '20%',
50
+ },
51
+ legend: {
52
+ position: 'top',
53
+ align: 'start',
54
+ },
55
+ interactions: {
56
+ onPieHover: null,
57
+ onPieUnhover: null,
58
+ },
59
+ },
60
+ };
61
+
62
+ storiesOf('Charts/PieChart', module).add('Kitchen Sink', () => (
63
+ <Container style={style}>
64
+ <PieChart chart={chart} />
65
+ </Container>
66
+ ));
@@ -0,0 +1,111 @@
1
+ import PropTypes from 'prop-types';
2
+
3
+ export const PieChartPropTypes = {
4
+ chart: PropTypes.shape({
5
+ data: PropTypes.shape({
6
+ labels: PropTypes.arrayOf(PropTypes.string),
7
+ datasets: PropTypes.arrayOf(PropTypes.object).isRequired,
8
+ }).isRequired,
9
+ options: PropTypes.shape({
10
+ title: PropTypes.oneOfType([
11
+ PropTypes.string,
12
+ PropTypes.arrayOf(PropTypes.string),
13
+ ]),
14
+ chartStyling: PropTypes.shape({
15
+ width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
16
+ height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
17
+ maintainAspectRatio: PropTypes.bool,
18
+ staticChartHeight: PropTypes.bool,
19
+ performanceMode: PropTypes.bool,
20
+ darkMode: PropTypes.bool,
21
+ }),
22
+ tooltip: PropTypes.shape({
23
+ tooltips: PropTypes.bool,
24
+ showLabelsInTooltips: PropTypes.bool,
25
+ }),
26
+ graph: PropTypes.shape({
27
+ showDataLabels: PropTypes.bool,
28
+ stacked: PropTypes.bool,
29
+ cutout: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
30
+ }),
31
+ legend: PropTypes.shape({
32
+ display: PropTypes.bool,
33
+ position: PropTypes.oneOf(['top', 'bottom', 'right']),
34
+ align: PropTypes.oneOf(['start', 'center', 'end']),
35
+ useDataset: PropTypes.bool,
36
+ }),
37
+ chartOptions: PropTypes.shape({
38
+ enableZoom: PropTypes.bool,
39
+ enablePan: PropTypes.bool,
40
+ }),
41
+ interactions: PropTypes.shape({
42
+ onLegendClick: PropTypes.func,
43
+ onPieHover: PropTypes.func,
44
+ onPieUnhover: PropTypes.func,
45
+ }),
46
+ }),
47
+ }).isRequired,
48
+ };
49
+
50
+ export const getDefaultProps = (props) => {
51
+ // Add missing nested objects
52
+ props.chart.options = props.chart.options || {};
53
+ props.chart.options.chartStyling = props.chart.options.chartStyling || {};
54
+ props.chart.options.tooltip = props.chart.options.tooltip || {};
55
+ props.chart.options.graph = props.chart.options.graph || {};
56
+ props.chart.options.legend = props.chart.options.legend || {};
57
+ props.chart.options.chartOptions = props.chart.options.chartOptions || {};
58
+ props.chart.options.interactions = props.chart.options.interactions || {};
59
+ // Set defaults for missing properties
60
+ const chart = {
61
+ data: props.chart.data,
62
+ options: {
63
+ title: props.chart.options.title || '',
64
+ chartStyling: {
65
+ width: props.chart.options.chartStyling.width,
66
+ height: props.chart.options.chartStyling.height,
67
+ maintainAspectRatio:
68
+ props.chart.options.chartStyling.maintainAspectRatio || false,
69
+ staticChartHeight:
70
+ props.chart.options.chartStyling.staticChartHeight || false,
71
+ performanceMode:
72
+ props.chart.options.chartStyling.performanceMode != null
73
+ ? props.chart.options.chartStyling.performanceMode
74
+ : true,
75
+ darkMode: props.chart.options.chartStyling.darkMode || false,
76
+ },
77
+ tooltip: {
78
+ tooltips:
79
+ props.chart.options.tooltip.tooltips != null
80
+ ? props.chart.options.tooltip.tooltips
81
+ : true,
82
+ showLabelsInTooltips:
83
+ props.chart.options.tooltip.showLabelsInTooltips || false,
84
+ },
85
+ graph: {
86
+ showDataLabels: props.chart.options.graph.showDataLabels || false,
87
+ stacked: props.chart.options.graph.stacked || false,
88
+ cutout: props.chart.options.graph.cutout || 0,
89
+ },
90
+ legend: {
91
+ display:
92
+ props.chart.options.legend.display != null
93
+ ? props.chart.options.legend.display
94
+ : true,
95
+ useDataset: props.chart.options.legend.useDataset || false,
96
+ position: props.chart.options.legend.position || 'bottom',
97
+ align: props.chart.options.legend.align || 'center',
98
+ },
99
+ chartOptions: {
100
+ enableZoom: props.chart.options.chartOptions.enableZoom || false,
101
+ enablePan: props.chart.options.chartOptions.enablePan || false,
102
+ },
103
+ interactions: {
104
+ onLegendClick: props.chart.options.interactions.onLegendClick,
105
+ onPieHover: props.chart.options.interactions.onPieHover,
106
+ onPieUnhover: props.chart.options.interactions.onPieUnhover,
107
+ },
108
+ },
109
+ };
110
+ return chart;
111
+ };
@@ -0,0 +1,55 @@
1
+ export const colors = [
2
+ '#3366cc',
3
+ '#dc3912',
4
+ '#ff9900',
5
+ '#109618',
6
+ '#990099',
7
+ '#0099c6',
8
+ '#dd4477',
9
+ '#66aa00',
10
+ '#b82e2e',
11
+ '#316395',
12
+ '#994499',
13
+ '#22aa99',
14
+ '#aaaa11',
15
+ '#6633cc',
16
+ '#e67300',
17
+ '#8b0707',
18
+ '#651067',
19
+ '#329262',
20
+ '#5574a6',
21
+ '#3b3eac',
22
+ ];
23
+
24
+ export const colorsDarkmode = [
25
+ '#578fff',
26
+ '#ff5026',
27
+ '#ff9900',
28
+ '#24ff31',
29
+ '#ff00ff',
30
+ '#00c5ff',
31
+ '#f7407d',
32
+ '#99ff00',
33
+ '#ff4040',
34
+ '#51a7fc',
35
+ '#f26bf2',
36
+ '#36f8ff',
37
+ '#ffff19',
38
+ '#9c6bff',
39
+ '#ff8b17',
40
+ '#ff1212',
41
+ '#fa29ff',
42
+ '#54ffaa',
43
+ '#80b0ff',
44
+ '#595eff',
45
+ ];
46
+
47
+ export const generateRandomColor = () => {
48
+ const color = `#${Math.floor(Math.random() * 16777215).toString(16)}`;
49
+ if (colors.includes(color)) {
50
+ return generateRandomColor();
51
+ } else {
52
+ colors.push(color);
53
+ return color;
54
+ }
55
+ };
@@ -0,0 +1,61 @@
1
+ export interface IChartInteractions {
2
+ onLegendClick: () => any;
3
+ onPointHover: () => any;
4
+ onPointUnhover: () => any;
5
+ }
6
+
7
+ export interface IChartOptions {
8
+ enableZoom: boolean;
9
+ enablePan: boolean;
10
+ }
11
+
12
+ export interface IChartLegend {
13
+ display: boolean;
14
+ position: 'top' | 'bottom' | 'right';
15
+ align: 'start' | 'center' | 'end';
16
+ useDataset: boolean;
17
+ }
18
+
19
+ export interface IChartGraph {
20
+ showDataLabels: boolean;
21
+ stacked: boolean;
22
+ cutout: number | string;
23
+ }
24
+
25
+ export interface IChartTooltip {
26
+ tooltips: boolean;
27
+ showLabelsInTooltips: boolean;
28
+ }
29
+
30
+ export interface IChartStyling {
31
+ width: number | string;
32
+ height: number | string;
33
+ maintainAspectRatio: boolean;
34
+ staticChartHeight: boolean;
35
+ performanceMode: boolean;
36
+ darkMode: boolean;
37
+ }
38
+
39
+ export interface IOptions {
40
+ title: string | string[];
41
+ chartStyling: IChartStyling;
42
+ tooltip: IChartTooltip;
43
+ graph: IChartGraph;
44
+ legend: IChartLegend;
45
+ chartOptions: IChartOptions;
46
+ interactions: IChartInteractions;
47
+ }
48
+
49
+ export interface IChartData {
50
+ labels: string;
51
+ datasets: any[];
52
+ }
53
+
54
+ export interface IChartData {
55
+ data: IChartData;
56
+ options: IOptions;
57
+ }
58
+
59
+ export interface IPieChartProps {
60
+ chart: IChartData;
61
+ }