@oliasoft-open-source/charts-library 2.1.0 → 2.1.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.
Files changed (29) hide show
  1. package/.storybook/main.js +18 -22
  2. package/.storybook/preview.js +37 -0
  3. package/.storybook/storybook.less +8 -0
  4. package/package.json +2 -1
  5. package/src/components/bar-chart/bar-chart-prop-types.js +7 -0
  6. package/src/components/bar-chart/bar-chart.jsx +7 -2
  7. package/src/components/bar-chart/{basic.stories.jsx → bar-chart.stories.jsx} +108 -371
  8. package/src/components/line-chart/Controls/Controls.jsx +2 -0
  9. package/src/components/line-chart/Controls/Layer.jsx +52 -49
  10. package/src/components/line-chart/line-chart-prop-types.js +10 -0
  11. package/src/components/line-chart/line-chart.jsx +91 -10
  12. package/src/components/line-chart/line-chart.module.less +6 -0
  13. package/src/components/line-chart/line-chart.stories.jsx +393 -0
  14. package/src/components/line-chart/state/line-chart-reducer.js +26 -15
  15. package/src/components/pie-chart/pie-chart.stories.jsx +234 -0
  16. package/src/components/scatter-chart/{scatter.stories.jsx → scatter-chart.stories.jsx} +25 -79
  17. package/src/helpers/chart-consts.js +2 -0
  18. package/src/helpers/chart-interface.ts +9 -0
  19. package/src/helpers/chart-utils.js +24 -4
  20. package/src/helpers/get-custom-legend-plugin-example.js +81 -0
  21. package/src/components/bar-chart/charts.stories.jsx +0 -119
  22. package/src/components/line-chart/basic.stories.jsx +0 -735
  23. package/src/components/line-chart/charts.stories.jsx +0 -264
  24. package/src/components/line-chart/stories/shapes/cubes.stories.jsx +0 -326
  25. package/src/components/line-chart/stories/shapes/pyramid.stories.jsx +0 -189
  26. package/src/components/line-chart/stories/shapes/round.stories.jsx +0 -339
  27. package/src/components/line-chart/stories/shapes/triangle.stories.jsx +0 -166
  28. package/src/components/pie-chart/basic.stories.jsx +0 -390
  29. package/src/components/pie-chart/charts.stories.jsx +0 -66
@@ -1,390 +0,0 @@
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
- ));
@@ -1,66 +0,0 @@
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
- ));