@scality/core-ui 0.169.0 → 0.171.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/__mocks__/uuid.js +11 -0
- package/dist/components/barchartv2/Barchart.component.js +2 -2
- package/dist/components/buttonv2/Buttonv2.component.js +1 -1
- package/dist/components/chartlegend/ChartLegend.d.ts +3 -1
- package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegend.js +2 -2
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts +3 -1
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegendWrapper.js +43 -9
- package/dist/components/date/FormattedDateTime.d.ts +41 -2
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +55 -8
- package/dist/components/date/FormattedDateTime.spec.js +12 -3
- package/dist/components/icon/Icon.component.d.ts +2 -0
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +2 -0
- package/dist/components/layout/v2/index.d.ts +2 -1
- package/dist/components/layout/v2/index.d.ts.map +1 -1
- package/dist/components/layout/v2/index.js +3 -3
- package/dist/components/linetemporalchart/ChartUtil.d.ts.map +1 -1
- package/dist/components/linetemporalchart/ChartUtil.js +12 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +10 -5
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +84 -49
- package/dist/components/text/Text.component.d.ts +2 -1
- package/dist/components/text/Text.component.d.ts.map +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +1 -1
- package/dist/style/theme.js +1 -1
- package/package.json +3 -1
- package/src/lib/components/barchartv2/Barchart.component.tsx +2 -2
- package/src/lib/components/barchartv2/ChartTooltip.test.tsx +1 -1
- package/src/lib/components/buttonv2/Buttonv2.component.tsx +1 -1
- package/src/lib/components/chartlegend/ChartLegend.tsx +4 -2
- package/src/lib/components/chartlegend/ChartLegendWrapper.test.tsx +197 -0
- package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +65 -9
- package/src/lib/components/date/FormattedDateTime.spec.tsx +27 -2
- package/src/lib/components/date/FormattedDateTime.tsx +61 -11
- package/src/lib/components/icon/Icon.component.tsx +2 -0
- package/src/lib/components/layout/v2/index.tsx +5 -3
- package/src/lib/components/linetemporalchart/ChartUtil.ts +26 -0
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +227 -157
- package/src/lib/components/text/Text.component.tsx +8 -1
- package/src/lib/next.ts +4 -1
- package/src/lib/style/theme.ts +1 -1
- package/stories/BarChart/barchart.stories.tsx +7 -1
- package/stories/formattedate.stories.tsx +7 -0
- package/stories/layout.stories.tsx +19 -0
- package/stories/linetimeseriechart.stories.tsx +217 -1
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
LineTimeSerieChart,
|
|
5
|
+
Serie,
|
|
6
|
+
} from '../src/lib/components/linetimeseriechart/linetimeseriechart.component';
|
|
4
7
|
import { ChartLegendWrapper } from '../src/lib/components/chartlegend/ChartLegendWrapper';
|
|
5
8
|
import { lineTimeSeriesColorRange } from '../src/lib/style/theme';
|
|
6
9
|
import { ChartLegend } from '../src/lib/components/chartlegend/ChartLegend';
|
|
10
|
+
import {
|
|
11
|
+
useChartId,
|
|
12
|
+
useChartLegend,
|
|
13
|
+
} from '../src/lib/components/chartlegend/ChartLegendWrapper';
|
|
14
|
+
import { useEffect } from 'react';
|
|
7
15
|
import {
|
|
8
16
|
SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
|
|
9
17
|
SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS,
|
|
10
18
|
} from '../src/lib/components/constants';
|
|
19
|
+
import { Button } from '../src/lib/components/buttonv2/Buttonv2.component';
|
|
11
20
|
|
|
12
21
|
const ChartWithProviders = (props) => {
|
|
13
22
|
return (
|
|
@@ -634,3 +643,210 @@ export const DateFormatExample: Story = {
|
|
|
634
643
|
timeFormat: 'date',
|
|
635
644
|
},
|
|
636
645
|
};
|
|
646
|
+
|
|
647
|
+
export const SyncIdExample: Story = {
|
|
648
|
+
render: () => {
|
|
649
|
+
return (
|
|
650
|
+
<ChartLegendWrapper
|
|
651
|
+
colorSet={{
|
|
652
|
+
'ip-10-160-122-207.eu-north-1.compute.internal':
|
|
653
|
+
lineTimeSeriesColorRange[0],
|
|
654
|
+
'ip-10-160-122-207.eu-north-2.compute.internal':
|
|
655
|
+
lineTimeSeriesColorRange[1],
|
|
656
|
+
}}
|
|
657
|
+
>
|
|
658
|
+
<LineTimeSerieChart
|
|
659
|
+
syncId="sync-id"
|
|
660
|
+
series={{
|
|
661
|
+
above: [
|
|
662
|
+
{
|
|
663
|
+
data: prometheusData as [number, string | number | null][],
|
|
664
|
+
resource: 'ip-10-160-122-207.eu-north-1.compute.internal',
|
|
665
|
+
metricPrefix: 'in',
|
|
666
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
data: prometheusData2 as [number, string | number | null][],
|
|
670
|
+
resource: 'ip-10-160-122-207.eu-north-2.compute.internal',
|
|
671
|
+
metricPrefix: 'in',
|
|
672
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
673
|
+
},
|
|
674
|
+
],
|
|
675
|
+
below: [
|
|
676
|
+
{
|
|
677
|
+
data: prometheusData3 as [number, string | number | null][],
|
|
678
|
+
resource: 'ip-10-160-122-207.eu-north-1.compute.internal',
|
|
679
|
+
metricPrefix: 'out',
|
|
680
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
data: prometheusData4 as [number, string | number | null][],
|
|
684
|
+
resource: 'ip-10-160-122-207.eu-north-2.compute.internal',
|
|
685
|
+
metricPrefix: 'out',
|
|
686
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
687
|
+
},
|
|
688
|
+
],
|
|
689
|
+
}}
|
|
690
|
+
title="ControlPlane Bandwidth"
|
|
691
|
+
height={200}
|
|
692
|
+
startingTimeStamp={Number(prometheusData[0][0])}
|
|
693
|
+
unitRange={UNIT_RANGE_BS}
|
|
694
|
+
isLoading={false}
|
|
695
|
+
yAxisType={'symmetrical'}
|
|
696
|
+
yAxisTitle={'in(+)/out(-)'}
|
|
697
|
+
interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
|
|
698
|
+
duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
|
|
699
|
+
/>
|
|
700
|
+
|
|
701
|
+
<LineTimeSerieChart
|
|
702
|
+
syncId="sync-id"
|
|
703
|
+
series={{
|
|
704
|
+
above: [
|
|
705
|
+
{
|
|
706
|
+
data: prometheusData2 as [number, string | number | null][],
|
|
707
|
+
resource: 'ip-10-160-122-207.eu-north-1.compute.internal',
|
|
708
|
+
metricPrefix: 'in',
|
|
709
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
710
|
+
},
|
|
711
|
+
],
|
|
712
|
+
below: [],
|
|
713
|
+
}}
|
|
714
|
+
title="ControlPlane Bandwidth 2"
|
|
715
|
+
height={200}
|
|
716
|
+
startingTimeStamp={Number(prometheusData2[0][0])}
|
|
717
|
+
unitRange={UNIT_RANGE_BS}
|
|
718
|
+
isLoading={false}
|
|
719
|
+
yAxisType={'symmetrical'}
|
|
720
|
+
yAxisTitle={'in(+)/out(-)'}
|
|
721
|
+
interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
|
|
722
|
+
duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
|
|
723
|
+
/>
|
|
724
|
+
<ChartLegend shape="line" direction="vertical" />
|
|
725
|
+
</ChartLegendWrapper>
|
|
726
|
+
);
|
|
727
|
+
},
|
|
728
|
+
};
|
|
729
|
+
export const CustomTooltipExample: Story = {
|
|
730
|
+
args: {
|
|
731
|
+
series: [
|
|
732
|
+
{
|
|
733
|
+
data: prometheusData,
|
|
734
|
+
resource: 'ip-10-160-122-207.eu-north-1.compute.internal',
|
|
735
|
+
metricPrefix: 'instance:10.160.122.207:9100',
|
|
736
|
+
getTooltipLabel: (prefix, resource) => `${resource}`,
|
|
737
|
+
},
|
|
738
|
+
],
|
|
739
|
+
title: 'CPU Usage',
|
|
740
|
+
height: 200,
|
|
741
|
+
startingTimeStamp: prometheusData[0][0],
|
|
742
|
+
isLoading: false,
|
|
743
|
+
isLegendHidden: false,
|
|
744
|
+
helpText: 'This is the help text',
|
|
745
|
+
yAxisType: 'percentage',
|
|
746
|
+
yAxisTitle: '',
|
|
747
|
+
interval: SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS,
|
|
748
|
+
duration: SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
|
|
749
|
+
timeFormat: 'date-time',
|
|
750
|
+
renderTooltip: (props) => {
|
|
751
|
+
return <div>Custom Tooltip</div>;
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
// Dynamic colorSet example components
|
|
757
|
+
const DynamicChart1 = (props) => {
|
|
758
|
+
const chartId = useChartId();
|
|
759
|
+
const { register } = useChartLegend();
|
|
760
|
+
|
|
761
|
+
useEffect(() => {
|
|
762
|
+
register(chartId, [
|
|
763
|
+
'ip-10-160-122-207.eu-north-1.compute.internal',
|
|
764
|
+
'ip-10-160-122-207.eu-north-2.compute.internal',
|
|
765
|
+
]);
|
|
766
|
+
}, [chartId, register]);
|
|
767
|
+
|
|
768
|
+
return <LineTimeSerieChart {...props} />;
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
const DynamicChart2 = (props) => {
|
|
772
|
+
const chartId = useChartId();
|
|
773
|
+
const { register } = useChartLegend();
|
|
774
|
+
|
|
775
|
+
useEffect(() => {
|
|
776
|
+
register(chartId, ['ip-10-160-122-207.eu-north-1.compute.internal']);
|
|
777
|
+
}, [chartId, register]);
|
|
778
|
+
|
|
779
|
+
return <LineTimeSerieChart {...props} />;
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
const generateColors = (seriesNames: string[]) => {
|
|
783
|
+
const colors: Record<string, string> = {};
|
|
784
|
+
seriesNames.forEach((name, index) => {
|
|
785
|
+
colors[name] =
|
|
786
|
+
lineTimeSeriesColorRange[index % lineTimeSeriesColorRange.length];
|
|
787
|
+
});
|
|
788
|
+
return colors;
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
export const DynamicColorSetExample: Story = {
|
|
792
|
+
render: () => {
|
|
793
|
+
return (
|
|
794
|
+
<ChartLegendWrapper colorSet={generateColors}>
|
|
795
|
+
<div style={{ marginBottom: '20px' }}>
|
|
796
|
+
<h3>Chart 1 - Multiple Series</h3>
|
|
797
|
+
<DynamicChart1
|
|
798
|
+
series={{
|
|
799
|
+
above: [
|
|
800
|
+
{
|
|
801
|
+
data: prometheusData as [number, string | number | null][],
|
|
802
|
+
resource: 'ip-10-160-122-207.eu-north-1.compute.internal',
|
|
803
|
+
metricPrefix: 'in',
|
|
804
|
+
getTooltipLabel: (prefix, resource) =>
|
|
805
|
+
`${resource}-${prefix}`,
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
data: prometheusData2 as [number, string | number | null][],
|
|
809
|
+
resource: 'ip-10-160-122-207.eu-north-2.compute.internal',
|
|
810
|
+
metricPrefix: 'in',
|
|
811
|
+
getTooltipLabel: (prefix, resource) =>
|
|
812
|
+
`${resource}-${prefix}`,
|
|
813
|
+
},
|
|
814
|
+
],
|
|
815
|
+
below: [],
|
|
816
|
+
}}
|
|
817
|
+
title="Dynamic Chart 1"
|
|
818
|
+
height={200}
|
|
819
|
+
startingTimeStamp={Number(prometheusData[0][0])}
|
|
820
|
+
isLoading={false}
|
|
821
|
+
yAxisType={'symmetrical'}
|
|
822
|
+
interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
|
|
823
|
+
duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
|
|
824
|
+
/>
|
|
825
|
+
</div>
|
|
826
|
+
|
|
827
|
+
<div style={{ marginBottom: '20px' }}>
|
|
828
|
+
<h3>Chart 2 - Single Series (Overlapping with Chart 1)</h3>
|
|
829
|
+
<DynamicChart2
|
|
830
|
+
series={[
|
|
831
|
+
{
|
|
832
|
+
data: prometheusData3 as [number, string | number | null][],
|
|
833
|
+
resource: 'ip-10-160-122-207.eu-north-1.compute.internal',
|
|
834
|
+
metricPrefix: 'instance:10.160.122.207:9100',
|
|
835
|
+
getTooltipLabel: (prefix, resource) => `${resource}`,
|
|
836
|
+
},
|
|
837
|
+
]}
|
|
838
|
+
title="Dynamic Chart 2"
|
|
839
|
+
height={200}
|
|
840
|
+
startingTimeStamp={Number(prometheusData3[0][0])}
|
|
841
|
+
isLoading={false}
|
|
842
|
+
yAxisType={'percentage'}
|
|
843
|
+
interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
|
|
844
|
+
duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
|
|
845
|
+
/>
|
|
846
|
+
</div>
|
|
847
|
+
|
|
848
|
+
<ChartLegend shape="line" direction="vertical" />
|
|
849
|
+
</ChartLegendWrapper>
|
|
850
|
+
);
|
|
851
|
+
},
|
|
852
|
+
};
|