@scality/core-ui 0.192.0 → 0.194.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.
Files changed (72) hide show
  1. package/dist/components/charts/barchart/Barchart.d.ts.map +1 -1
  2. package/dist/components/charts/barchart/Barchart.js +29 -19
  3. package/dist/components/charts/common/chartUtils.d.ts +7 -2
  4. package/dist/components/charts/common/chartUtils.d.ts.map +1 -1
  5. package/dist/components/charts/common/chartUtils.js +55 -20
  6. package/dist/components/charts/index.d.ts +1 -1
  7. package/dist/components/charts/index.d.ts.map +1 -1
  8. package/dist/components/charts/linetimeseries/LineTimeSerieChart.d.ts +12 -47
  9. package/dist/components/charts/linetimeseries/LineTimeSerieChart.d.ts.map +1 -1
  10. package/dist/components/charts/linetimeseries/LineTimeSerieChart.js +46 -220
  11. package/dist/components/charts/linetimeseries/LineTimeSerieChart.types.d.ts +77 -0
  12. package/dist/components/charts/linetimeseries/LineTimeSerieChart.types.d.ts.map +1 -0
  13. package/dist/components/charts/linetimeseries/LineTimeSerieChart.types.js +6 -0
  14. package/dist/components/charts/linetimeseries/LineTimeSerieChartTooltip.d.ts +18 -0
  15. package/dist/components/charts/linetimeseries/LineTimeSerieChartTooltip.d.ts.map +1 -0
  16. package/dist/components/charts/linetimeseries/LineTimeSerieChartTooltip.js +65 -0
  17. package/dist/components/charts/linetimeseries/useChartData.d.ts +44 -0
  18. package/dist/components/charts/linetimeseries/useChartData.d.ts.map +1 -0
  19. package/dist/components/charts/linetimeseries/useChartData.js +207 -0
  20. package/dist/components/charts/linetimeseries/useChartHover.d.ts +15 -0
  21. package/dist/components/charts/linetimeseries/useChartHover.d.ts.map +1 -0
  22. package/dist/components/charts/linetimeseries/useChartHover.js +29 -0
  23. package/dist/components/checkbox/Checkbox.component.d.ts.map +1 -1
  24. package/dist/components/checkbox/Checkbox.component.js +15 -7
  25. package/dist/components/constrainedtext/Constrainedtext.component.js +2 -2
  26. package/dist/components/dropdown/Dropdown.component.d.ts.map +1 -1
  27. package/dist/components/dropdown/Dropdown.component.js +3 -0
  28. package/dist/components/error-pages/ErrorPage401.component.js +1 -1
  29. package/dist/components/error-pages/ErrorPage404.component.js +1 -1
  30. package/dist/components/error-pages/ErrorPage500.component.js +1 -1
  31. package/dist/components/icon/CustomsIcons.d.ts +10 -0
  32. package/dist/components/icon/CustomsIcons.d.ts.map +1 -1
  33. package/dist/components/icon/CustomsIcons.js +8 -0
  34. package/dist/components/icon/Icon.component.d.ts +0 -1
  35. package/dist/components/icon/Icon.component.d.ts.map +1 -1
  36. package/dist/components/icon/Icon.component.js +5 -2
  37. package/dist/components/infomessage/InfoMessage.component.js +1 -1
  38. package/dist/components/tablev2/Tablestyle.d.ts.map +1 -1
  39. package/dist/components/tablev2/Tablestyle.js +2 -3
  40. package/dist/components/tooltip/Tooltip.component.js +1 -1
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +1 -0
  44. package/dist/utils.d.ts +14 -0
  45. package/dist/utils.d.ts.map +1 -1
  46. package/dist/utils.js +25 -0
  47. package/package.json +1 -1
  48. package/src/lib/components/charts/barchart/Barchart.tsx +123 -106
  49. package/src/lib/components/charts/common/chartUtils.test.ts +27 -12
  50. package/src/lib/components/charts/common/chartUtils.ts +67 -23
  51. package/src/lib/components/charts/index.ts +1 -1
  52. package/src/lib/components/charts/linetimeseries/LineTimeSerieChart.tsx +136 -516
  53. package/src/lib/components/charts/linetimeseries/LineTimeSerieChart.types.ts +93 -0
  54. package/src/lib/components/charts/linetimeseries/LineTimeSerieChartTooltip.tsx +137 -0
  55. package/src/lib/components/charts/linetimeseries/useChartData.ts +322 -0
  56. package/src/lib/components/charts/linetimeseries/useChartHover.ts +35 -0
  57. package/src/lib/components/checkbox/Checkbox.component.tsx +19 -20
  58. package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +2 -2
  59. package/src/lib/components/dropdown/Dropdown.component.tsx +3 -0
  60. package/src/lib/components/error-pages/ErrorPage401.component.tsx +1 -1
  61. package/src/lib/components/error-pages/ErrorPage404.component.tsx +1 -1
  62. package/src/lib/components/error-pages/ErrorPage500.component.tsx +1 -1
  63. package/src/lib/components/icon/CustomsIcons.tsx +36 -0
  64. package/src/lib/components/icon/Icon.component.tsx +9 -2
  65. package/src/lib/components/infomessage/InfoMessage.component.tsx +1 -1
  66. package/src/lib/components/tablev2/Tablestyle.tsx +2 -4
  67. package/src/lib/components/tooltip/Tooltip.component.tsx +1 -1
  68. package/src/lib/index.ts +1 -0
  69. package/src/lib/utils.ts +38 -0
  70. package/stories/GlobalHealthBar/globalhealthbar.stories.tsx +1 -1
  71. package/stories/banner.stories.tsx +1 -1
  72. package/stories/linetimeseriechart.stories.tsx +325 -6
@@ -36,7 +36,7 @@ function ErrorPage404({ locale = 'en', onReturnHomeClick, ...rest }: Props) {
36
36
  return (
37
37
  <ErrorPageContainer className="sc-error-page404" {...rest}>
38
38
  <Row>
39
- <Icon name="Exclamation-triangle" size="2x" color="statusWarning" />
39
+ <Icon name="Exclamation-circle" size="2x" color="statusWarning" />
40
40
  <Title>{translations[locale].not_exist}</Title>
41
41
  </Row>
42
42
  <Row>
@@ -49,7 +49,7 @@ function ErrorPage500({
49
49
  return (
50
50
  <ErrorPageContainer className="sc-error-page500" {...rest}>
51
51
  <Row>
52
- <Icon name="Exclamation-triangle" size="2x" color="statusWarning" />
52
+ <Icon name="Exclamation-circle" size="2x" color="statusWarning" />
53
53
  <Title>{translations[locale].unexpected_error}</Title>
54
54
  </Row>
55
55
  <Row>
@@ -50,3 +50,39 @@ export const RemoteGroup = ({ ariaLabel, color, size }) => {
50
50
  </svg>
51
51
  );
52
52
  };
53
+
54
+ export const Bucket = ({ ariaLabel, color, size }) => {
55
+ const getColor = useGetColor(color);
56
+ return (
57
+ <svg
58
+ viewBox="0 0 32 28"
59
+ fill="none"
60
+ xmlns="http://www.w3.org/2000/svg"
61
+ className={'svg-inline--fa ' + (size ? `fa-${size}` : '')}
62
+ aria-label={ariaLabel}
63
+ >
64
+ <path
65
+ d="M30.0239 0C31.2114 0 32.1489 1.125 31.9614 2.3125L28.5239 24.5625C28.2114 26.5625 26.5239 28 24.5239 28H7.46143C5.46143 28 3.77393 26.5625 3.52393 24.5625L0.0239303 2.3125C-0.16357 1.125 0.77393 0 2.02393 0H30.0239ZM27.6489 4H4.33643L6.21143 16H25.7739L27.6489 4Z"
66
+ fill={getColor}
67
+ />
68
+ </svg>
69
+ );
70
+ };
71
+
72
+ export const Buckets = ({ ariaLabel, color, size }) => {
73
+ const getColor = useGetColor(color);
74
+ return (
75
+ <svg
76
+ viewBox="0 0 37 28"
77
+ fill="none"
78
+ xmlns="http://www.w3.org/2000/svg"
79
+ className={'svg-inline--fa ' + (size ? `fa-${size}` : '')}
80
+ aria-label={ariaLabel}
81
+ >
82
+ <path
83
+ d="M35.1063 9.33301C35.9032 9.33313 36.5329 10.0834 36.4071 10.875L34.0995 25.708C33.8897 27.0412 32.7571 27.9999 31.4149 28H24.1278C26.417 27.5019 28.221 25.649 28.5985 23.2334V23.2305L29.0975 20H32.2538L33.5126 12H30.3329L30.745 9.33301H35.1063ZM28.0223 0C29.1305 0.000168028 30.0049 1.04998 29.8299 2.1582L26.6219 22.9248C26.3303 24.7915 24.7552 26.1338 22.8885 26.1338H6.96373C5.09707 26.1338 3.52226 24.7915 3.28893 22.9248L0.0223272 2.1582C-0.152604 1.04996 0.721996 0.000113715 1.88854 0H28.0223ZM4.04674 3.7334L5.79674 14.9336H24.0555L25.8055 3.7334H4.04674ZM22.4901 12H17.8671L18.0135 12.9336H15.2987L14.9725 10.875C14.8467 10.0834 15.4756 9.33323 16.3143 9.33301H22.9071L22.4901 12Z"
84
+ fill={getColor}
85
+ />
86
+ </svg>
87
+ );
88
+ };
@@ -10,7 +10,7 @@ import {
10
10
  import styled, { css } from 'styled-components';
11
11
  import { CoreUITheme } from '../../style/theme';
12
12
  import { Loader } from '../loader/Loader.component';
13
- import { RemoteGroup, RemoteUser } from './CustomsIcons';
13
+ import { Bucket, Buckets, RemoteGroup, RemoteUser } from './CustomsIcons';
14
14
 
15
15
  // Module-level cache for imported icons
16
16
  const iconCache: Record<string, any> = {};
@@ -24,7 +24,6 @@ export const iconTable = {
24
24
  'Node-pdf': 'fas faDatabase',
25
25
  'Volume-pdf': 'fas faCompactDisc',
26
26
  Network: 'fas faProjectDiagram',
27
- Bucket: 'fas faGlassWhiskey',
28
27
  'Cloud-backend': 'fas faCloud',
29
28
  Datacenter: 'fas faWarehouse',
30
29
  'Simple-user': 'fas faUser',
@@ -164,10 +163,18 @@ export const customIcons: Record<
164
163
  'Remote-group': ({ 'aria-label': ariaLabel, color, size }) => (
165
164
  <RemoteGroup ariaLabel={ariaLabel} color={color} size={size} />
166
165
  ),
166
+ Bucket: ({ 'aria-label': ariaLabel, color, size }) => (
167
+ <Bucket ariaLabel={ariaLabel} color={color} size={size} />
168
+ ),
169
+ Buckets: ({ 'aria-label': ariaLabel, color, size }) => (
170
+ <Buckets ariaLabel={ariaLabel} color={color} size={size} />
171
+ ),
167
172
  };
168
173
 
169
174
  customIcons['Remote-user'].displayName = 'RemoteUser';
170
175
  customIcons['Remote-group'].displayName = 'RemoteGroup';
176
+ customIcons['Bucket'].displayName = 'Bucket';
177
+ customIcons['Buckets'].displayName = 'Buckets';
171
178
 
172
179
  const IconStyled = styled(FontAwesomeIcon)`
173
180
  ${(props) => {
@@ -32,7 +32,7 @@ export const InfoMessage = ({ title, content, link, linkText }: Props) => {
32
32
  >
33
33
  <Stack>
34
34
  <Icon name="Info-circle" color={theme.infoPrimary} size="lg" />
35
- {typeof title === 'string' ? <Text isEmphazed>{title}</Text> : title}
35
+ {typeof title === 'string' ? <Text color="textPrimary" isEmphazed>{title}</Text> : title}
36
36
  </Stack>
37
37
  <Text color="textSecondary" isGentleEmphazed>
38
38
  {content}
@@ -8,7 +8,6 @@ import { HeaderGroup } from 'react-table';
8
8
  import { Icon } from '../icon/Icon.component';
9
9
  import { FocusVisibleStyle } from '../buttonv2/Buttonv2.component';
10
10
  import { spacing } from '../../spacing';
11
- import { Box } from '../box/Box';
12
11
 
13
12
  const borderSize = '4px';
14
13
  export const SortIncentive = styled.span`
@@ -65,7 +64,6 @@ export const HeadRow = styled.div<HeadRowType>`
65
64
  overflow: hidden;
66
65
  border-bottom: 1px solid
67
66
  ${(props) => props.theme[props.separationLineVariant]};
68
- padding-right: ${borderSize};
69
67
  padding-left: ${spacing.r16};
70
68
  `;
71
69
 
@@ -105,7 +103,7 @@ export const TableRow = styled.div<TableRowType>`
105
103
  if (props.selectedId && props.isSelected) {
106
104
  return css`
107
105
  background-color: ${props.theme.highlight};
108
- border-right: ${borderSize} solid ${props.theme.selectedActive};
106
+ box-shadow: inset -${borderSize} 0 0 ${props.theme.selectedActive};
109
107
  `;
110
108
  }
111
109
  }}
@@ -124,7 +122,7 @@ export const TableRowMultiSelectable = styled.div<TableRowMultiSelectableType>`
124
122
  if (props.isSelected) {
125
123
  return css`
126
124
  background-color: ${(props) => props.theme.highlight};
127
- border-right: ${borderSize} solid ${props.theme.selectedActive};
125
+ box-shadow: inset -${borderSize} 0 0 ${props.theme.selectedActive};
128
126
  `;
129
127
  }
130
128
  }}
@@ -58,7 +58,7 @@ const TooltipOverLayContainer = styled.div<{
58
58
  (props && props.style && props.style.fontSize) || fontSize.small};
59
59
  vertical-align: middle;
60
60
  padding: ${spacing.r4} ${spacing.r8};
61
- max-width: 40rem;
61
+ max-width: 20rem;
62
62
  `;
63
63
 
64
64
  const TooltipText = styled.div`
package/src/lib/index.ts CHANGED
@@ -79,3 +79,4 @@ export { InputList } from './components/inputlist/InputList.component';
79
79
  export { InlineInput } from './components/inlineinput/InlineInput';
80
80
  export { UnsuccessfulResult } from './components/UnsuccessfulResult.component';
81
81
  export { CoreUITheme } from './style/theme';
82
+ export { formatISONumber } from './utils';
package/src/lib/utils.ts CHANGED
@@ -55,3 +55,41 @@ export const convertRemToPixels = (rem: number): number => {
55
55
 
56
56
  return 0;
57
57
  };
58
+
59
+ type FormatISONumberOptions = {
60
+ decimals?: number;
61
+ compact?: boolean;
62
+ fixedDecimals?: boolean;
63
+ };
64
+
65
+ /**
66
+ * Formats a number to ISO 80000-1 format:
67
+ * - Space as thousands separator
68
+ * - Dot as decimal separator
69
+ * - Optional compact notation (10K, 1M, etc.)
70
+ * - Very small values (< 0.001): scientific notation
71
+ */
72
+ export const formatISONumber = (
73
+ value: number,
74
+ options: FormatISONumberOptions = {},
75
+ ): string => {
76
+ const { decimals = 2, compact = false, fixedDecimals = false } = options;
77
+
78
+ if (value === 0) return '0';
79
+
80
+ const absValue = Math.abs(value);
81
+
82
+ if (absValue < 0.001) {
83
+ return value.toExponential();
84
+ }
85
+
86
+ // ISO format: space as thousands separator, dot as decimal separator
87
+ // With optional compact notation (10K, 1M, etc.)
88
+ return new Intl.NumberFormat('fr-FR', {
89
+ minimumFractionDigits: fixedDecimals ? decimals : undefined,
90
+ maximumFractionDigits: decimals,
91
+ notation: compact ? 'compact' : 'standard',
92
+ })
93
+ .format(value)
94
+ .replace(',', '.');
95
+ };
@@ -9,7 +9,7 @@ import {
9
9
  type Story = StoryObj<GlobalHealthProps>;
10
10
 
11
11
  const meta: Meta<GlobalHealthProps> = {
12
- title: 'Components/DataDisplay/Charts/GlobalHealthBar',
12
+ title: 'Components/Data Display/Charts/GlobalHealthBar',
13
13
  component: GlobalHealthBar,
14
14
  };
15
15
  export default meta;
@@ -9,7 +9,7 @@ export default {
9
9
  component: Banner,
10
10
  decorators: [(story) => <Wrapper>{story()}</Wrapper>],
11
11
  args: {
12
- icon: 'Exclamation-triangle',
12
+ icon: 'Exclamation-circle',
13
13
  },
14
14
  argTypes: {
15
15
  icon: iconArgType,
@@ -11,10 +11,13 @@ import {
11
11
  import { lineTimeSeriesColorRange } from '../src/lib/style/theme';
12
12
  import { useEffect } from 'react';
13
13
  import {
14
+ SAMPLE_DURATION_LAST_ONE_HOUR,
14
15
  SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
16
+ SAMPLE_FREQUENCY_LAST_ONE_HOUR,
15
17
  SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS,
16
18
  } from '../src/lib/components/constants';
17
19
  import { Button } from '../src/lib/components/buttonv2/Buttonv2.component';
20
+ import { useTheme } from 'styled-components';
18
21
 
19
22
  const ChartWithProviders = (props) => {
20
23
  return (
@@ -71,10 +74,6 @@ const meta: Meta<typeof LineTimeSerieChart> = {
71
74
  options: ['default', 'percentage', 'symmetrical'],
72
75
  },
73
76
  yAxisTitle: { control: 'text' },
74
- timeFormat: {
75
- control: 'select',
76
- options: ['date-time', 'date'],
77
- },
78
77
  },
79
78
  };
80
79
 
@@ -638,7 +637,6 @@ export const DateFormatExample: Story = {
638
637
  duration:
639
638
  longTermPrometheusData[longTermPrometheusData.length - 1][0] -
640
639
  longTermPrometheusData[0][0],
641
- timeFormat: 'date',
642
640
  },
643
641
  };
644
642
 
@@ -719,6 +717,51 @@ export const SyncIdExample: Story = {
719
717
  interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
720
718
  duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
721
719
  />
720
+
721
+ <LineTimeSerieChart
722
+ syncId="sync-id"
723
+ series={[
724
+ {
725
+ data: prometheusData as [number, string | number | null][],
726
+ resource: 'ip-10-160-122-207.eu-north-1.compute.internal',
727
+ metricPrefix: 'cpu',
728
+ getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
729
+ },
730
+ ]}
731
+ title="CPU Usage"
732
+ height={200}
733
+ startingTimeStamp={Number(prometheusData[0][0])}
734
+ isLoading={false}
735
+ yAxisType={'percentage'}
736
+ interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
737
+ duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
738
+ />
739
+
740
+ <LineTimeSerieChart
741
+ syncId="sync-id"
742
+ series={[
743
+ {
744
+ data: prometheusData3 as [number, string | number | null][],
745
+ resource: 'ip-10-160-122-207.eu-north-1.compute.internal',
746
+ metricPrefix: 'memory',
747
+ getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
748
+ },
749
+ {
750
+ data: prometheusData4 as [number, string | number | null][],
751
+ resource: 'ip-10-160-122-207.eu-north-2.compute.internal',
752
+ metricPrefix: 'memory',
753
+ getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
754
+ },
755
+ ]}
756
+ title="Memory Usage"
757
+ height={200}
758
+ startingTimeStamp={Number(prometheusData3[0][0])}
759
+ isLoading={false}
760
+ yAxisType={'percentage'}
761
+ interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
762
+ duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
763
+ />
764
+
722
765
  <ChartLegend shape="line" direction="vertical" />
723
766
  </ChartLegendWrapper>
724
767
  );
@@ -744,7 +787,6 @@ export const CustomTooltipExample: Story = {
744
787
  yAxisTitle: '',
745
788
  interval: SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS,
746
789
  duration: SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
747
- timeFormat: 'date-time',
748
790
  renderTooltip: (props) => {
749
791
  return <div>Custom Tooltip</div>;
750
792
  },
@@ -849,3 +891,280 @@ export const DynamicColorSetExample: Story = {
849
891
  );
850
892
  },
851
893
  };
894
+
895
+ export const EmptyDataExample: Story = {
896
+ render: () => {
897
+ const theme = useTheme();
898
+ const now = Date.now() / 1000;
899
+
900
+ return (
901
+ <ChartLegendWrapper
902
+ // @ts-ignore
903
+ colorSet={{ Success: theme.statusHealthy, Failed: theme.statusCritical }}
904
+ sortOrder="status"
905
+ >
906
+ <LineTimeSerieChart
907
+ series={[]}
908
+ title="Empty Data - Last Hour"
909
+ height={150}
910
+ duration={60 * 60} // 1 hour
911
+ interval={60} // 1 minute
912
+ startingTimeStamp={now - 60 * 60}
913
+ isLoading={false}
914
+ yAxisType="default"
915
+ />
916
+ <ChartLegend shape="line" direction="vertical" />
917
+ </ChartLegendWrapper>
918
+ );
919
+ },
920
+ };
921
+
922
+
923
+ // Generate 1-hour data with 30s intervals, all zeros
924
+ const generateAllZeroValuesData = (): [number, string][] => {
925
+ const baseTimestamp = 1740405600;
926
+ const points: [number, string][] = [];
927
+ for (let i = 0; i <= 120; i++) {
928
+ const timestamp = baseTimestamp + i * 30;
929
+ points.push([timestamp, '0']);
930
+ }
931
+ return points;
932
+ };
933
+
934
+ const allZeroValuesData = generateAllZeroValuesData();
935
+
936
+ export const AllZeroValuesExample: Story = {
937
+ render: () => {
938
+ return (
939
+ <ChartLegendWrapper colorSet={{ 'server-1': lineTimeSeriesColorRange[0] }}>
940
+ <LineTimeSerieChart yAxisType='default' startingTimeStamp={allZeroValuesData[0][0]} interval={SAMPLE_FREQUENCY_LAST_ONE_HOUR} duration={SAMPLE_DURATION_LAST_ONE_HOUR}
941
+ series={[{ data: allZeroValuesData, resource: 'server-1', metricPrefix: 'bandwidth', getTooltipLabel: (prefix, resource) => `${resource}-${prefix}` }]} title="All Zero Values" height={200} />
942
+ </ChartLegendWrapper>
943
+ );
944
+ },
945
+ };
946
+
947
+ // Data with small values (below 1)
948
+ const smallValuesData: [number, string][] = [
949
+ [1740405600, '0.047'],
950
+ [1740406320, '0.053'],
951
+ [1740407760, '0.040'],
952
+ [1740408480, '0.059'],
953
+ [1740409200, '0.062'],
954
+ [1740409920, '0.057'],
955
+ [1740410640, '0.045'],
956
+ [1740411360, '0.058'],
957
+ [1740412080, '0.053'],
958
+ [1740412800, '0.064'],
959
+ [1740413520, '0.081'],
960
+ [1740414240, '0.064'],
961
+ [1740415680, '0.097'],
962
+ [1740416400, '0.055'],
963
+ [1740417120, '0.047'],
964
+ [1740417840, '0.072'],
965
+ [1740418560, '0.061'],
966
+ [1740419280, '0.051'],
967
+ [1740420000, '0.039'],
968
+ [1740420720, '0.046'],
969
+ [1740421440, '0.035'],
970
+ [1740422160, '0.046'],
971
+ [1740422880, '0.043'],
972
+ [1740423600, '0.036'],
973
+ [1740467520, '0.042'],
974
+ [1740468240, '0.053'],
975
+ [1740468960, '0.055'],
976
+ [1740469680, '0.046'],
977
+ [1740470400, '0.043'],
978
+ [1740471120, '0.055'],
979
+ [1740471840, '0.046'],
980
+ [1740472560, '0.047'],
981
+ [1740473280, '0.044'],
982
+ [1740474000, '0.055'],
983
+ [1740474720, '0.042'],
984
+ [1740475440, '0.061'],
985
+ [1740476160, '0.042'],
986
+ [1740476880, '0.038'],
987
+ [1740477600, '0.041'],
988
+ [1740478320, '0.052'],
989
+ [1740479040, '0.042'],
990
+ [1740479760, '0.034'],
991
+ [1740480480, '0.036'],
992
+ [1740481200, '0.037'],
993
+ [1740481920, '0.049'],
994
+ [1740482640, '0.041'],
995
+ [1740483360, '0.037'],
996
+ [1740484080, '0.035'],
997
+ [1740484800, '0.039'],
998
+ [1740485520, '0.047'],
999
+ [1740486240, '0.046'],
1000
+ [1740486960, '0.042'],
1001
+ [1740487680, '0.035'],
1002
+ [1740488400, '0.034'],
1003
+ [1740489120, '0.041'],
1004
+ [1740489840, '0.058'],
1005
+ [1740490560, '0.040'],
1006
+ [1740491280, '0.045'],
1007
+ [1740492000, '0.045'],
1008
+ ];
1009
+
1010
+ const verySmallValuesData: [number, string][] = [
1011
+ [1740405600, '0.00000475'],
1012
+ [1740406320, '0.00000530'],
1013
+ [1740407760, '0.00000401'],
1014
+ [1740408480, '0.00000591'],
1015
+ [1740409200, '0.00000624'],
1016
+ [1740409920, '0.00000574'],
1017
+ [1740410640, '0.00000451'],
1018
+ [1740411360, '0.00000586'],
1019
+ [1740412080, '0.00000530'],
1020
+ [1740412800, '0.00000649'],
1021
+ [1740413520, '0.00000812'],
1022
+ [1740414240, '0.00000648'],
1023
+ [1740415680, '0.00000671'],
1024
+ [1740416400, '0.00000552'],
1025
+ [1740417120, '0.00000479'],
1026
+ [1740417840, '0.00000721'],
1027
+ [1740418560, '0.00000619'],
1028
+ [1740419280, '0.00000510'],
1029
+ [1740420000, '0.00000395'],
1030
+ [1740420720, '0.00000469'],
1031
+ [1740421440, '0.00000350'],
1032
+ [1740422160, '0.00000466'],
1033
+ [1740422880, '0.00000435'],
1034
+ [1740423600, '0.00000367'],
1035
+ ];
1036
+
1037
+
1038
+
1039
+ export const SmallValuesExample: Story = {
1040
+ render: () => {
1041
+ return (
1042
+ <ChartLegendWrapper
1043
+ colorSet={{
1044
+ 'server-1': lineTimeSeriesColorRange[0],
1045
+ 'server-2': lineTimeSeriesColorRange[1],
1046
+ }}
1047
+ >
1048
+ <LineTimeSerieChart
1049
+ series={[
1050
+ {
1051
+ data: smallValuesData,
1052
+ resource: 'server-1',
1053
+ metricPrefix: 'rate',
1054
+ getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
1055
+ },
1056
+ ]}
1057
+ title="Small Values (0.003 - 0.008 range)"
1058
+ height={200}
1059
+ startingTimeStamp={smallValuesData[0][0]}
1060
+ isLoading={false}
1061
+ yAxisType={'default'}
1062
+ interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
1063
+ duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
1064
+ />
1065
+
1066
+ <LineTimeSerieChart
1067
+ series={[
1068
+ {
1069
+ data: verySmallValuesData,
1070
+ resource: 'server-2',
1071
+ metricPrefix: 'rate',
1072
+ getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
1073
+ },
1074
+ ]}
1075
+ title="Very Small Values (0.000003 - 0.000008 range)"
1076
+ height={200}
1077
+ startingTimeStamp={verySmallValuesData[0][0]}
1078
+ isLoading={false}
1079
+ yAxisType={'default'}
1080
+ interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
1081
+ duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
1082
+ />
1083
+ <ChartLegend shape="line" direction="vertical" />
1084
+ </ChartLegendWrapper>
1085
+ );
1086
+ },
1087
+ };
1088
+ // Generate 1-hour data with 30s intervals (120 points)
1089
+ const generateBigValuesData = (): [number, string][] => {
1090
+ const baseTimestamp = 1740405600;
1091
+ const points: [number, string][] = [];
1092
+ for (let i = 0; i <= 120; i++) {
1093
+ const timestamp = baseTimestamp + i * 30;
1094
+ // Exponential growth from 1000 to ~100M
1095
+ const value = Math.floor(1000 * Math.pow(1.1, i));
1096
+ points.push([timestamp, value.toString()]);
1097
+ }
1098
+ return points;
1099
+ };
1100
+
1101
+ const generateBigValuesData2 = (): [number, string][] => {
1102
+ const baseTimestamp = 1740405600;
1103
+ const points: [number, string][] = [];
1104
+ for (let i = 0; i <= 120; i++) {
1105
+ const timestamp = baseTimestamp + i * 30;
1106
+ // Fluctuating between 10000 and 15000 with random variation
1107
+ const value = 12500 + Math.sin(i * 0.2) * 2500 + Math.random() * 500;
1108
+ points.push([timestamp, value.toFixed(2)]);
1109
+ }
1110
+ return points;
1111
+ };
1112
+
1113
+ const bigValuesData = generateBigValuesData();
1114
+ const bigValuesData2 = generateBigValuesData2();
1115
+ export const BigValuesExample: Story = {
1116
+ render: () => {
1117
+ return (
1118
+ <ChartLegendWrapper
1119
+ colorSet={{
1120
+ 'server-1': lineTimeSeriesColorRange[0],
1121
+ 'server-2': lineTimeSeriesColorRange[1],
1122
+ }}
1123
+ >
1124
+ <LineTimeSerieChart
1125
+ series={[
1126
+ {
1127
+ data: bigValuesData2,
1128
+ resource: 'server-2',
1129
+ metricPrefix: 'bandwidth',
1130
+ getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
1131
+ },
1132
+ ]}
1133
+ title="Big Values"
1134
+ height={200}
1135
+ yAxisTitle='Big Number Example '
1136
+ startingTimeStamp={bigValuesData2[0][0]}
1137
+ isLoading={false}
1138
+ yAxisType={'default'}
1139
+ interval={SAMPLE_FREQUENCY_LAST_ONE_HOUR}
1140
+ duration={SAMPLE_DURATION_LAST_ONE_HOUR}
1141
+ />
1142
+ <LineTimeSerieChart
1143
+ series={[
1144
+ {
1145
+ data: bigValuesData2,
1146
+ resource: 'server-2',
1147
+ metricPrefix: 'bandwidth',
1148
+ getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
1149
+ },
1150
+ ]}
1151
+ title="Big Values"
1152
+ height={200}
1153
+ yAxisTitle='Big Number Example '
1154
+ startingTimeStamp={bigValuesData2[0][0]}
1155
+ isLoading={false}
1156
+ unitRange={UNIT_RANGE_BS}
1157
+ yAxisType={'default'}
1158
+ interval={SAMPLE_FREQUENCY_LAST_ONE_HOUR}
1159
+ duration={SAMPLE_DURATION_LAST_ONE_HOUR}
1160
+ />
1161
+ </ChartLegendWrapper>
1162
+ );
1163
+ },
1164
+ };
1165
+
1166
+
1167
+
1168
+
1169
+
1170
+