@react-magma/charts 6.0.1-next.0 → 7.0.0-next.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 (42) hide show
  1. package/dist/charts.css +6 -0
  2. package/dist/charts.css.map +1 -0
  3. package/dist/charts.js +1 -1
  4. package/dist/charts.js.map +1 -1
  5. package/dist/charts.modern.js +303 -12
  6. package/dist/charts.modern.js.map +1 -1
  7. package/dist/charts.modern.module.js +1 -1
  8. package/dist/charts.modern.module.js.map +1 -1
  9. package/dist/charts.umd.js +1 -1
  10. package/dist/charts.umd.js.map +1 -1
  11. package/dist/components/CarbonChart/CarbonChart.d.ts +32 -0
  12. package/dist/components/CarbonChart/CarbonChart.test.d.ts +1 -0
  13. package/dist/components/CarbonChart/CarbonChartArea.stories.d.ts +8 -0
  14. package/dist/components/CarbonChart/CarbonChartAreaStacked.stories.d.ts +6 -0
  15. package/dist/components/CarbonChart/CarbonChartBar.stories.d.ts +12 -0
  16. package/dist/components/CarbonChart/CarbonChartBarFloating.stories.d.ts +6 -0
  17. package/dist/components/CarbonChart/CarbonChartBarGrouped.stories.d.ts +12 -0
  18. package/dist/components/CarbonChart/CarbonChartBarStacked.stories.d.ts +13 -0
  19. package/dist/components/CarbonChart/CarbonChartDonut.stories.d.ts +8 -0
  20. package/dist/components/CarbonChart/CarbonChartLine.stories.d.ts +9 -0
  21. package/dist/components/CarbonChart/CarbonChartLollipop.stories.d.ts +5 -0
  22. package/dist/components/CarbonChart/CarbonChartPie.stories.d.ts +8 -0
  23. package/dist/components/CarbonChart/index.d.ts +1 -0
  24. package/dist/index.d.ts +1 -0
  25. package/package.json +9 -3
  26. package/src/components/CarbonChart/CarbonChart.test.js +74 -0
  27. package/src/components/CarbonChart/CarbonChart.tsx +524 -0
  28. package/src/components/CarbonChart/CarbonChartArea.stories.tsx +357 -0
  29. package/src/components/CarbonChart/CarbonChartAreaStacked.stories.tsx +313 -0
  30. package/src/components/CarbonChart/CarbonChartBar.stories.tsx +388 -0
  31. package/src/components/CarbonChart/CarbonChartBarFloating.stories.tsx +156 -0
  32. package/src/components/CarbonChart/CarbonChartBarGrouped.stories.tsx +798 -0
  33. package/src/components/CarbonChart/CarbonChartBarStacked.stories.tsx +833 -0
  34. package/src/components/CarbonChart/CarbonChartDonut.stories.tsx +204 -0
  35. package/src/components/CarbonChart/CarbonChartLine.stories.tsx +674 -0
  36. package/src/components/CarbonChart/CarbonChartLollipop.stories.tsx +113 -0
  37. package/src/components/CarbonChart/CarbonChartPie.stories.tsx +187 -0
  38. package/src/components/CarbonChart/index.ts +1 -0
  39. package/src/components/LineChart/Chart.tsx +15 -14
  40. package/src/components/LineChart/GraphTooltip.tsx +6 -3
  41. package/src/components/LineChart/LineChart.tsx +7 -5
  42. package/src/index.ts +1 -0
@@ -0,0 +1,674 @@
1
+ import React from 'react';
2
+ import { Story, Meta } from '@storybook/react/types-6-0';
3
+ import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
4
+ import { Card } from 'react-magma-dom';
5
+
6
+ export default {
7
+ component: CarbonChart,
8
+ title: 'CarbonChart/Line',
9
+ argTypes: {
10
+ isInverse: {
11
+ control: {
12
+ type: 'boolean',
13
+ },
14
+ },
15
+ type: {
16
+ control: {
17
+ type: 'select',
18
+ options: CarbonChartType,
19
+ },
20
+ },
21
+ },
22
+ } as Meta;
23
+
24
+ const Template: Story<CarbonChartProps> = args => (
25
+ <Card isInverse={args.isInverse} style={{ padding: '12px' }}>
26
+ <CarbonChart {...args} />
27
+ </Card>
28
+ );
29
+
30
+ export const LineDiscrete = Template.bind({});
31
+ LineDiscrete.args = {
32
+ isInverse: false,
33
+ type: CarbonChartType.line,
34
+ dataSet: [
35
+ {
36
+ group: 'Dataset 1',
37
+ key: 'Qty',
38
+ value: 34200,
39
+ },
40
+ {
41
+ group: 'Dataset 1',
42
+ key: 'More',
43
+ value: 23500,
44
+ },
45
+ {
46
+ group: 'Dataset 1',
47
+ key: 'Sold',
48
+ value: 53100,
49
+ },
50
+ {
51
+ group: 'Dataset 1',
52
+ key: 'Restocking',
53
+ value: 42300,
54
+ },
55
+ {
56
+ group: 'Dataset 1',
57
+ key: 'Misc',
58
+ value: 12300,
59
+ },
60
+ {
61
+ group: 'Dataset 2',
62
+ key: 'Qty',
63
+ value: 34200,
64
+ },
65
+ {
66
+ group: 'Dataset 2',
67
+ key: 'More',
68
+ value: 53200,
69
+ },
70
+ {
71
+ group: 'Dataset 2',
72
+ key: 'Sold',
73
+ value: 42300,
74
+ },
75
+ {
76
+ group: 'Dataset 2',
77
+ key: 'Restocking',
78
+ value: 21400,
79
+ },
80
+ {
81
+ group: 'Dataset 2',
82
+ key: 'Misc',
83
+ value: 0,
84
+ },
85
+ {
86
+ group: 'Dataset 3',
87
+ key: 'Qty',
88
+ value: 41200,
89
+ },
90
+ {
91
+ group: 'Dataset 3',
92
+ key: 'More',
93
+ value: 18400,
94
+ },
95
+ {
96
+ group: 'Dataset 3',
97
+ key: 'Sold',
98
+ value: 34210,
99
+ },
100
+ {
101
+ group: 'Dataset 3',
102
+ key: 'Restocking',
103
+ value: 1400,
104
+ },
105
+ {
106
+ group: 'Dataset 3',
107
+ key: 'Misc',
108
+ value: 42100,
109
+ },
110
+ {
111
+ group: 'Dataset 4',
112
+ key: 'Qty',
113
+ value: 22000,
114
+ },
115
+ {
116
+ group: 'Dataset 4',
117
+ key: 'More',
118
+ value: 1200,
119
+ },
120
+ {
121
+ group: 'Dataset 4',
122
+ key: 'Sold',
123
+ value: 9000,
124
+ },
125
+ {
126
+ group: 'Dataset 4',
127
+ key: 'Restocking',
128
+ value: 24000,
129
+ audienceSize: 10,
130
+ },
131
+ {
132
+ group: 'Dataset 4',
133
+ key: 'Misc',
134
+ value: 3000,
135
+ audienceSize: 10,
136
+ },
137
+ ],
138
+ options: {
139
+ title: 'Line (discrete)',
140
+ axes: {
141
+ bottom: {
142
+ title: '2019 Annual Sales Figures',
143
+ mapsTo: 'key',
144
+ scaleType: 'labels',
145
+ },
146
+ left: {
147
+ mapsTo: 'value',
148
+ title: 'Conversion rate',
149
+ scaleType: 'linear',
150
+ },
151
+ },
152
+ height: '400px',
153
+ },
154
+ };
155
+
156
+ export const LineTimeSeries = Template.bind({});
157
+ LineTimeSeries.args = {
158
+ isInverse: false,
159
+ type: CarbonChartType.line,
160
+ dataSet: [
161
+ {
162
+ group: 'Dataset 1',
163
+ date: '2019-01-01T05:00:00.000Z',
164
+ value: 50000,
165
+ surplus: 523012392.5263605,
166
+ },
167
+ {
168
+ group: 'Dataset 1',
169
+ date: '2019-01-05T05:00:00.000Z',
170
+ value: 65000,
171
+ surplus: 772740170.8482182,
172
+ },
173
+ {
174
+ group: 'Dataset 1',
175
+ date: '2019-01-08T05:00:00.000Z',
176
+ value: null,
177
+ surplus: 13322.578682563697,
178
+ },
179
+ {
180
+ group: 'Dataset 1',
181
+ date: '2019-01-13T05:00:00.000Z',
182
+ value: 49213,
183
+ surplus: 1000448679.2227045,
184
+ },
185
+ {
186
+ group: 'Dataset 1',
187
+ date: '2019-01-17T05:00:00.000Z',
188
+ value: 51213,
189
+ surplus: 1234900823.3172598,
190
+ },
191
+ {
192
+ group: 'Dataset 2',
193
+ date: '2019-01-02T05:00:00.000Z',
194
+ value: 0,
195
+ surplus: 7620.93487174954,
196
+ },
197
+ {
198
+ group: 'Dataset 2',
199
+ date: '2019-01-06T05:00:00.000Z',
200
+ value: 57312,
201
+ surplus: 1308387951.9203572,
202
+ },
203
+ {
204
+ group: 'Dataset 2',
205
+ date: '2019-01-08T05:00:00.000Z',
206
+ value: 27432,
207
+ surplus: 553140870.9513942,
208
+ },
209
+ {
210
+ group: 'Dataset 2',
211
+ date: '2019-01-15T05:00:00.000Z',
212
+ value: 70323,
213
+ surplus: 1448993520.232652,
214
+ },
215
+ {
216
+ group: 'Dataset 2',
217
+ date: '2019-01-19T05:00:00.000Z',
218
+ value: 21300,
219
+ surplus: 468792972.92781883,
220
+ },
221
+ {
222
+ group: 'Dataset 3',
223
+ date: '2019-01-01T05:00:00.000Z',
224
+ value: 40000,
225
+ surplus: 309637962.3262422,
226
+ },
227
+ {
228
+ group: 'Dataset 3',
229
+ date: '2019-01-05T05:00:00.000Z',
230
+ value: null,
231
+ surplus: 2051.471861823623,
232
+ },
233
+ {
234
+ group: 'Dataset 3',
235
+ date: '2019-01-08T05:00:00.000Z',
236
+ value: 18000,
237
+ surplus: 343093081.6745837,
238
+ },
239
+ {
240
+ group: 'Dataset 3',
241
+ date: '2019-01-13T05:00:00.000Z',
242
+ value: 39213,
243
+ surplus: 716440523.7786787,
244
+ },
245
+ {
246
+ group: 'Dataset 3',
247
+ date: '2019-01-17T05:00:00.000Z',
248
+ value: 61213,
249
+ surplus: 584039753.4962941,
250
+ },
251
+ {
252
+ group: 'Dataset 4',
253
+ date: '2019-01-02T05:00:00.000Z',
254
+ value: 20000,
255
+ surplus: 186495096.85354337,
256
+ },
257
+ {
258
+ group: 'Dataset 4',
259
+ date: '2019-01-06T05:00:00.000Z',
260
+ value: 37312,
261
+ surplus: 202885089.37063065,
262
+ },
263
+ {
264
+ group: 'Dataset 4',
265
+ date: '2019-01-08T05:00:00.000Z',
266
+ value: 51432,
267
+ surplus: 763947723.2503313,
268
+ },
269
+ {
270
+ group: 'Dataset 4',
271
+ date: '2019-01-15T05:00:00.000Z',
272
+ value: 25332,
273
+ surplus: 560375921.1862621,
274
+ },
275
+ {
276
+ group: 'Dataset 4',
277
+ date: '2019-01-19T05:00:00.000Z',
278
+ value: null,
279
+ surplus: 24577.821805054795,
280
+ },
281
+ ],
282
+ options: {
283
+ title: 'Line (time series)',
284
+ axes: {
285
+ bottom: {
286
+ title: '2019 Annual Sales Figures',
287
+ mapsTo: 'date',
288
+ scaleType: 'time',
289
+ },
290
+ left: {
291
+ mapsTo: 'value',
292
+ title: 'Conversion rate',
293
+ scaleType: 'linear',
294
+ },
295
+ },
296
+ curve: 'curveMonotoneX',
297
+ height: '400px',
298
+ },
299
+ };
300
+
301
+ export const LineDenseTimeSeries = Template.bind({});
302
+ LineDenseTimeSeries.args = {
303
+ isInverse: false,
304
+ type: CarbonChartType.line,
305
+ dataSet: [
306
+ {
307
+ group: 'Dataset 1',
308
+ date: '2019-01-01T05:00:00.000Z',
309
+ value: -10000,
310
+ },
311
+ {
312
+ group: 'Dataset 1',
313
+ date: '2019-01-01T10:00:00.000Z',
314
+ value: -12000,
315
+ },
316
+ {
317
+ group: 'Dataset 1',
318
+ date: '2019-01-01T15:00:00.000Z',
319
+ value: -14000,
320
+ },
321
+ {
322
+ group: 'Dataset 1',
323
+ date: '2019-01-02T05:00:00.000Z',
324
+ value: -25000,
325
+ },
326
+ {
327
+ group: 'Dataset 1',
328
+ date: '2019-01-02T07:00:00.000Z',
329
+ value: -26000,
330
+ },
331
+ {
332
+ group: 'Dataset 1',
333
+ date: '2019-01-03T05:00:00.000Z',
334
+ value: -10000,
335
+ },
336
+ {
337
+ group: 'Dataset 1',
338
+ date: '2019-01-03T10:00:00.000Z',
339
+ value: 10000,
340
+ },
341
+ {
342
+ group: 'Dataset 1',
343
+ date: '2019-01-03T15:00:00.000Z',
344
+ value: 12000,
345
+ },
346
+ {
347
+ group: 'Dataset 1',
348
+ date: '2019-01-05T05:00:00.000Z',
349
+ value: 45000,
350
+ },
351
+ {
352
+ group: 'Dataset 1',
353
+ date: '2019-01-07T05:00:00.000Z',
354
+ value: 49000,
355
+ },
356
+ {
357
+ group: 'Dataset 1',
358
+ date: '2019-01-07T20:00:00.000Z',
359
+ value: 45000,
360
+ },
361
+ {
362
+ group: 'Dataset 1',
363
+ date: '2019-01-09T05:00:00.000Z',
364
+ value: 50000,
365
+ },
366
+ {
367
+ group: 'Dataset 1',
368
+ date: '2019-01-09T10:00:00.000Z',
369
+ value: 52000,
370
+ },
371
+ {
372
+ group: 'Dataset 1',
373
+ date: '2019-01-09T20:00:00.000Z',
374
+ value: 55000,
375
+ },
376
+ {
377
+ group: 'Dataset 1',
378
+ date: '2019-01-10T05:00:00.000Z',
379
+ value: 50000,
380
+ },
381
+ {
382
+ group: 'Dataset 1',
383
+ date: '2019-01-12T05:00:00.000Z',
384
+ value: 65000,
385
+ },
386
+ {
387
+ group: 'Dataset 1',
388
+ date: '2019-01-13T05:00:00.000Z',
389
+ value: 80000,
390
+ },
391
+ {
392
+ group: 'Dataset 1',
393
+ date: '2019-01-14T15:00:00.000Z',
394
+ value: 85000,
395
+ },
396
+ {
397
+ group: 'Dataset 1',
398
+ date: '2019-01-15T12:00:00.000Z',
399
+ value: 90000,
400
+ },
401
+ {
402
+ group: 'Dataset 1',
403
+ date: '2019-01-15T23:00:00.000Z',
404
+ value: 70000,
405
+ },
406
+ {
407
+ group: 'Dataset 2',
408
+ date: '2019-01-01T05:00:00.000Z',
409
+ value: 20000,
410
+ },
411
+ {
412
+ group: 'Dataset 2',
413
+ date: '2019-01-01T08:00:00.000Z',
414
+ value: 22000,
415
+ },
416
+ {
417
+ group: 'Dataset 2',
418
+ date: '2019-01-01T21:00:00.000Z',
419
+ value: 24000,
420
+ },
421
+ {
422
+ group: 'Dataset 2',
423
+ date: '2019-01-02T05:00:00.000Z',
424
+ value: 35000,
425
+ },
426
+ {
427
+ group: 'Dataset 2',
428
+ date: '2019-01-02T12:00:00.000Z',
429
+ value: 36000,
430
+ },
431
+ {
432
+ group: 'Dataset 2',
433
+ date: '2019-01-03T05:00:00.000Z',
434
+ value: 20000,
435
+ },
436
+ {
437
+ group: 'Dataset 2',
438
+ date: '2019-01-03T11:00:00.000Z',
439
+ value: 20000,
440
+ },
441
+ {
442
+ group: 'Dataset 2',
443
+ date: '2019-01-03T23:00:00.000Z',
444
+ value: 22000,
445
+ },
446
+ {
447
+ group: 'Dataset 2',
448
+ date: '2019-01-05T05:00:00.000Z',
449
+ value: 62000,
450
+ },
451
+ {
452
+ group: 'Dataset 2',
453
+ date: '2019-01-06T05:00:00.000Z',
454
+ value: 52000,
455
+ },
456
+ {
457
+ group: 'Dataset 2',
458
+ date: '2019-01-07T05:00:00.000Z',
459
+ value: 52000,
460
+ },
461
+ {
462
+ group: 'Dataset 2',
463
+ date: '2019-01-07T20:00:00.000Z',
464
+ value: 52000,
465
+ },
466
+ {
467
+ group: 'Dataset 2',
468
+ date: '2019-01-09T05:00:00.000Z',
469
+ value: 60000,
470
+ },
471
+ {
472
+ group: 'Dataset 2',
473
+ date: '2019-01-09T10:00:00.000Z',
474
+ value: 62000,
475
+ },
476
+ {
477
+ group: 'Dataset 2',
478
+ date: '2019-01-09T15:00:00.000Z',
479
+ value: 62000,
480
+ },
481
+ {
482
+ group: 'Dataset 2',
483
+ date: '2019-01-12T05:00:00.000Z',
484
+ value: 65000,
485
+ },
486
+ {
487
+ group: 'Dataset 2',
488
+ date: '2019-01-14T05:00:00.000Z',
489
+ value: 40000,
490
+ },
491
+ {
492
+ group: 'Dataset 2',
493
+ date: '2019-01-15T10:00:00.000Z',
494
+ value: 45000,
495
+ },
496
+ {
497
+ group: 'Dataset 2',
498
+ date: '2019-01-15T15:00:00.000Z',
499
+ value: 35000,
500
+ },
501
+ {
502
+ group: 'Dataset 2',
503
+ date: '2019-01-15T23:00:00.000Z',
504
+ value: 30000,
505
+ },
506
+ ],
507
+ options: {
508
+ title: 'Line (dense time series)',
509
+ axes: {
510
+ bottom: {
511
+ title: '2019 Annual Sales Figures',
512
+ mapsTo: 'date',
513
+ scaleType: 'time',
514
+ },
515
+ left: {
516
+ mapsTo: 'value',
517
+ title: 'Conversion rate',
518
+ scaleType: 'linear',
519
+ },
520
+ },
521
+ curve: 'curveMonotoneX',
522
+ height: '400px',
523
+ },
524
+ };
525
+
526
+ export const LineLineDualDualAxes = Template.bind({});
527
+ LineLineDualDualAxes.args = {
528
+ isInverse: false,
529
+ type: CarbonChartType.line,
530
+ dataSet: [
531
+ {
532
+ group: 'Temperature',
533
+ date: '2019-01-01T05:00:00.000Z',
534
+ temp: 23,
535
+ },
536
+ {
537
+ group: 'Temperature',
538
+ date: '2019-02-01T05:00:00.000Z',
539
+ temp: 15,
540
+ },
541
+ {
542
+ group: 'Temperature',
543
+ date: '2019-03-01T05:00:00.000Z',
544
+ temp: 24,
545
+ },
546
+ {
547
+ group: 'Temperature',
548
+ date: '2019-04-01T04:00:00.000Z',
549
+ temp: 33,
550
+ },
551
+ {
552
+ group: 'Temperature',
553
+ date: '2019-05-01T04:00:00.000Z',
554
+ temp: 23,
555
+ },
556
+ {
557
+ group: 'Temperature',
558
+ date: '2019-06-01T04:00:00.000Z',
559
+ temp: 32,
560
+ },
561
+ {
562
+ group: 'Temperature',
563
+ date: '2019-07-01T04:00:00.000Z',
564
+ temp: 23,
565
+ },
566
+ {
567
+ group: 'Rainfall',
568
+ date: '2019-01-01T05:00:00.000Z',
569
+ rainfall: 50,
570
+ },
571
+ {
572
+ group: 'Rainfall',
573
+ date: '2019-02-01T05:00:00.000Z',
574
+ rainfall: 65,
575
+ },
576
+ {
577
+ group: 'Rainfall',
578
+ date: '2019-03-01T05:00:00.000Z',
579
+ rainfall: 35,
580
+ },
581
+ {
582
+ group: 'Rainfall',
583
+ date: '2019-04-01T04:00:00.000Z',
584
+ rainfall: 43,
585
+ },
586
+ {
587
+ group: 'Rainfall',
588
+ date: '2019-05-01T04:00:00.000Z',
589
+ rainfall: 53,
590
+ },
591
+ {
592
+ group: 'Rainfall',
593
+ date: '2019-06-01T04:00:00.000Z',
594
+ rainfall: 19,
595
+ },
596
+ {
597
+ group: 'Rainfall',
598
+ date: '2019-07-01T04:00:00.000Z',
599
+ rainfall: 13,
600
+ },
601
+ ],
602
+ options: {
603
+ title: 'Line + Line (dual axes)',
604
+ axes: {
605
+ left: {
606
+ title: 'Temperature (°C)',
607
+ mapsTo: 'temp',
608
+ },
609
+ bottom: {
610
+ scaleType: 'time',
611
+ mapsTo: 'date',
612
+ title: 'Date',
613
+ },
614
+ right: {
615
+ title: 'Rainfall (mm)',
616
+ mapsTo: 'rainfall',
617
+ correspondingDatasets: ['Rainfall'],
618
+ },
619
+ },
620
+ curve: 'curveMonotoneX',
621
+ height: '400px',
622
+ },
623
+ };
624
+
625
+ export const LineEmptyState = Template.bind({});
626
+ LineEmptyState.args = {
627
+ isInverse: false,
628
+ type: CarbonChartType.line,
629
+ dataSet: [],
630
+ options: {
631
+ title: 'Line (empty state)',
632
+ axes: {
633
+ bottom: {
634
+ title: '2019 Annual Sales Figures',
635
+ mapsTo: 'date',
636
+ scaleType: 'time',
637
+ },
638
+ left: {
639
+ mapsTo: 'value',
640
+ title: 'Conversion rate',
641
+ scaleType: 'linear',
642
+ },
643
+ },
644
+ curve: 'curveMonotoneX',
645
+ height: '400px',
646
+ },
647
+ };
648
+
649
+ export const LineSkeleton = Template.bind({});
650
+ LineSkeleton.args = {
651
+ isInverse: false,
652
+ type: CarbonChartType.line,
653
+ dataSet: [],
654
+ options: {
655
+ title: 'Line (skeleton)',
656
+ axes: {
657
+ bottom: {
658
+ title: '2019 Annual Sales Figures',
659
+ mapsTo: 'date',
660
+ scaleType: 'time',
661
+ },
662
+ left: {
663
+ mapsTo: 'value',
664
+ title: 'Conversion rate',
665
+ scaleType: 'linear',
666
+ },
667
+ },
668
+ curve: 'curveMonotoneX',
669
+ data: {
670
+ loading: true,
671
+ },
672
+ height: '400px',
673
+ },
674
+ };