@scality/core-ui 0.162.0 → 0.163.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.
- package/dist/components/barchartv2/Barchart.component.d.ts +0 -2
- package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
- package/dist/components/barchartv2/Barchart.component.js +11 -1
- package/dist/components/barchartv2/utils.d.ts +25 -2
- package/dist/components/barchartv2/utils.d.ts.map +1 -1
- package/dist/components/barchartv2/utils.js +35 -3
- package/dist/components/chartlegend/ChartLegend.d.ts +8 -0
- package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -0
- package/dist/components/chartlegend/ChartLegend.js +65 -0
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts +17 -0
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -0
- package/dist/components/chartlegend/ChartLegendWrapper.js +50 -0
- package/dist/components/date/FormattedDateTime.d.ts +3 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +19 -1
- package/dist/components/date/FormattedDateTime.spec.js +12 -0
- package/dist/components/icon/Icon.component.d.ts +5 -5
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +33 -31
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +33 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +249 -0
- package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -1
- package/dist/components/selectv2/Selectv2.component.js +11 -6
- package/dist/components/steppers/Stepper.component.d.ts.map +1 -1
- package/dist/components/steppers/Stepper.component.js +9 -8
- package/dist/components/toast/ToastProvider.d.ts.map +1 -1
- package/dist/components/toast/ToastProvider.js +4 -5
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +1 -1
- package/dist/components/vegachartv2/SyncedCursorCharts.js +3 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/next.d.ts +1 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +1 -0
- package/dist/style/theme.d.ts +1 -0
- package/dist/style/theme.d.ts.map +1 -1
- package/dist/style/theme.js +28 -0
- package/package.json +2 -2
- package/src/lib/components/accordion/Accordion.test.tsx +7 -15
- package/src/lib/components/barchartv2/Barchart.component.test.tsx +82 -101
- package/src/lib/components/barchartv2/Barchart.component.tsx +14 -2
- package/src/lib/components/barchartv2/utils.test.ts +117 -0
- package/src/lib/components/barchartv2/utils.ts +54 -6
- package/src/lib/components/chartlegend/ChartLegend.tsx +113 -0
- package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +85 -0
- package/src/lib/components/date/FormattedDateTime.spec.tsx +24 -0
- package/src/lib/components/date/FormattedDateTime.tsx +36 -2
- package/src/lib/components/healthselectorv2/HealthSelector.component.test.tsx +3 -3
- package/src/lib/components/icon/Icon.component.tsx +48 -60
- package/src/lib/components/inlineinput/InlineInput.test.tsx +22 -19
- package/src/lib/components/inputlist/InputList.test.tsx +21 -19
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +502 -0
- package/src/lib/components/searchinput/SearchInput.test.tsx +3 -7
- package/src/lib/components/selectv2/Selectv2.component.tsx +13 -5
- package/src/lib/components/selectv2/selectv2.test.tsx +62 -57
- package/src/lib/components/steppers/Stepper.component.tsx +10 -8
- package/src/lib/components/tablev2/TableSync.test.tsx +8 -11
- package/src/lib/components/tablev2/Tablev2.test.tsx +36 -37
- package/src/lib/components/toast/ToastProvider.tsx +14 -6
- package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +5 -7
- package/src/lib/index.ts +1 -0
- package/src/lib/next.ts +1 -0
- package/src/lib/style/theme.ts +29 -0
- package/stories/BarChart/barchart.stories.tsx +292 -125
- package/stories/format.mdx +4 -2
- package/stories/linetimeseriechart.stories.tsx +485 -0
|
@@ -10,13 +10,10 @@ import {
|
|
|
10
10
|
import { Button } from '../../src/lib/components/buttonv2/Buttonv2.component';
|
|
11
11
|
import { Text } from '../../src/lib/components/text/Text.component';
|
|
12
12
|
import { spacing, Stack, Wrap } from '../../src/lib/spacing';
|
|
13
|
-
import {
|
|
14
|
-
CoreUITheme,
|
|
15
|
-
lineColor1,
|
|
16
|
-
lineColor2,
|
|
17
|
-
lineColor3,
|
|
18
|
-
} from '../../src/lib/style/theme';
|
|
13
|
+
import { CoreUITheme } from '../../src/lib/style/theme';
|
|
19
14
|
import { Wrapper } from '../common';
|
|
15
|
+
import { ChartLegendWrapper } from '../../src/lib/components/chartlegend/ChartLegendWrapper';
|
|
16
|
+
import { ChartLegend } from '../../src/lib/components/chartlegend/ChartLegend';
|
|
20
17
|
|
|
21
18
|
type Story = StoryObj<typeof Barchart>;
|
|
22
19
|
|
|
@@ -57,14 +54,17 @@ export const Playground: Story = {
|
|
|
57
54
|
},
|
|
58
55
|
] as const;
|
|
59
56
|
return (
|
|
60
|
-
<
|
|
61
|
-
type="category"
|
|
62
|
-
bars={exampleData}
|
|
57
|
+
<ChartLegendWrapper
|
|
63
58
|
colorSet={{
|
|
64
59
|
Success: theme.statusHealthy,
|
|
65
60
|
Failed: theme.statusCritical,
|
|
66
61
|
}}
|
|
67
|
-
|
|
62
|
+
>
|
|
63
|
+
<Stack direction="vertical" gap="r16">
|
|
64
|
+
<Barchart type="category" bars={exampleData} />
|
|
65
|
+
<ChartLegend shape="rectangle" direction="horizontal" />
|
|
66
|
+
</Stack>
|
|
67
|
+
</ChartLegendWrapper>
|
|
68
68
|
);
|
|
69
69
|
},
|
|
70
70
|
};
|
|
@@ -114,27 +114,33 @@ export const Time7Days: Story = {
|
|
|
114
114
|
render: () => {
|
|
115
115
|
const theme = useTheme() as CoreUITheme;
|
|
116
116
|
return (
|
|
117
|
-
<
|
|
118
|
-
type={{
|
|
119
|
-
type: 'time',
|
|
120
|
-
timeRange: {
|
|
121
|
-
startDate: new Date(
|
|
122
|
-
new Date(Date.now()).setHours(0, 0, 0, 0) -
|
|
123
|
-
7 * 24 * 60 * 60 * 1000,
|
|
124
|
-
),
|
|
125
|
-
endDate: new Date(
|
|
126
|
-
new Date(Date.now()).setHours(0, 0, 0, 0) -
|
|
127
|
-
1 * 24 * 60 * 60 * 1000,
|
|
128
|
-
),
|
|
129
|
-
interval: 24 * 60 * 60 * 1000,
|
|
130
|
-
},
|
|
131
|
-
}}
|
|
132
|
-
bars={timeData7Days}
|
|
117
|
+
<ChartLegendWrapper
|
|
133
118
|
colorSet={{
|
|
134
119
|
Success: theme.statusHealthy,
|
|
135
120
|
Failed: theme.statusCritical,
|
|
136
121
|
}}
|
|
137
|
-
|
|
122
|
+
>
|
|
123
|
+
<Stack direction="vertical" gap="r16">
|
|
124
|
+
<Barchart
|
|
125
|
+
type={{
|
|
126
|
+
type: 'time',
|
|
127
|
+
timeRange: {
|
|
128
|
+
startDate: new Date(
|
|
129
|
+
new Date(Date.now()).setHours(0, 0, 0, 0) -
|
|
130
|
+
7 * 24 * 60 * 60 * 1000,
|
|
131
|
+
),
|
|
132
|
+
endDate: new Date(
|
|
133
|
+
new Date(Date.now()).setHours(0, 0, 0, 0) -
|
|
134
|
+
1 * 24 * 60 * 60 * 1000,
|
|
135
|
+
),
|
|
136
|
+
interval: 24 * 60 * 60 * 1000,
|
|
137
|
+
},
|
|
138
|
+
}}
|
|
139
|
+
bars={timeData7Days}
|
|
140
|
+
/>
|
|
141
|
+
<ChartLegend shape="line" />
|
|
142
|
+
</Stack>
|
|
143
|
+
</ChartLegendWrapper>
|
|
138
144
|
);
|
|
139
145
|
},
|
|
140
146
|
};
|
|
@@ -179,27 +185,30 @@ export const Time7DaysWithMissingData: Story = {
|
|
|
179
185
|
render: () => {
|
|
180
186
|
const theme = useTheme() as CoreUITheme;
|
|
181
187
|
return (
|
|
182
|
-
<
|
|
183
|
-
type={{
|
|
184
|
-
type: 'time',
|
|
185
|
-
timeRange: {
|
|
186
|
-
startDate: new Date(
|
|
187
|
-
new Date(Date.now()).setHours(0, 0, 0, 0) -
|
|
188
|
-
7 * 24 * 60 * 60 * 1000,
|
|
189
|
-
),
|
|
190
|
-
endDate: new Date(
|
|
191
|
-
new Date(Date.now()).setHours(0, 0, 0, 0) -
|
|
192
|
-
1 * 24 * 60 * 60 * 1000,
|
|
193
|
-
),
|
|
194
|
-
interval: 24 * 60 * 60 * 1000,
|
|
195
|
-
},
|
|
196
|
-
}}
|
|
197
|
-
bars={timeData7DaysWithMissingData}
|
|
188
|
+
<ChartLegendWrapper
|
|
198
189
|
colorSet={{
|
|
199
190
|
Success: theme.statusHealthy,
|
|
200
191
|
Failed: theme.statusCritical,
|
|
201
192
|
}}
|
|
202
|
-
|
|
193
|
+
>
|
|
194
|
+
<Barchart
|
|
195
|
+
type={{
|
|
196
|
+
type: 'time',
|
|
197
|
+
timeRange: {
|
|
198
|
+
startDate: new Date(
|
|
199
|
+
new Date(Date.now()).setHours(0, 0, 0, 0) -
|
|
200
|
+
7 * 24 * 60 * 60 * 1000,
|
|
201
|
+
),
|
|
202
|
+
endDate: new Date(
|
|
203
|
+
new Date(Date.now()).setHours(0, 0, 0, 0) -
|
|
204
|
+
1 * 24 * 60 * 60 * 1000,
|
|
205
|
+
),
|
|
206
|
+
interval: 24 * 60 * 60 * 1000,
|
|
207
|
+
},
|
|
208
|
+
}}
|
|
209
|
+
bars={timeData7DaysWithMissingData}
|
|
210
|
+
/>
|
|
211
|
+
</ChartLegendWrapper>
|
|
203
212
|
);
|
|
204
213
|
},
|
|
205
214
|
};
|
|
@@ -269,23 +278,26 @@ export const TimeLast24Hours: Story = {
|
|
|
269
278
|
render: () => {
|
|
270
279
|
const theme = useTheme() as CoreUITheme;
|
|
271
280
|
return (
|
|
272
|
-
<
|
|
273
|
-
type={{
|
|
274
|
-
type: 'time',
|
|
275
|
-
timeRange: {
|
|
276
|
-
startDate: new Date(
|
|
277
|
-
new Date(Date.now()).setMinutes(0, 0, 0) - 24 * 60 * 60 * 1000,
|
|
278
|
-
),
|
|
279
|
-
endDate: new Date(new Date(Date.now()).setMinutes(0, 0, 0)),
|
|
280
|
-
interval: 60 * 60 * 1000,
|
|
281
|
-
},
|
|
282
|
-
}}
|
|
283
|
-
bars={timeDataLast24Hours}
|
|
281
|
+
<ChartLegendWrapper
|
|
284
282
|
colorSet={{
|
|
285
283
|
Success: theme.statusHealthy,
|
|
286
284
|
Failed: theme.statusCritical,
|
|
287
285
|
}}
|
|
288
|
-
|
|
286
|
+
>
|
|
287
|
+
<Barchart
|
|
288
|
+
type={{
|
|
289
|
+
type: 'time',
|
|
290
|
+
timeRange: {
|
|
291
|
+
startDate: new Date(
|
|
292
|
+
new Date(Date.now()).setMinutes(0, 0, 0) - 24 * 60 * 60 * 1000,
|
|
293
|
+
),
|
|
294
|
+
endDate: new Date(new Date(Date.now()).setMinutes(0, 0, 0)),
|
|
295
|
+
interval: 60 * 60 * 1000,
|
|
296
|
+
},
|
|
297
|
+
}}
|
|
298
|
+
bars={timeDataLast24Hours}
|
|
299
|
+
/>
|
|
300
|
+
</ChartLegendWrapper>
|
|
289
301
|
);
|
|
290
302
|
},
|
|
291
303
|
};
|
|
@@ -313,32 +325,35 @@ export const CapacityWithUnitRange: Story = {
|
|
|
313
325
|
render: () => {
|
|
314
326
|
const theme = useTheme() as CoreUITheme;
|
|
315
327
|
return (
|
|
316
|
-
<
|
|
317
|
-
type="category"
|
|
318
|
-
bars={capacityDataWithUnitRange}
|
|
319
|
-
unitRange={[
|
|
320
|
-
{
|
|
321
|
-
threshold: 0,
|
|
322
|
-
label: 'B',
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
threshold: 1024,
|
|
326
|
-
label: 'KiB',
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
threshold: 1024 * 1024,
|
|
330
|
-
label: 'MiB',
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
threshold: 1024 * 1024 * 1024,
|
|
334
|
-
label: 'GiB',
|
|
335
|
-
},
|
|
336
|
-
]}
|
|
328
|
+
<ChartLegendWrapper
|
|
337
329
|
colorSet={{
|
|
338
330
|
Free: theme.selectedActive,
|
|
339
331
|
Used: theme.infoSecondary,
|
|
340
332
|
}}
|
|
341
|
-
|
|
333
|
+
>
|
|
334
|
+
<Barchart
|
|
335
|
+
type="category"
|
|
336
|
+
bars={capacityDataWithUnitRange}
|
|
337
|
+
unitRange={[
|
|
338
|
+
{
|
|
339
|
+
threshold: 0,
|
|
340
|
+
label: 'B',
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
threshold: 1024,
|
|
344
|
+
label: 'KiB',
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
threshold: 1024 * 1024,
|
|
348
|
+
label: 'MiB',
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
threshold: 1024 * 1024 * 1024,
|
|
352
|
+
label: 'GiB',
|
|
353
|
+
},
|
|
354
|
+
]}
|
|
355
|
+
/>
|
|
356
|
+
</ChartLegendWrapper>
|
|
342
357
|
);
|
|
343
358
|
},
|
|
344
359
|
};
|
|
@@ -371,15 +386,17 @@ export const Stacked: Story = {
|
|
|
371
386
|
render: () => {
|
|
372
387
|
const theme = useTheme() as CoreUITheme;
|
|
373
388
|
return (
|
|
374
|
-
<
|
|
375
|
-
type="category"
|
|
376
|
-
bars={stackedData}
|
|
377
|
-
stacked
|
|
389
|
+
<ChartLegendWrapper
|
|
378
390
|
colorSet={{
|
|
379
391
|
Success: theme.statusHealthy,
|
|
380
392
|
Failed: theme.statusCritical,
|
|
381
393
|
}}
|
|
382
|
-
|
|
394
|
+
>
|
|
395
|
+
<Stack direction="vertical" gap="r16">
|
|
396
|
+
<Barchart type="category" bars={stackedData} stacked />
|
|
397
|
+
<ChartLegend shape="rectangle" />
|
|
398
|
+
</Stack>
|
|
399
|
+
</ChartLegendWrapper>
|
|
383
400
|
);
|
|
384
401
|
},
|
|
385
402
|
};
|
|
@@ -420,16 +437,19 @@ export const DefaultSort: Story = {
|
|
|
420
437
|
return totalA - totalB > 0 ? -1 : totalA - totalB < 0 ? 1 : 0; // Descending order
|
|
421
438
|
};
|
|
422
439
|
return (
|
|
423
|
-
<
|
|
424
|
-
type="category"
|
|
425
|
-
stacked
|
|
426
|
-
bars={defaultSortData}
|
|
427
|
-
defaultSort={customSort}
|
|
440
|
+
<ChartLegendWrapper
|
|
428
441
|
colorSet={{
|
|
429
442
|
Success: theme.statusHealthy,
|
|
430
443
|
Failed: theme.statusCritical,
|
|
431
444
|
}}
|
|
432
|
-
|
|
445
|
+
>
|
|
446
|
+
<Barchart
|
|
447
|
+
type="category"
|
|
448
|
+
stacked
|
|
449
|
+
bars={defaultSortData}
|
|
450
|
+
defaultSort={customSort}
|
|
451
|
+
/>
|
|
452
|
+
</ChartLegendWrapper>
|
|
433
453
|
);
|
|
434
454
|
},
|
|
435
455
|
};
|
|
@@ -494,16 +514,22 @@ export const WithCustomTooltip: Story = {
|
|
|
494
514
|
<Text variant="Basic" color="textSecondary">
|
|
495
515
|
Tooltip and sort functions defined outside with full type safety
|
|
496
516
|
</Text>
|
|
497
|
-
<
|
|
498
|
-
type="category"
|
|
499
|
-
bars={exampleData}
|
|
500
|
-
tooltip={customTooltip}
|
|
501
|
-
height={300}
|
|
517
|
+
<ChartLegendWrapper
|
|
502
518
|
colorSet={{
|
|
503
519
|
Success: theme.statusHealthy,
|
|
504
520
|
Failed: theme.statusCritical,
|
|
505
521
|
}}
|
|
506
|
-
|
|
522
|
+
>
|
|
523
|
+
<Stack direction="vertical" gap="r16">
|
|
524
|
+
<Barchart
|
|
525
|
+
type="category"
|
|
526
|
+
bars={exampleData}
|
|
527
|
+
tooltip={customTooltip}
|
|
528
|
+
height={300}
|
|
529
|
+
/>
|
|
530
|
+
<ChartLegend shape="line" />
|
|
531
|
+
</Stack>
|
|
532
|
+
</ChartLegendWrapper>
|
|
507
533
|
</Stack>
|
|
508
534
|
);
|
|
509
535
|
},
|
|
@@ -558,21 +584,158 @@ export const StatusColors: Story = {
|
|
|
558
584
|
},
|
|
559
585
|
] as const;
|
|
560
586
|
return (
|
|
561
|
-
<
|
|
562
|
-
type="category"
|
|
563
|
-
bars={statusData}
|
|
564
|
-
stacked
|
|
587
|
+
<ChartLegendWrapper
|
|
565
588
|
colorSet={{
|
|
566
589
|
'Success Rate': theme.statusHealthy,
|
|
567
590
|
'Failed Requests': theme.statusCritical,
|
|
568
591
|
'Warning Events': theme.statusWarning,
|
|
569
592
|
}}
|
|
570
|
-
|
|
571
|
-
|
|
593
|
+
>
|
|
594
|
+
<Stack direction="vertical" gap="r16">
|
|
595
|
+
<Barchart
|
|
596
|
+
type="category"
|
|
597
|
+
bars={statusData}
|
|
598
|
+
stacked
|
|
599
|
+
title="System Health Metrics"
|
|
600
|
+
/>
|
|
601
|
+
<ChartLegend shape="rectangle" />
|
|
602
|
+
</Stack>
|
|
603
|
+
</ChartLegendWrapper>
|
|
604
|
+
);
|
|
605
|
+
},
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
export const LegendShapes: Story = {
|
|
609
|
+
render: () => {
|
|
610
|
+
const theme = useTheme() as CoreUITheme;
|
|
611
|
+
const exampleData = [
|
|
612
|
+
{
|
|
613
|
+
label: 'Success',
|
|
614
|
+
data: [
|
|
615
|
+
['category1', 25],
|
|
616
|
+
['category2', 40],
|
|
617
|
+
['category3', 35],
|
|
618
|
+
],
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
label: 'Failed',
|
|
622
|
+
data: [
|
|
623
|
+
['category1', 15],
|
|
624
|
+
['category2', 20],
|
|
625
|
+
['category3', 18],
|
|
626
|
+
],
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
label: 'Warning',
|
|
630
|
+
data: [
|
|
631
|
+
['category1', 8],
|
|
632
|
+
['category2', 12],
|
|
633
|
+
['category3', 10],
|
|
634
|
+
],
|
|
635
|
+
},
|
|
636
|
+
] as const;
|
|
637
|
+
return (
|
|
638
|
+
<Stack direction="vertical" gap="r24">
|
|
639
|
+
<Text variant="Large">Legend Shapes</Text>
|
|
640
|
+
|
|
641
|
+
<ChartLegendWrapper
|
|
642
|
+
colorSet={{
|
|
643
|
+
Success: theme.statusHealthy,
|
|
644
|
+
Failed: theme.statusCritical,
|
|
645
|
+
Warning: theme.statusWarning,
|
|
646
|
+
}}
|
|
647
|
+
>
|
|
648
|
+
<Stack direction="vertical" gap="r16">
|
|
649
|
+
<Barchart
|
|
650
|
+
type="category"
|
|
651
|
+
bars={exampleData}
|
|
652
|
+
height={200}
|
|
653
|
+
title="Horizontal Rectangle Legend"
|
|
654
|
+
/>
|
|
655
|
+
<ChartLegend shape="rectangle" />
|
|
656
|
+
</Stack>
|
|
657
|
+
</ChartLegendWrapper>
|
|
658
|
+
<ChartLegendWrapper
|
|
659
|
+
colorSet={{
|
|
660
|
+
Success: theme.statusHealthy,
|
|
661
|
+
Failed: theme.statusCritical,
|
|
662
|
+
Warning: theme.statusWarning,
|
|
663
|
+
}}
|
|
664
|
+
>
|
|
665
|
+
<Stack direction="vertical" gap="r16">
|
|
666
|
+
<Barchart
|
|
667
|
+
type="category"
|
|
668
|
+
bars={exampleData}
|
|
669
|
+
height={200}
|
|
670
|
+
title="Vertical Line Legend"
|
|
671
|
+
/>
|
|
672
|
+
<ChartLegend shape="line" direction="vertical" />
|
|
673
|
+
</Stack>
|
|
674
|
+
</ChartLegendWrapper>
|
|
675
|
+
</Stack>
|
|
572
676
|
);
|
|
573
677
|
},
|
|
574
678
|
};
|
|
575
679
|
|
|
680
|
+
export const BarchartsWithSingleLegend: Story = {
|
|
681
|
+
render: () => {
|
|
682
|
+
const theme = useTheme() as CoreUITheme;
|
|
683
|
+
const exampleData = [
|
|
684
|
+
{
|
|
685
|
+
label: 'Success',
|
|
686
|
+
data: [
|
|
687
|
+
['category1', 25],
|
|
688
|
+
['category2', 40],
|
|
689
|
+
['category3', 35],
|
|
690
|
+
],
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
label: 'Failed',
|
|
694
|
+
data: [
|
|
695
|
+
['category1', 15],
|
|
696
|
+
['category2', 20],
|
|
697
|
+
['category3', 18],
|
|
698
|
+
],
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
label: 'Warning',
|
|
702
|
+
data: [
|
|
703
|
+
['category1', 8],
|
|
704
|
+
['category2', 12],
|
|
705
|
+
['category3', 10],
|
|
706
|
+
],
|
|
707
|
+
},
|
|
708
|
+
] as const;
|
|
709
|
+
return (
|
|
710
|
+
<Stack direction="vertical" gap="r24">
|
|
711
|
+
<Text variant="Large">Barcharts with Single Shared Legend</Text>
|
|
712
|
+
|
|
713
|
+
<ChartLegendWrapper
|
|
714
|
+
colorSet={{
|
|
715
|
+
Success: theme.statusHealthy,
|
|
716
|
+
Failed: theme.statusCritical,
|
|
717
|
+
Warning: theme.statusWarning,
|
|
718
|
+
}}
|
|
719
|
+
>
|
|
720
|
+
<Barchart
|
|
721
|
+
type="category"
|
|
722
|
+
bars={exampleData}
|
|
723
|
+
height={200}
|
|
724
|
+
title="Barchart 1"
|
|
725
|
+
/>
|
|
726
|
+
|
|
727
|
+
<Barchart
|
|
728
|
+
type="category"
|
|
729
|
+
bars={exampleData}
|
|
730
|
+
height={200}
|
|
731
|
+
title="Barchart 2"
|
|
732
|
+
/>
|
|
733
|
+
<ChartLegend shape="rectangle" />
|
|
734
|
+
</ChartLegendWrapper>
|
|
735
|
+
</Stack>
|
|
736
|
+
);
|
|
737
|
+
},
|
|
738
|
+
};
|
|
576
739
|
export const CompleteExample: Story = {
|
|
577
740
|
render: () => {
|
|
578
741
|
const theme = useTheme() as CoreUITheme;
|
|
@@ -622,33 +785,37 @@ export const CompleteExample: Story = {
|
|
|
622
785
|
backgroundColor: theme.backgroundLevel2,
|
|
623
786
|
}}
|
|
624
787
|
>
|
|
625
|
-
<
|
|
626
|
-
type="category"
|
|
627
|
-
title="Loading BarChart"
|
|
628
|
-
helpTooltip="Click on the button to load or unload data"
|
|
629
|
-
secondaryTitle={isLoading ? 'Loading...' : 'Loaded data'}
|
|
630
|
-
rightTitle={
|
|
631
|
-
<Button
|
|
632
|
-
label={isLoading ? 'Load data' : 'Fake loading data'}
|
|
633
|
-
onClick={() => {
|
|
634
|
-
setIsLoading(!isLoading);
|
|
635
|
-
if (isLoading) {
|
|
636
|
-
setData(exampleData);
|
|
637
|
-
} else {
|
|
638
|
-
setData(undefined);
|
|
639
|
-
}
|
|
640
|
-
}}
|
|
641
|
-
/>
|
|
642
|
-
}
|
|
643
|
-
bars={data || []}
|
|
644
|
-
tooltip={customTooltip}
|
|
645
|
-
isLoading={isLoading}
|
|
646
|
-
height={200}
|
|
788
|
+
<ChartLegendWrapper
|
|
647
789
|
colorSet={{
|
|
648
790
|
Success: 'lineColor1',
|
|
649
791
|
Failed: 'lineColor2',
|
|
650
792
|
}}
|
|
651
|
-
|
|
793
|
+
>
|
|
794
|
+
<Barchart
|
|
795
|
+
type="category"
|
|
796
|
+
title="Loading BarChart"
|
|
797
|
+
helpTooltip="Click on the button to load or unload data"
|
|
798
|
+
secondaryTitle={isLoading ? 'Loading...' : 'Loaded data'}
|
|
799
|
+
rightTitle={
|
|
800
|
+
<Button
|
|
801
|
+
label={isLoading ? 'Load data' : 'Fake loading data'}
|
|
802
|
+
onClick={() => {
|
|
803
|
+
setIsLoading(!isLoading);
|
|
804
|
+
if (isLoading) {
|
|
805
|
+
setData(exampleData);
|
|
806
|
+
} else {
|
|
807
|
+
setData(undefined);
|
|
808
|
+
}
|
|
809
|
+
}}
|
|
810
|
+
/>
|
|
811
|
+
}
|
|
812
|
+
bars={data || []}
|
|
813
|
+
tooltip={customTooltip}
|
|
814
|
+
isLoading={isLoading}
|
|
815
|
+
height={200}
|
|
816
|
+
/>
|
|
817
|
+
<ChartLegend shape="rectangle" direction="horizontal" />
|
|
818
|
+
</ChartLegendWrapper>
|
|
652
819
|
</div>
|
|
653
820
|
);
|
|
654
821
|
},
|
package/stories/format.mdx
CHANGED
|
@@ -32,8 +32,10 @@ import { Meta } from '@storybook/blocks';
|
|
|
32
32
|
| Short#1 | DD MMM | 20 Jul | 5 | Chart time axis |
|
|
33
33
|
| Short#2 | DDMMM HH:mm | 20Jul 09:00 | 11 | Limited space, year not needed |
|
|
34
34
|
| Short#3 | YYYY-MM-DD | 2020-07-20 | 10 | Tables |
|
|
35
|
-
| Mid#1 |
|
|
36
|
-
| Mid#2 |
|
|
35
|
+
| Mid#1 | DD MMM HH:mm | 20 Jul 09:00 | 12 | Chart Axis ticks |
|
|
36
|
+
| Mid#2 | DD MMM HH:mm:ss | 20 Jul 09:00:00 | 15 | Chart Tooltip title |
|
|
37
|
+
| Mid#3 | YYYY-MM-DD HH:mm | 2020-07-20 09:00 | 16 | Tables (creation/modification dates) |
|
|
38
|
+
| Mid#4 | YYYY-MM-DD HH:mm:ss | 2020-07-20 09:00:00 | 19 | When the seconds are needed |
|
|
37
39
|
| Full#1 | EEE MMM DD YYYY HH:mm:ss | Mon Jul 20 2020 09:00:00 | 24 | When a lot of space (hover) - When precision is needed |
|
|
38
40
|
|
|
39
41
|
### Remarks:
|