@react-magma/charts 7.0.0-next.1 → 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 +7 -1
  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,388 @@
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/Bar Simple',
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 VerticalSimpleBarDiscrete = Template.bind({});
31
+ VerticalSimpleBarDiscrete.args = {
32
+ isInverse: false,
33
+ type: CarbonChartType.bar,
34
+ dataSet: [
35
+ {
36
+ group: 'Qty',
37
+ value: 65000,
38
+ },
39
+ {
40
+ group: 'More',
41
+ value: 29123,
42
+ },
43
+ {
44
+ group: 'Sold',
45
+ value: 35213,
46
+ },
47
+ {
48
+ group: 'Restocking',
49
+ value: 51213,
50
+ },
51
+ {
52
+ group: 'Misc',
53
+ value: 16932,
54
+ },
55
+ ],
56
+ options: {
57
+ title: 'Vertical simple bar (discrete)',
58
+ axes: {
59
+ left: {
60
+ mapsTo: 'value',
61
+ },
62
+ bottom: {
63
+ mapsTo: 'group',
64
+ scaleType: 'labels',
65
+ },
66
+ },
67
+ height: '400px',
68
+ },
69
+ };
70
+
71
+ export const VerticalSimpleBarTimeSeries = Template.bind({});
72
+ VerticalSimpleBarTimeSeries.args = {
73
+ isInverse: false,
74
+ type: CarbonChartType.bar,
75
+ dataSet: [
76
+ {
77
+ group: 'Qty',
78
+ date: new Date(2019, 0, 1),
79
+ value: 10000,
80
+ },
81
+ {
82
+ group: 'More',
83
+ date: new Date(2019, 0, 2),
84
+ value: 65000,
85
+ },
86
+ {
87
+ group: 'Sold',
88
+ date: new Date(2019, 0, 3),
89
+ value: 30000,
90
+ },
91
+ {
92
+ group: 'Restocking',
93
+ date: new Date(2019, 0, 6),
94
+ value: 49213,
95
+ },
96
+ {
97
+ group: 'Misc',
98
+ date: new Date(2019, 0, 7),
99
+ value: 51213,
100
+ },
101
+ ],
102
+ options: {
103
+ title: 'Vertical simple bar (time series)',
104
+ axes: {
105
+ left: {
106
+ mapsTo: 'value',
107
+ },
108
+ bottom: {
109
+ mapsTo: 'date',
110
+ scaleType: 'time',
111
+ },
112
+ },
113
+ height: '400px',
114
+ },
115
+ };
116
+
117
+ export const VerticalSimpleBarTimeSeriesDenseDataTurkish = Template.bind({});
118
+ VerticalSimpleBarTimeSeriesDenseDataTurkish.args = {
119
+ isInverse: false,
120
+ type: CarbonChartType.bar,
121
+ dataSet: [
122
+ {
123
+ group: 'data',
124
+ date: new Date(2019, 1, 1),
125
+ value: 10000,
126
+ },
127
+ {
128
+ group: 'data',
129
+ date: new Date(2019, 1, 1),
130
+ value: 20001,
131
+ },
132
+ {
133
+ group: 'data',
134
+ date: new Date(2019, 1, 1),
135
+ value: 10002,
136
+ },
137
+ {
138
+ group: 'data',
139
+ date: new Date(2019, 1, 1),
140
+ value: 10062,
141
+ },
142
+ {
143
+ group: 'data',
144
+ date: new Date(2019, 1, 1),
145
+ value: 30003,
146
+ },
147
+ {
148
+ group: 'data',
149
+ date: new Date(2019, 1, 1),
150
+ value: 20004,
151
+ },
152
+ {
153
+ group: 'data',
154
+ date: new Date(2019, 1, 1),
155
+ value: 10005,
156
+ },
157
+ {
158
+ group: 'data',
159
+ date: new Date(2019, 1, 1),
160
+ value: 50006,
161
+ },
162
+ {
163
+ group: 'data',
164
+ date: new Date(2019, 1, 1),
165
+ value: 20006,
166
+ },
167
+ {
168
+ group: 'data',
169
+ date: new Date(2019, 1, 1),
170
+ value: 40007,
171
+ },
172
+ {
173
+ group: 'data',
174
+ date: new Date(2019, 1, 1),
175
+ value: 30008,
176
+ },
177
+ {
178
+ group: 'data',
179
+ date: new Date(2019, 1, 1),
180
+ value: 10000,
181
+ },
182
+ {
183
+ group: 'data',
184
+ date: new Date(2019, 1, 1),
185
+ value: 10000,
186
+ },
187
+ {
188
+ group: 'data',
189
+ date: new Date(2019, 1, 1),
190
+ value: 20000,
191
+ },
192
+ {
193
+ group: 'data',
194
+ date: new Date(2019, 1, 1),
195
+ value: 10000,
196
+ },
197
+ {
198
+ group: 'data',
199
+ date: new Date(2019, 1, 1),
200
+ value: 30000,
201
+ },
202
+ {
203
+ group: 'data',
204
+ date: new Date(2019, 1, 1),
205
+ value: 10000,
206
+ },
207
+ ],
208
+ options: {
209
+ title: 'Vertical simple bar (time series - dense data, Turkish)',
210
+ axes: {
211
+ left: {
212
+ mapsTo: 'value',
213
+ ticks: {},
214
+ },
215
+ bottom: {
216
+ mapsTo: 'date',
217
+ scaleType: 'time',
218
+ ticks: {},
219
+ },
220
+ },
221
+ tooltip: {},
222
+ bars: {
223
+ maxWidth: 200,
224
+ },
225
+ height: '400px',
226
+ },
227
+ };
228
+
229
+ export const VerticalSimpleBarEmptyState = Template.bind({});
230
+ VerticalSimpleBarEmptyState.args = {
231
+ isInverse: false,
232
+ type: CarbonChartType.bar,
233
+ dataSet: [],
234
+ options: {
235
+ title: 'Vertical simple bar (empty state)',
236
+ axes: {
237
+ left: {},
238
+ bottom: {
239
+ scaleType: 'labels',
240
+ },
241
+ },
242
+ height: '400px',
243
+ },
244
+ };
245
+
246
+ export const VerticalSimpleBarSkeleton = Template.bind({});
247
+ VerticalSimpleBarSkeleton.args = {
248
+ isInverse: false,
249
+ type: CarbonChartType.bar,
250
+ dataSet: [],
251
+ options: {
252
+ title: 'Vertical simple bar (skeleton)',
253
+ axes: {
254
+ left: {},
255
+ bottom: {
256
+ scaleType: 'labels',
257
+ },
258
+ },
259
+ data: {
260
+ loading: true,
261
+ },
262
+ height: '400px',
263
+ },
264
+ };
265
+
266
+ export const HorizontalSimpleBarTimeSeries = Template.bind({});
267
+ HorizontalSimpleBarTimeSeries.args = {
268
+ isInverse: false,
269
+ type: CarbonChartType.bar,
270
+ dataSet: [
271
+ {
272
+ group: 'Qty',
273
+ date: new Date(2019, 0, 1),
274
+ value: 10000,
275
+ },
276
+ {
277
+ group: 'More',
278
+ date: new Date(2019, 0, 2),
279
+ value: 65000,
280
+ },
281
+ {
282
+ group: 'Sold',
283
+ date: new Date(2019, 0, 3),
284
+ value: 30000,
285
+ },
286
+ {
287
+ group: 'Restocking',
288
+ date: new Date(2019, 0, 6),
289
+ value: 49213,
290
+ },
291
+ {
292
+ group: 'Misc',
293
+ date: new Date(2019, 0, 7),
294
+ value: 51213,
295
+ },
296
+ ],
297
+ options: {
298
+ title: 'Horizontal simple bar (time series)',
299
+ axes: {
300
+ left: {
301
+ mapsTo: 'date',
302
+ scaleType: 'time',
303
+ },
304
+ bottom: {
305
+ mapsTo: 'value',
306
+ },
307
+ },
308
+ height: '400px',
309
+ },
310
+ };
311
+
312
+ export const HorizontalSimpleBarDiscrete = Template.bind({});
313
+ HorizontalSimpleBarDiscrete.args = {
314
+ isInverse: false,
315
+ type: CarbonChartType.bar,
316
+ dataSet: [
317
+ {
318
+ group: 'Qty',
319
+ value: 65000,
320
+ },
321
+ {
322
+ group: 'More',
323
+ value: 29123,
324
+ },
325
+ {
326
+ group: 'Sold',
327
+ value: 35213,
328
+ },
329
+ {
330
+ group: 'Restocking',
331
+ value: 51213,
332
+ },
333
+ {
334
+ group: 'Misc',
335
+ value: 16932,
336
+ },
337
+ ],
338
+ options: {
339
+ title: 'Horizontal simple bar (discrete)',
340
+ axes: {
341
+ left: {
342
+ mapsTo: 'group',
343
+ scaleType: 'labels',
344
+ },
345
+ bottom: {
346
+ mapsTo: 'value',
347
+ },
348
+ },
349
+ height: '400px',
350
+ },
351
+ };
352
+
353
+ export const HorizontalSimpleBarSkeleton = Template.bind({});
354
+ HorizontalSimpleBarSkeleton.args = {
355
+ isInverse: false,
356
+ type: CarbonChartType.bar,
357
+ dataSet: [],
358
+ options: {
359
+ title: 'Horizontal simple bar (skeleton)',
360
+ axes: {
361
+ left: {
362
+ scaleType: 'labels',
363
+ },
364
+ bottom: {},
365
+ },
366
+ data: {
367
+ loading: true,
368
+ },
369
+ height: '400px',
370
+ },
371
+ };
372
+
373
+ export const HorizontalSimpleBarEmptyState = Template.bind({});
374
+ HorizontalSimpleBarEmptyState.args = {
375
+ isInverse: false,
376
+ type: CarbonChartType.bar,
377
+ dataSet: [],
378
+ options: {
379
+ title: 'Horizontal simple bar (empty state)',
380
+ axes: {
381
+ left: {
382
+ scaleType: 'labels',
383
+ },
384
+ bottom: {},
385
+ },
386
+ height: '400px',
387
+ },
388
+ };
@@ -0,0 +1,156 @@
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/Bar Floating',
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 HorizontalFloatingBarTimeSeries = Template.bind({});
31
+ HorizontalFloatingBarTimeSeries.args = {
32
+ isInverse: false,
33
+ type: CarbonChartType.bar,
34
+ dataSet: [
35
+ {
36
+ group: 'Qty',
37
+ date: new Date(2019, 0, 1),
38
+ value: [10000, 41000],
39
+ },
40
+ {
41
+ group: 'More',
42
+ date: new Date(2019, 0, 2),
43
+ value: 65000,
44
+ },
45
+ {
46
+ group: 'Sold',
47
+ date: new Date(2019, 0, 3),
48
+ value: 30000,
49
+ },
50
+ {
51
+ group: 'Restocking',
52
+ date: new Date(2019, 0, 6),
53
+ value: [22000, 69213],
54
+ },
55
+ {
56
+ group: 'Misc',
57
+ date: new Date(2019, 0, 7),
58
+ value: [3500, 71213],
59
+ },
60
+ ],
61
+ options: {
62
+ title: 'Horizontal floating bar (time series)',
63
+ axes: {
64
+ left: {
65
+ mapsTo: 'date',
66
+ scaleType: 'time',
67
+ },
68
+ bottom: {
69
+ mapsTo: 'value',
70
+ },
71
+ },
72
+ height: '400px',
73
+ },
74
+ };
75
+ export const FloatingVerticalBarDiscrete = Template.bind({});
76
+ FloatingVerticalBarDiscrete.args = {
77
+ isInverse: false,
78
+ type: CarbonChartType.bar,
79
+ dataSet: [
80
+ {
81
+ group: 'Qty',
82
+ value: [30000, 65000],
83
+ },
84
+ {
85
+ group: 'More',
86
+ value: [15000, 29123],
87
+ },
88
+ {
89
+ group: 'Sold',
90
+ value: [22000, 35213],
91
+ },
92
+ {
93
+ group: 'Restocking',
94
+ value: [28000, 51213],
95
+ },
96
+ {
97
+ group: 'Misc',
98
+ value: [3000, 16932],
99
+ },
100
+ ],
101
+ options: {
102
+ title: 'Floating vertical bar (discrete)',
103
+ axes: {
104
+ left: {
105
+ mapsTo: 'value',
106
+ includeZero: false,
107
+ },
108
+ bottom: {
109
+ mapsTo: 'group',
110
+ scaleType: 'labels',
111
+ },
112
+ },
113
+ height: '400px',
114
+ },
115
+ };
116
+ export const FloatingHorizontalBarDiscrete = Template.bind({});
117
+ FloatingHorizontalBarDiscrete.args = {
118
+ isInverse: false,
119
+ type: CarbonChartType.bar,
120
+ dataSet: [
121
+ {
122
+ group: 'Qty',
123
+ value: [30000, 65000],
124
+ },
125
+ {
126
+ group: 'More',
127
+ value: [15000, 29123],
128
+ },
129
+ {
130
+ group: 'Sold',
131
+ value: [22000, 35213],
132
+ },
133
+ {
134
+ group: 'Restocking',
135
+ value: [28000, 51213],
136
+ },
137
+ {
138
+ group: 'Misc',
139
+ value: [3000, 36932],
140
+ },
141
+ ],
142
+ options: {
143
+ title: 'Floating horizontal bar (discrete)',
144
+ axes: {
145
+ left: {
146
+ mapsTo: 'group',
147
+ scaleType: 'labels',
148
+ },
149
+ bottom: {
150
+ mapsTo: 'value',
151
+ includeZero: false,
152
+ },
153
+ },
154
+ height: '400px',
155
+ },
156
+ };