@scality/core-ui 0.186.0 → 0.187.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 (171) hide show
  1. package/dist/components/{linetemporalchart/MetricTimespanProvider.d.ts → charts/MetricsTimeSpanProvider.d.ts} +1 -1
  2. package/dist/components/charts/MetricsTimeSpanProvider.d.ts.map +1 -0
  3. package/dist/components/{barchartv2/Barchart.component.d.ts → charts/barchart/Barchart.d.ts} +2 -33
  4. package/dist/components/charts/barchart/Barchart.d.ts.map +1 -0
  5. package/dist/components/charts/barchart/Barchart.js +56 -0
  6. package/dist/components/{barchartv2/utils.d.ts → charts/barchart/Barchart.utils.d.ts} +8 -35
  7. package/dist/components/charts/barchart/Barchart.utils.d.ts.map +1 -0
  8. package/dist/components/{barchartv2/utils.js → charts/barchart/Barchart.utils.js} +7 -88
  9. package/dist/components/{barchartv2 → charts/barchart}/BarchartTooltip.d.ts +2 -1
  10. package/dist/components/charts/barchart/BarchartTooltip.d.ts.map +1 -0
  11. package/dist/components/{barchartv2 → charts/barchart}/BarchartTooltip.js +3 -3
  12. package/dist/components/{charttooltip → charts/common}/ChartTooltip.d.ts +9 -2
  13. package/dist/components/charts/common/ChartTooltip.d.ts.map +1 -0
  14. package/dist/components/{charttooltip → charts/common}/ChartTooltip.js +11 -15
  15. package/dist/components/charts/common/SharedComponents.d.ts +47 -0
  16. package/dist/components/charts/common/SharedComponents.d.ts.map +1 -0
  17. package/dist/components/charts/common/SharedComponents.js +73 -0
  18. package/dist/components/charts/common/chartUtils.d.ts +91 -0
  19. package/dist/components/charts/common/chartUtils.d.ts.map +1 -0
  20. package/dist/components/charts/common/chartUtils.js +243 -0
  21. package/dist/components/{globalhealthbar/GlobalHealthBarRecharts.component.d.ts → charts/globalhealthbar/GlobalHealthBar.d.ts} +2 -2
  22. package/dist/components/charts/globalhealthbar/GlobalHealthBar.d.ts.map +1 -0
  23. package/dist/components/{globalhealthbar/useHealthBarData.d.ts → charts/globalhealthbar/GlobalHealthBar.hooks.d.ts} +1 -1
  24. package/dist/components/charts/globalhealthbar/GlobalHealthBar.hooks.d.ts.map +1 -0
  25. package/dist/components/{globalhealthbar/GlobalHealthBarRecharts.component.js → charts/globalhealthbar/GlobalHealthBar.js} +4 -4
  26. package/dist/components/{globalhealthbar/healthBarUtils.d.ts → charts/globalhealthbar/GlobalHealthBar.utils.d.ts} +1 -1
  27. package/dist/components/charts/globalhealthbar/GlobalHealthBar.utils.d.ts.map +1 -0
  28. package/dist/components/{globalhealthbar/healthBarUtils.js → charts/globalhealthbar/GlobalHealthBar.utils.js} +1 -1
  29. package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.d.ts +1 -1
  30. package/dist/components/charts/globalhealthbar/GlobalHealthBarTooltip.d.ts.map +1 -0
  31. package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.js +7 -3
  32. package/dist/components/charts/globalhealthbar/HealthBarXAxis.d.ts.map +1 -0
  33. package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.js +1 -1
  34. package/dist/components/charts/index.d.ts +16 -0
  35. package/dist/components/charts/index.d.ts.map +1 -0
  36. package/dist/components/charts/index.js +15 -0
  37. package/dist/components/{chartlegend → charts/legend}/ChartLegend.d.ts +1 -1
  38. package/dist/components/charts/legend/ChartLegend.d.ts.map +1 -0
  39. package/dist/components/{chartlegend → charts/legend}/ChartLegend.js +2 -2
  40. package/dist/components/{chartlegend → charts/legend}/ChartLegendWrapper.d.ts +1 -1
  41. package/dist/components/charts/legend/ChartLegendWrapper.d.ts.map +1 -0
  42. package/dist/components/{linetimeseriechart/linetimeseriechart.component.d.ts → charts/linetimeseries/LineTimeSerieChart.d.ts} +12 -2
  43. package/dist/components/charts/linetimeseries/LineTimeSerieChart.d.ts.map +1 -0
  44. package/dist/components/{linetimeseriechart/linetimeseriechart.component.js → charts/linetimeseries/LineTimeSerieChart.js} +34 -35
  45. package/dist/components/charts/linetimeseries/LineTimeSerieChart.utils.d.ts +14 -0
  46. package/dist/components/charts/linetimeseries/LineTimeSerieChart.utils.d.ts.map +1 -0
  47. package/dist/components/{linetimeseriechart/utils.js → charts/linetimeseries/LineTimeSerieChart.utils.js} +4 -6
  48. package/dist/components/charts/sparkline/Sparkline.d.ts +23 -0
  49. package/dist/components/charts/sparkline/Sparkline.d.ts.map +1 -0
  50. package/dist/components/{sparkline/sparkline.component.js → charts/sparkline/Sparkline.js} +12 -6
  51. package/dist/components/charts/types.d.ts +34 -0
  52. package/dist/components/charts/types.d.ts.map +1 -0
  53. package/dist/components/charts/types.js +4 -0
  54. package/dist/components/icon/Icon.component.d.ts +1 -0
  55. package/dist/components/icon/Icon.component.d.ts.map +1 -1
  56. package/dist/components/icon/Icon.component.js +2 -2
  57. package/dist/components/textbadge/TextBadge.component.d.ts +1 -1
  58. package/dist/components/textbadge/TextBadge.component.d.ts.map +1 -1
  59. package/dist/index.d.ts +0 -2
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +4 -2
  62. package/dist/next.d.ts +3 -11
  63. package/dist/next.d.ts.map +1 -1
  64. package/dist/next.js +4 -11
  65. package/package.json +2 -6
  66. package/src/lib/components/{barchartv2/Barchart.component.test.tsx → charts/barchart/Barchart.test.tsx} +35 -10
  67. package/src/lib/components/{barchartv2/Barchart.component.tsx → charts/barchart/Barchart.tsx} +42 -207
  68. package/src/lib/components/{barchartv2/utils.test.ts → charts/barchart/Barchart.utils.test.ts} +2 -141
  69. package/src/lib/components/{barchartv2/utils.ts → charts/barchart/Barchart.utils.ts} +17 -143
  70. package/src/lib/components/{barchartv2 → charts/barchart}/BarchartTooltip.tsx +5 -9
  71. package/src/lib/components/{charttooltip → charts/common}/ChartTooltip.tsx +13 -20
  72. package/src/lib/components/charts/common/SharedComponents.tsx +180 -0
  73. package/src/lib/components/charts/common/chartUtils.test.ts +402 -0
  74. package/src/lib/components/charts/common/chartUtils.ts +334 -0
  75. package/src/lib/components/{globalhealthbar/useHealthBarData.spec.tsx → charts/globalhealthbar/GlobalHealthBar.hooks.test.tsx} +1 -1
  76. package/src/lib/components/{globalhealthbar/GlobalHealthBarRecharts.component.tsx → charts/globalhealthbar/GlobalHealthBar.tsx} +4 -4
  77. package/src/lib/components/{globalhealthbar/healthBarUtils.spec.ts → charts/globalhealthbar/GlobalHealthBar.utils.test.ts} +1 -1
  78. package/src/lib/components/{globalhealthbar/healthBarUtils.ts → charts/globalhealthbar/GlobalHealthBar.utils.ts} +1 -1
  79. package/src/lib/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.tsx +8 -4
  80. package/src/lib/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.tsx +1 -1
  81. package/src/lib/components/charts/index.ts +59 -0
  82. package/src/lib/components/{chartlegend → charts/legend}/ChartLegend.tsx +2 -2
  83. package/src/lib/components/{chartlegend → charts/legend}/ChartLegendWrapper.tsx +1 -1
  84. package/src/lib/components/{linetimeseriechart/linetimeseriechart.test.tsx → charts/linetimeseries/LineTimeSerieChart.test.tsx} +3 -6
  85. package/src/lib/components/{linetimeseriechart/linetimeseriechart.component.tsx → charts/linetimeseries/LineTimeSerieChart.tsx} +48 -44
  86. package/src/lib/components/{linetimeseriechart/utils.test.ts → charts/linetimeseries/LineTimeSerieChart.utils.test.ts} +1 -1
  87. package/src/lib/components/{linetimeseriechart/utils.ts → charts/linetimeseries/LineTimeSerieChart.utils.ts} +4 -6
  88. package/src/lib/components/charts/sparkline/Sparkline.tsx +80 -0
  89. package/src/lib/components/charts/types.ts +36 -0
  90. package/src/lib/components/icon/Icon.component.tsx +12 -8
  91. package/src/lib/components/textbadge/TextBadge.component.tsx +1 -1
  92. package/src/lib/index.ts +4 -2
  93. package/src/lib/next.ts +26 -13
  94. package/stories/BarChart/barchart.stories.tsx +10 -9
  95. package/stories/GlobalHealthBar/{globalhealthbarRecharts.stories.tsx → globalhealthbar.stories.tsx} +3 -21
  96. package/stories/GlobalHealthBar/globalheathbarrecharts.guideline.mdx +2 -2
  97. package/stories/guideline/chart-guideline.mdx +1 -38
  98. package/stories/linetimeseriechart.stories.tsx +4 -6
  99. package/stories/sparkline.stories.tsx +13 -11
  100. package/stories/textbadge.stories.tsx +15 -0
  101. package/dist/components/barchart/BarChart.component.d.ts +0 -17
  102. package/dist/components/barchart/BarChart.component.d.ts.map +0 -1
  103. package/dist/components/barchart/BarChart.component.js +0 -27
  104. package/dist/components/barchartv2/Barchart.component.d.ts.map +0 -1
  105. package/dist/components/barchartv2/Barchart.component.js +0 -122
  106. package/dist/components/barchartv2/BarchartTooltip.d.ts.map +0 -1
  107. package/dist/components/barchartv2/utils.d.ts.map +0 -1
  108. package/dist/components/chartlegend/ChartLegend.d.ts.map +0 -1
  109. package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +0 -1
  110. package/dist/components/charttooltip/ChartTooltip.d.ts.map +0 -1
  111. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts +0 -23
  112. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts.map +0 -1
  113. package/dist/components/globalhealthbar/GlobalHealthBar.component.js +0 -173
  114. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts.map +0 -1
  115. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts.map +0 -1
  116. package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts.map +0 -1
  117. package/dist/components/globalhealthbar/healthBarUtils.d.ts.map +0 -1
  118. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts +0 -2
  119. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts.map +0 -1
  120. package/dist/components/globalhealthbar/healthBarUtils.spec.js +0 -391
  121. package/dist/components/globalhealthbar/tooltip/index.d.ts +0 -8
  122. package/dist/components/globalhealthbar/tooltip/index.d.ts.map +0 -1
  123. package/dist/components/globalhealthbar/tooltip/index.js +0 -55
  124. package/dist/components/globalhealthbar/useHealthBarData.d.ts.map +0 -1
  125. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts +0 -2
  126. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts.map +0 -1
  127. package/dist/components/globalhealthbar/useHealthBarData.spec.js +0 -209
  128. package/dist/components/linetemporalchart/ChartUtil.d.ts +0 -41
  129. package/dist/components/linetemporalchart/ChartUtil.d.ts.map +0 -1
  130. package/dist/components/linetemporalchart/ChartUtil.js +0 -148
  131. package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts +0 -46
  132. package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +0 -1
  133. package/dist/components/linetemporalchart/LineTemporalChart.component.js +0 -579
  134. package/dist/components/linetemporalchart/MetricTimespanProvider.d.ts.map +0 -1
  135. package/dist/components/linetemporalchart/tooltip/index.d.ts +0 -30
  136. package/dist/components/linetemporalchart/tooltip/index.d.ts.map +0 -1
  137. package/dist/components/linetemporalchart/tooltip/index.js +0 -104
  138. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +0 -1
  139. package/dist/components/linetimeseriechart/utils.d.ts +0 -16
  140. package/dist/components/linetimeseriechart/utils.d.ts.map +0 -1
  141. package/dist/components/sparkline/sparkline.component.d.ts +0 -17
  142. package/dist/components/sparkline/sparkline.component.d.ts.map +0 -1
  143. package/dist/components/vegachartv2/SyncedCursorCharts.d.ts +0 -12
  144. package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +0 -1
  145. package/dist/components/vegachartv2/SyncedCursorCharts.js +0 -15
  146. package/dist/components/vegachartv2/VegaChartV2.component.d.ts +0 -15
  147. package/dist/components/vegachartv2/VegaChartV2.component.d.ts.map +0 -1
  148. package/dist/components/vegachartv2/VegaChartV2.component.js +0 -218
  149. package/src/lib/components/barchart/BarChart.component.tsx +0 -51
  150. package/src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx +0 -204
  151. package/src/lib/components/globalhealthbar/tooltip/index.ts +0 -72
  152. package/src/lib/components/linetemporalchart/ChartUtil.test.ts +0 -250
  153. package/src/lib/components/linetemporalchart/ChartUtil.ts +0 -225
  154. package/src/lib/components/linetemporalchart/LineTemporalChart.component.tsx +0 -800
  155. package/src/lib/components/linetemporalchart/tooltip/index.ts +0 -178
  156. package/src/lib/components/sparkline/sparkline.component.tsx +0 -56
  157. package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +0 -28
  158. package/src/lib/components/vegachartv2/VegaChartV2.component.tsx +0 -276
  159. package/stories/barchart.stories.tsx +0 -142
  160. package/stories/globalhealthbar.stories.tsx +0 -191
  161. package/stories/guideline/mdxExampleComponents.tsx +0 -57
  162. package/stories/linecharttemporal.stories.tsx +0 -88
  163. /package/dist/components/{linetemporalchart/MetricTimespanProvider.js → charts/MetricsTimeSpanProvider.js} +0 -0
  164. /package/dist/components/{globalhealthbar/useHealthBarData.js → charts/globalhealthbar/GlobalHealthBar.hooks.js} +0 -0
  165. /package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.d.ts +0 -0
  166. /package/dist/components/{chartlegend → charts/legend}/ChartLegendWrapper.js +0 -0
  167. /package/src/lib/components/{linetemporalchart/MetricTimespanProvider.tsx → charts/MetricsTimeSpanProvider.tsx} +0 -0
  168. /package/src/lib/components/{barchartv2 → charts/barchart}/BarchartTooltip.test.tsx +0 -0
  169. /package/src/lib/components/{globalhealthbar/useHealthBarData.ts → charts/globalhealthbar/GlobalHealthBar.hooks.ts} +0 -0
  170. /package/src/lib/components/{chartlegend → charts/legend}/ChartLegend.test.tsx +0 -0
  171. /package/src/lib/components/{chartlegend → charts/legend}/ChartLegendWrapper.test.tsx +0 -0
@@ -0,0 +1,243 @@
1
+ import { NAN_STRING } from '../../constants';
2
+ /* -------------------------------------------------------------------------- */
3
+ /* constants */
4
+ /* -------------------------------------------------------------------------- */
5
+ export const maxWidthTooltip = { maxWidth: '20rem' };
6
+ /* -------------------------------------------------------------------------- */
7
+ /* utils functions */
8
+ /* -------------------------------------------------------------------------- */
9
+ /**
10
+ * Round a value to a nice number for chart display
11
+ * Used by Barchart and LineTimeSerieChart for Y-axis scaling
12
+ */
13
+ export const getRoundReferenceValue = (value) => {
14
+ if (value <= 0)
15
+ return 1; // Default for zero or negative values
16
+ // Buffer the value by 10% to avoid being too close to the edge of the chart
17
+ const bufferedValue = value * 1.1;
18
+ if (value >= 10) {
19
+ const remainder = value % 10;
20
+ const incremented = value + (10 - remainder);
21
+ // If the remainder is less than 5, round down to the nearest 10
22
+ if (remainder < 5) {
23
+ return value - remainder;
24
+ }
25
+ // If incrementing would exceed the buffered max, also round down
26
+ if (incremented > bufferedValue) {
27
+ return value - remainder;
28
+ }
29
+ // Otherwise, round up to the next 10
30
+ return incremented;
31
+ }
32
+ const magnitude = Math.pow(10, Math.floor(Math.log10(value)));
33
+ const remainder = bufferedValue % magnitude;
34
+ // Round to nice numbers based on normalized value
35
+ // appearance for small values
36
+ return remainder === 0 ? bufferedValue : bufferedValue - remainder;
37
+ };
38
+ /**
39
+ * Generate tick values for Y-axis
40
+ * Used by Barchart and LineTimeSerieChart
41
+ */
42
+ export const getTicks = (topValue, isSymmetrical) => {
43
+ const possibleTickNumbers = [4, 3];
44
+ const numberOfTicks = possibleTickNumbers.find((number) => topValue % (number - 1) === 0) || 3; // Default to 3 ticks if no match
45
+ const tickInterval = topValue / (numberOfTicks - 1);
46
+ const ticks = Array.from({ length: numberOfTicks }, (_, index) => index * tickInterval);
47
+ if (isSymmetrical) {
48
+ // Create negative ticks in order without 0
49
+ const negativeTicks = Array.from({ length: numberOfTicks - 1 }, (_, index) => (index - numberOfTicks + 1) * tickInterval);
50
+ ticks.unshift(...negativeTicks);
51
+ }
52
+ return ticks;
53
+ };
54
+ /**
55
+ * Return the unit label based on the current dataset, and the valueBase which is used to convert the data
56
+ * Used by LineTimeSerieChart
57
+ * @param unitRange - Array of threshold and label pairs
58
+ * @param maxValue - The maximum value among the data set
59
+ * @returns Object with valueBase and unitLabel
60
+ */
61
+ export function getUnitLabel(unitRange, maxValue) {
62
+ if (!unitRange || unitRange.length === 0) {
63
+ return {
64
+ valueBase: 1,
65
+ unitLabel: undefined,
66
+ };
67
+ }
68
+ // first sort the unitRange
69
+ unitRange.sort((unitA, unitB) => {
70
+ return unitA.threshold - unitB.threshold;
71
+ });
72
+ let index = unitRange.findIndex((range) => range.threshold > maxValue);
73
+ // last unit
74
+ if (index === -1) {
75
+ index = unitRange.length;
76
+ }
77
+ if (index === 0) {
78
+ return {
79
+ valueBase: unitRange[index].threshold || 1,
80
+ unitLabel: unitRange[index].label,
81
+ };
82
+ }
83
+ return {
84
+ // if the threshold is 0, we use 1 as the value base to avoid division by 0
85
+ valueBase: unitRange[index - 1].threshold || 1,
86
+ unitLabel: unitRange[index - 1].label,
87
+ };
88
+ }
89
+ /**
90
+ * Computes unit label and normalizes chart data based on unit range.
91
+ * This is shared logic used by both Barchart and LineTimeSerieChart.
92
+ *
93
+ * @param data - Chart data to normalize
94
+ * @param maxValue - Maximum value in the dataset
95
+ * @param unitRange - Optional unit range configuration for automatic scaling
96
+ * @param excludeKey - Key to exclude from normalization (e.g., 'category' for Barchart, 'timestamp' for LineTimeSerieChart)
97
+ * @returns Object containing unit label, top value for Y-axis, and normalized data
98
+ */
99
+ export const normalizeChartDataWithUnits = (data, maxValue, unitRange, excludeKey) => {
100
+ // If no unit range provided, just calculate top value without unit conversion
101
+ if (!unitRange || unitRange.length === 0) {
102
+ const topValue = getRoundReferenceValue(maxValue);
103
+ return {
104
+ unitLabel: undefined,
105
+ topValue,
106
+ rechartsData: data,
107
+ topDomain: maxValue * 1.1,
108
+ };
109
+ }
110
+ // Get appropriate unit and value base for normalization
111
+ const { valueBase, unitLabel } = getUnitLabel(unitRange, maxValue);
112
+ const basedValue = maxValue / valueBase;
113
+ const topValue = getRoundReferenceValue(basedValue);
114
+ const topDomain = basedValue * 1.1;
115
+ // Normalize all numeric values by dividing by valueBase
116
+ const rechartsData = data.map((dataPoint) => {
117
+ const normalizedDataPoint = {
118
+ ...dataPoint,
119
+ };
120
+ Object.entries(dataPoint).forEach(([key, value]) => {
121
+ if (key !== excludeKey && typeof value === 'number') {
122
+ normalizedDataPoint[key] = value / valueBase;
123
+ }
124
+ });
125
+ return normalizedDataPoint;
126
+ });
127
+ return { unitLabel, topValue, rechartsData, topDomain };
128
+ };
129
+ /**
130
+ * This function manually adds the missing data points with `null` value caused by downtime of the VMs
131
+ * Missing data points are only added when the gap between consecutive data points is bigger than 2 intervals
132
+ * Used by LineTimeSerieChart and Sparkline
133
+ *
134
+ * @param orginalValues - The array of the data points are already sorted according to the time series
135
+ * @param startingTimeStamp - The starting timestamp in seconds
136
+ * @param sampleDuration - The time span value in seconds
137
+ * @param sampleInterval - The time difference between two data points in seconds
138
+ */
139
+ export function addMissingDataPoint(originalValues, startingTimeStamp, sampleDuration, sampleInterval) {
140
+ if (!originalValues ||
141
+ startingTimeStamp === undefined ||
142
+ !sampleDuration ||
143
+ !sampleInterval ||
144
+ startingTimeStamp < 0 ||
145
+ sampleDuration <= 0 ||
146
+ sampleInterval <= 0) {
147
+ return [];
148
+ }
149
+ // If there are no original values, return empty array
150
+ if (originalValues.length === 0) {
151
+ return [];
152
+ }
153
+ const newValues = [];
154
+ // add missing data points for the starting time
155
+ for (let i = startingTimeStamp; i < originalValues[0][0]; i += sampleInterval) {
156
+ newValues.push([i, NAN_STRING]);
157
+ }
158
+ // Process all but the last element
159
+ for (let i = 0; i < originalValues.length - 1; i++) {
160
+ if (originalValues[i][0] < startingTimeStamp ||
161
+ originalValues[i][0] > startingTimeStamp + sampleDuration) {
162
+ continue;
163
+ }
164
+ // Always add the current data point
165
+ newValues.push(originalValues[i]);
166
+ const currentTimestamp = originalValues[i][0];
167
+ const nextTimestamp = originalValues[i + 1][0];
168
+ const gap = nextTimestamp - currentTimestamp;
169
+ // Calculate how many missing points to add
170
+ const missingIntervals = Math.floor(gap / sampleInterval) - 1;
171
+ // Add missing data points with NAN_STRING (only executes if missingIntervals > 0)
172
+ for (let j = 1; j <= missingIntervals; j++) {
173
+ const missingTimestamp = currentTimestamp + j * sampleInterval;
174
+ newValues.push([missingTimestamp, NAN_STRING]);
175
+ }
176
+ }
177
+ // Add the last element
178
+ newValues.push(originalValues[originalValues.length - 1]);
179
+ // add missing data points for the ending time
180
+ for (let i = originalValues[originalValues.length - 1][0] + sampleInterval; i < startingTimeStamp + sampleDuration; i += sampleInterval) {
181
+ newValues.push([i, NAN_STRING]);
182
+ }
183
+ return newValues;
184
+ }
185
+ /**
186
+ * Date Format Reference Table
187
+ * ============================
188
+ *
189
+ * This table documents the date formatting logic used across charts:
190
+ * - X-Axis Format: Used for chart axis labels (formatXAxisDate + LineTimeSerieChart's formatXAxisLabel)
191
+ * - Tooltip Format: Used for tooltip headers (getTooltipDateFormat)
192
+ *
193
+ * ┌─────────────────┬──────────────┬────────────────────────┬──────────────────┬──────────────────────────────────────────┬───────────────────────────┐
194
+ * │ Interval │ Duration (s) │ X-axis format │ Example (X-axis) │ Tooltip format │ Example (Tooltip) │
195
+ * ├─────────────────┼──────────────┼────────────────────────┼──────────────────┼──────────────────────────────────────────┼───────────────────────────┤
196
+ * │ Last hour │ ≤ 3,600 │ HH:MM │ 14:05 │ DD MMM HH:MM:SS │ 01 Oct 00:15:00 │
197
+ * │ Last 24 hours │ ≤ 86,400 │ HH:MM │ 23:00 │ DD MMM HH:MM │ 01 Oct 00:15 │
198
+ * │ Last 7 days │ ≤ 604,800 │ DD MMM HH:MM │ 27 Sep 10:12 │ DD MMM HH:MM │ 01 Oct 00:15 │
199
+ * │ Long term │ > 604,800 │ DDMMMYY │ 15Sep25 │ DD MMM YYYY HH:MM │ 01 Oct 2025 00:15 │
200
+ * └─────────────────┴──────────────┴────────────────────────┴──────────────────┴──────────────────────────────────────────┴───────────────────────────┘
201
+ *
202
+ * Note: Duration is in seconds. Some intervals share the same format, which is why both functions only have 3 cases.
203
+ */
204
+ /**
205
+ * Get the format of the date based on the duration
206
+ * Used by Barchart CustomTick component
207
+ * @param duration - Duration in seconds
208
+ * @returns Formatted string type
209
+ */
210
+ export const formatXAxisDate = (duration) => {
211
+ if (duration <= 24 * 60 * 60) {
212
+ return 'time';
213
+ }
214
+ else if (duration <= 7 * 24 * 60 * 60) {
215
+ return 'day-month-abbreviated';
216
+ }
217
+ else {
218
+ return 'chart-long-term-date';
219
+ }
220
+ };
221
+ /**
222
+ * Get the format of the date based on the duration
223
+ * Used by TooltipHeader component
224
+ * @param duration - Duration in seconds
225
+ * @returns Formatted string type
226
+ */
227
+ export const getTooltipDateFormat = (duration) => {
228
+ if (duration <= 60 * 60) {
229
+ return 'day-month-abbreviated-hour-minute-second';
230
+ }
231
+ else if (duration <= 7 * 24 * 60 * 60) {
232
+ return 'day-month-abbreviated-hour-minute';
233
+ }
234
+ else {
235
+ return 'day-month-abbreviated-year-hour-minute';
236
+ }
237
+ };
238
+ export const formatToISONumber = (value) => {
239
+ const formattedValue = new Intl.NumberFormat('fr-FR')
240
+ .format(value)
241
+ .replace(',', '.');
242
+ return formattedValue;
243
+ };
@@ -1,4 +1,4 @@
1
- import { Alert } from './useHealthBarData';
1
+ import { Alert } from './GlobalHealthBar.hooks';
2
2
  export interface GlobalHealthProps {
3
3
  id: string;
4
4
  alerts: Alert[];
@@ -7,4 +7,4 @@ export interface GlobalHealthProps {
7
7
  }
8
8
  export declare function GlobalHealthBar({ id, alerts, start, end }: GlobalHealthProps): import("react/jsx-runtime").JSX.Element;
9
9
  export type { Alert };
10
- //# sourceMappingURL=GlobalHealthBarRecharts.component.d.ts.map
10
+ //# sourceMappingURL=GlobalHealthBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalHealthBar.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/charts/globalhealthbar/GlobalHealthBar.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,EAAoB,MAAM,yBAAyB,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX;AAUD,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,iBAAiB,2CAkN5E;AAGD,YAAY,EAAE,KAAK,EAAE,CAAC"}
@@ -16,4 +16,4 @@ export declare const useHealthBarData: (alerts: Alert[], startTimestamp: number,
16
16
  unavailableKeys: string[];
17
17
  };
18
18
  };
19
- //# sourceMappingURL=useHealthBarData.d.ts.map
19
+ //# sourceMappingURL=GlobalHealthBar.hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalHealthBar.hooks.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/charts/globalhealthbar/GlobalHealthBar.hooks.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,KAAK;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,aAAa,CAAC;IACjD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,gBAAgB,WACnB,KAAK,EAAE,kBACC,MAAM,gBACR,MAAM,MAChB,MAAM;;;;;;;;;;CA6DX,CAAC"}
@@ -2,10 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useMemo, useRef, useState } from 'react';
3
3
  import { Bar, BarChart, ResponsiveContainer, Tooltip, YAxis, } from 'recharts';
4
4
  import styled, { useTheme } from 'styled-components';
5
- import { GlobalHealthBarTooltip } from './components/GlobalHealthBarTooltip';
6
- import { HealthBarXAxis } from './components/HealthBarXAxis';
7
- import { CHART_CONFIG, getNavigationAction, getNavigationStateUpdate, } from './healthBarUtils';
8
- import { useHealthBarData } from './useHealthBarData';
5
+ import { GlobalHealthBarTooltip } from './GlobalHealthBarTooltip';
6
+ import { HealthBarXAxis } from './HealthBarXAxis';
7
+ import { CHART_CONFIG, getNavigationAction, getNavigationStateUpdate, } from './GlobalHealthBar.utils';
8
+ import { useHealthBarData } from './GlobalHealthBar.hooks';
9
9
  const ChartInteractiveContainer = styled.div `
10
10
  position: relative;
11
11
  outline: none;
@@ -74,4 +74,4 @@ export declare const getTooltipPosition: (alert: {
74
74
  startsAt: string;
75
75
  endsAt: string;
76
76
  }, startTimestamp: number, endTimestamp: number, chartUsableWidth: number) => number;
77
- //# sourceMappingURL=healthBarUtils.d.ts.map
77
+ //# sourceMappingURL=GlobalHealthBar.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalHealthBar.utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/charts/globalhealthbar/GlobalHealthBar.utils.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;CAWf,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;CAOjB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;CAOf,CAAC;AA4BX,eAAO,MAAM,sBAAsB,iBAAkB,MAAM,KAAG,MAAM,EAInE,CAAC;AAEF,eAAO,MAAM,iBAAiB,iBAAkB,MAAM,KAAG,MAAM,EAM9D,CAAC;AAEF,eAAO,MAAM,kBAAkB,iBAAkB,MAAM,KAAG,MAAM,EAO/D,CAAC;AAEF,eAAO,MAAM,aAAa,UACjB,MAAM,cACD,MAAM,aACP,OAAO,KACjB,MAKF,CAAC;AAEF,eAAO,MAAM,QAAQ,mBACH,MAAM,gBACR,MAAM,KACnB,MAAM,EAYR,CAAC;AAMF,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,wBAAwB,eACvB,MAAM,cACN,MAAM,QACZ,MAAM,SACL,MAAM,gBACC,MAAM,KACnB,OA+BF,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,sBAAsB,wBACZ,MAAM,qBACR,MAAM,uBACJ,MAAM,qBACR,MAAM,kBACT,MAAM,UACf,MAAM;;;;CAkBd,CAAC;AAMF,MAAM,MAAM,gBAAgB,GACxB,UAAU,GACV,MAAM,GACN,OAAO,GACP,MAAM,GACN,QAAQ,CAAC;AAEb,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,GAAG,GAAG,IAAI,CAAC;IAC1B,sBAAsB,EAAE,OAAO,CAAC;CACjC;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAS,MAAM,KAAG,gBAAgB,GAAG,IAiBpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,WAC3B,gBAAgB,gBACV,MAAM,eACP,MAAM,KAClB,MAiBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,UAChC,gBAAgB,gBACV,MAAM,UACZ,CAAC,EAAE,KACV,eAYF,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,kBAAkB,UACtB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,kBAC3B,MAAM,gBACR,MAAM,oBACF,MAAM,WAgBzB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { fontSize } from '../../style/theme';
1
+ import { fontSize } from '../../../style/theme';
2
2
  // =============================================================================
3
3
  // CONSTANTS
4
4
  // =============================================================================
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { Alert } from '../GlobalHealthBarRecharts.component';
3
2
  import { TooltipContentProps } from 'recharts';
3
+ import { Alert } from './GlobalHealthBar.hooks';
4
4
  interface GlobalHealthBarTooltipProps {
5
5
  tooltipData: Alert | null;
6
6
  coordinate?: {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalHealthBarTooltip.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/charts/globalhealthbar/GlobalHealthBarTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAM/C,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAKhD,UAAU,2BAA2B;IACnC,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,YAAY,EAAE,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACnD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAoBD,eAAO,MAAM,sBAAsB,UAAW,2BAA2B,mDA6FxE,CAAC"}
@@ -1,9 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled, { css, useTheme } from 'styled-components';
3
- import { FormattedDateTime, Stack, Text, Wrap, spacing } from '../../../index';
3
+ import { FormattedDateTime } from '../../date/FormattedDateTime';
4
+ import { Stack } from '../../../spacing';
5
+ import { Text } from '../../text/Text.component';
6
+ import { Wrap } from '../../../spacing';
7
+ import { spacing } from '../../../spacing';
4
8
  import { zIndex } from '../../../style/theme';
5
- import { CHART_CONFIG, getTooltipPosition } from '../healthBarUtils';
6
- import { ChartTooltipPortal } from '../../charttooltip/ChartTooltip';
9
+ import { CHART_CONFIG, getTooltipPosition } from './GlobalHealthBar.utils';
10
+ import { ChartTooltipPortal } from '../common/ChartTooltip';
7
11
  const TooltipContainer = styled.div `
8
12
  ${(props) => {
9
13
  const theme = useTheme();
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HealthBarXAxis.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/charts/globalhealthbar/HealthBarXAxis.tsx"],"names":[],"mappings":"AAWA,UAAU,mBAAmB;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AAiDD,eAAO,MAAM,cAAc,sCAGxB,mBAAmB,4CA4BrB,CAAC"}
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { XAxis } from 'recharts';
3
3
  import { useTheme } from 'styled-components';
4
4
  import { fontSize } from '../../../style/theme';
5
- import { getTicks, calculateLabelVisibility, TIME_CONSTANTS, getEdgeMargin, } from '../healthBarUtils';
5
+ import { getTicks, calculateLabelVisibility, TIME_CONSTANTS, getEdgeMargin, } from './GlobalHealthBar.utils';
6
6
  import { FormattedDateTime } from '../../date/FormattedDateTime';
7
7
  const CustomTick = ({ tickProps, startTimestamp, endTimestamp, }) => {
8
8
  const theme = useTheme();
@@ -0,0 +1,16 @@
1
+ export { Barchart } from './barchart/Barchart';
2
+ export type { BarchartProps, BarchartBars, BarchartTooltipFn, BarchartSortFn, Point, } from './barchart/Barchart';
3
+ export { LineTimeSerieChart } from './linetimeseries/LineTimeSerieChart';
4
+ export type { LineChartProps, Serie, } from './linetimeseries/LineTimeSerieChart';
5
+ export { GlobalHealthBar } from './globalhealthbar/GlobalHealthBar';
6
+ export type { GlobalHealthProps } from './globalhealthbar/GlobalHealthBar';
7
+ export type { Alert } from './globalhealthbar/GlobalHealthBar.hooks';
8
+ export { Sparkline } from './sparkline/Sparkline';
9
+ export { ChartLegend } from './legend/ChartLegend';
10
+ export { ChartLegendWrapper, useChartId, useChartLegend, } from './legend/ChartLegendWrapper';
11
+ export { BarchartTooltip } from './barchart/BarchartTooltip';
12
+ export { ChartTooltipContainer, ChartTooltipItem, ChartTooltipHeader, ChartTooltipItemsContainer, ChartTooltipPortal, } from './common/ChartTooltip';
13
+ export { getRoundReferenceValue, getTicks, getUnitLabel, addMissingDataPoint, formatXAxisDate, getTooltipDateFormat, normalizeChartDataWithUnits, } from './common/chartUtils';
14
+ export { MetricsTimeSpanProvider, useMetricsTimeSpan, } from './MetricsTimeSpanProvider';
15
+ export type { UnitRange, TimeType, CategoryType } from './types';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/charts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,YAAY,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,KAAK,GACN,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,YAAY,EACV,cAAc,EACd,KAAK,GACN,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,YAAY,EAAE,KAAK,EAAE,MAAM,yCAAyC,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,cAAc,GACf,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,sBAAsB,EACtB,QAAQ,EACR,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AAGnC,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Components
2
+ export { Barchart } from './barchart/Barchart';
3
+ export { LineTimeSerieChart } from './linetimeseries/LineTimeSerieChart';
4
+ export { GlobalHealthBar } from './globalhealthbar/GlobalHealthBar';
5
+ export { Sparkline } from './sparkline/Sparkline';
6
+ // Legend
7
+ export { ChartLegend } from './legend/ChartLegend';
8
+ export { ChartLegendWrapper, useChartId, useChartLegend, } from './legend/ChartLegendWrapper';
9
+ // Tooltips (for advanced usage)
10
+ export { BarchartTooltip } from './barchart/BarchartTooltip';
11
+ export { ChartTooltipContainer, ChartTooltipItem, ChartTooltipHeader, ChartTooltipItemsContainer, ChartTooltipPortal, } from './common/ChartTooltip';
12
+ // Shared utilities (for advanced usage)
13
+ export { getRoundReferenceValue, getTicks, getUnitLabel, addMissingDataPoint, formatXAxisDate, getTooltipDateFormat, normalizeChartDataWithUnits, } from './common/chartUtils';
14
+ // Context Providers (for backward compatibility)
15
+ export { MetricsTimeSpanProvider, useMetricsTimeSpan, } from './MetricsTimeSpanProvider';
@@ -1,4 +1,4 @@
1
- import { TextVariant } from '../text/Text.component';
1
+ import { TextVariant } from '../../text/Text.component';
2
2
  type ChartLegendProps = {
3
3
  shape: 'line' | 'rectangle';
4
4
  disabled?: boolean;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartLegend.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/charts/legend/ChartLegend.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAI9D,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACtC,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B,CAAC;AAUF,eAAO,MAAM,UAAU;eACV,OAAO;eACP,OAAO;SAYnB,CAAC;AAEF,eAAO,MAAM,WAAW;YACd,MAAM;WACP,MAAM,GAAG,WAAW;iBACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;SAsBpC,CAAC;AAEF,eAAO,MAAM,WAAW,gDAKrB,gBAAgB,4CAyElB,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled from 'styled-components';
3
3
  import { useChartLegend } from './ChartLegendWrapper';
4
- import { Text } from '../text/Text.component';
5
- import { chartColors } from '../../style/theme';
4
+ import { Text } from '../../text/Text.component';
5
+ import { chartColors } from '../../../style/theme';
6
6
  import { useCallback } from 'react';
7
7
  const Legend = styled.div `
8
8
  display: flex;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { ChartColors } from '../../style/theme';
2
+ import { ChartColors } from '../../../style/theme';
3
3
  export declare const useChartId: () => string;
4
4
  export type ChartLegendState = {
5
5
  selectedResources: string[];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartLegendWrapper.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/charts/legend/ChartLegendWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAKV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,eAAO,MAAM,UAAU,QAAO,MAQ7B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,sBAAsB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAC1C,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACnD,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,iBAAiB,EAAE,MAAM,OAAO,CAAC;IACjC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC5D,CAAC;AAIF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EACJ,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,GACpC,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC;IACtE,SAAS,CAAC,EAAE,cAAc,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;CAC5E,CAAC;AAEF,eAAO,MAAM,kBAAkB,uCAI5B,uBAAuB,4CAsIzB,CAAC;AAEF,eAAO,MAAM,cAAc,wBAM1B,CAAC"}
@@ -1,5 +1,5 @@
1
- import { TooltipContentProps } from 'recharts';
2
1
  import React from 'react';
2
+ import { TooltipContentProps } from 'recharts';
3
3
  export type Serie = {
4
4
  resource: string;
5
5
  data: [number, number | string | null][];
@@ -40,6 +40,16 @@ export type LineChartProps = (NonSymmetricalChartSerie | SymmetricalChartSerie)
40
40
  helpText?: string;
41
41
  renderTooltip?: (tooltipProps: TooltipContentProps<number, string>, unitLabel?: string, duration?: number) => React.ReactNode;
42
42
  };
43
+ /**
44
+ * Props for LineTimeSerieChart component
45
+ * @param series - The data series to display
46
+ * @param title - The title of the chart
47
+ * @param height - The height of the chart in pixels
48
+ * @param startingTimeStamp - Starting timestamp in seconds
49
+ * @param interval - Interval between data points in seconds
50
+ * @param duration - Total duration of the chart in seconds
51
+ *
52
+ */
43
53
  export declare function LineTimeSerieChart({ series, title, height, startingTimeStamp, interval, duration, unitRange, isLoading, timeFormat, yAxisType, yAxisTitle, helpText, syncId, renderTooltip, ...rest }: LineChartProps): import("react/jsx-runtime").JSX.Element;
44
54
  export {};
45
- //# sourceMappingURL=linetimeseriechart.component.d.ts.map
55
+ //# sourceMappingURL=LineTimeSerieChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineTimeSerieChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/charts/linetimeseries/LineTimeSerieChart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AACtE,OAAO,EAML,mBAAmB,EAGpB,MAAM,UAAU,CAAC;AAiClB,MAAM,MAAM,KAAK,GAAG;IAElB,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAEzC,eAAe,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtE,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,SAAS,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IACrC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;CAC7B,CAAC;AAGF,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EACF;QACE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;QAC3B,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;KAC5B,GACD,SAAS,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CACzB,wBAAwB,GACxB,qBAAqB,CACxB,GAAG;IACF,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,CACd,YAAY,EAAE,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,EACjD,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,KACd,KAAK,CAAC,SAAS,CAAC;CACtB,CAAC;AAiHF;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAiB,EACjB,UAAwB,EACxB,SAAqB,EACrB,UAAU,EACV,QAAQ,EACR,MAAM,EACN,aAAa,EACb,GAAG,IAAI,EACR,EAAE,cAAc,2CA0VhB"}
@@ -1,20 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { CartesianGrid, Line, LineChart, ReferenceLine, Tooltip, XAxis, YAxis, } from 'recharts';
3
2
  import React, { useCallback, useMemo, useRef, useState } from 'react';
3
+ import { CartesianGrid, Line, LineChart, ReferenceLine, Tooltip, XAxis, YAxis, } from 'recharts';
4
4
  import styled, { useTheme } from 'styled-components';
5
- import { Stack } from '../../spacing';
6
- import { fontSize } from '../../style/theme';
7
- import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
8
- import { addMissingDataPoint, getUnitLabel, } from '../linetemporalchart/ChartUtil';
9
- import { Loader } from '../loader/Loader.component';
10
- import { ChartTitleText } from '../text/Text.component';
11
- import { formatXAxisLabel } from './utils';
12
- import { ChartTooltipPortal, ChartTooltipItem, ChartTooltipHeader, ChartTooltipItemsContainer, ChartTooltipSeparator, TooltipHeader, } from '../charttooltip/ChartTooltip';
13
- import { LegendShape } from '../chartlegend/ChartLegend';
14
- import { StyledResponsiveContainer } from '../barchartv2/Barchart.component';
15
- import { getRoundReferenceValue, getTicks } from '../barchartv2/utils';
16
- import { IconHelp } from '../iconhelper/IconHelper';
17
- const maxWidthTooltip = { maxWidth: '20rem' };
5
+ import { Stack } from '../../../spacing';
6
+ import { fontSize } from '../../../style/theme';
7
+ import { IconHelp } from '../../iconhelper/IconHelper';
8
+ import { Loader } from '../../loader/Loader.component';
9
+ import { ChartTitleText } from '../../text/Text.component';
10
+ import { LegendShape } from '../legend/ChartLegend';
11
+ import { useChartLegend } from '../legend/ChartLegendWrapper';
12
+ import { StyledResponsiveContainer } from '../common/SharedComponents';
13
+ import { ChartTooltipHeader, ChartTooltipItem, ChartTooltipItemsContainer, ChartTooltipPortal, ChartTooltipSeparator, TooltipHeader, } from '../common/ChartTooltip';
14
+ import { addMissingDataPoint, formatToISONumber, getTicks, maxWidthTooltip, normalizeChartDataWithUnits, } from '../common/chartUtils';
15
+ import { formatXAxisLabel } from './LineTimeSerieChart.utils';
18
16
  const LineTemporalChartWrapper = styled.div `
19
17
  display: flex;
20
18
  flex-direction: column;
@@ -57,6 +55,16 @@ const LineTimeSerieChartTooltip = ({ unitLabel, duration, isChartActive, tooltip
57
55
  const isSymmetricalSeries = (series) => {
58
56
  return 'above' in series && 'below' in series;
59
57
  };
58
+ /**
59
+ * Props for LineTimeSerieChart component
60
+ * @param series - The data series to display
61
+ * @param title - The title of the chart
62
+ * @param height - The height of the chart in pixels
63
+ * @param startingTimeStamp - Starting timestamp in seconds
64
+ * @param interval - Interval between data points in seconds
65
+ * @param duration - Total duration of the chart in seconds
66
+ *
67
+ */
60
68
  export function LineTimeSerieChart({ series, title, height, startingTimeStamp, interval, duration, unitRange, isLoading = false, timeFormat = 'date-time', yAxisType = 'default', yAxisTitle, helpText, syncId, renderTooltip, ...rest }) {
61
69
  const theme = useTheme();
62
70
  const { getColor, selectedResources } = useChartLegend();
@@ -162,21 +170,14 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, i
162
170
  const top = Math.abs(Math.max(...values));
163
171
  const bottom = Math.abs(Math.min(...values));
164
172
  const maxValue = Math.max(top, bottom);
165
- const { valueBase, unitLabel } = yAxisType === 'percentage' ? { valueBase: 1, unitLabel: '%' } : getUnitLabel(unitRange !== null && unitRange !== void 0 ? unitRange : [], maxValue);
166
- // Use round reference value to add extra padding to the top value
167
- const basedValue = maxValue / valueBase;
168
- const topDomain = basedValue * 1.1;
169
- const topValue = getRoundReferenceValue(basedValue);
170
- const rechartsData = chartData.map((dataPoint) => {
171
- const normalizedDataPoint = { ...dataPoint };
172
- Object.entries(dataPoint).forEach(([key, value]) => {
173
- if (key !== 'timestamp' && typeof value === 'number') {
174
- normalizedDataPoint[key] = value / valueBase;
175
- }
176
- });
177
- return normalizedDataPoint;
178
- });
179
- return { topValue, unitLabel, rechartsData, topDomain };
173
+ // Use shared normalization function
174
+ const result = normalizeChartDataWithUnits(chartData, maxValue, unitRange, 'timestamp');
175
+ return {
176
+ topValue: result.topValue,
177
+ unitLabel: result.unitLabel,
178
+ rechartsData: result.rechartsData,
179
+ topDomain: result.topDomain,
180
+ };
180
181
  }, [chartData, yAxisType, unitRange]);
181
182
  // Group series by resource and create color mapping
182
183
  const { colorMapping, groupedSeries } = useMemo(() => {
@@ -227,14 +228,12 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, i
227
228
  fill: theme.textSecondary,
228
229
  fontSize: fontSize.smaller,
229
230
  },
230
- }, domain: yAxisType === 'percentage'
231
- ? [0, topDomain]
232
- : yAxisType === 'symmetrical'
233
- ? [-topDomain, topDomain]
234
- : [0, topDomain], axisLine: { stroke: theme.border }, tick: {
231
+ }, domain: yAxisType === 'symmetrical'
232
+ ? [-topDomain, topDomain]
233
+ : [0, topDomain], axisLine: { stroke: theme.border }, tick: {
235
234
  fill: theme.textSecondary,
236
235
  fontSize: fontSize.smaller,
237
- }, tickFormatter: (value) => new Intl.NumberFormat('fr-FR').format(value), ticks: getTicks(topValue, yAxisType === 'symmetrical'), interval: 0 }), _jsx(Tooltip, { content: (props) => (_jsx(LineTimeSerieChartTooltip, { unitLabel: unitLabel, duration: duration, renderTooltip: renderTooltip, isSymmetrical: yAxisType === 'symmetrical', tooltipProps: props, isChartActive: isChartActive, hoveredValue: hoveredValue, chartContainerRef: chartRef })) }), yAxisType === 'symmetrical' && (_jsx(ReferenceLine, { y: 0, stroke: theme.border })), Object.entries(groupedSeries).map(([resource, resourceSeries]) => resourceSeries.map((serie, serieIndex) => {
236
+ }, tickFormatter: (value) => formatToISONumber(value), ticks: getTicks(topValue, yAxisType === 'symmetrical'), interval: 0 }), _jsx(Tooltip, { content: (props) => (_jsx(LineTimeSerieChartTooltip, { unitLabel: unitLabel, duration: duration, renderTooltip: renderTooltip, isSymmetrical: yAxisType === 'symmetrical', tooltipProps: props, isChartActive: isChartActive, hoveredValue: hoveredValue, chartContainerRef: chartRef })) }), yAxisType === 'symmetrical' && (_jsx(ReferenceLine, { y: 0, stroke: theme.border })), Object.entries(groupedSeries).map(([resource, resourceSeries]) => resourceSeries.map((serie, serieIndex) => {
238
237
  const label = serie.getTooltipLabel(serie.metricPrefix, serie.resource);
239
238
  return (_jsx(Line, { type: "monotone", dataKey: label, stroke: colorMapping[resource], dot: false, isAnimationActive: false, strokeDasharray: serie.isLineDashed ? '4 4' : undefined, onMouseEnter: () => setHoveredValue(label), onMouseLeave: () => setHoveredValue(undefined) }, `${title}-${resource}-${serieIndex}`));
240
239
  }))] }) }) })] }));
@@ -0,0 +1,14 @@
1
+ export declare const ONE_YEAR_MILLISECONDS: number;
2
+ export type ChartDataPoint = {
3
+ timestamp: number;
4
+ } & Record<string, number | null>;
5
+ /**
6
+ * Formats timestamp for X-axis labels based on duration
7
+ *
8
+ *
9
+ * @param timestamp - The timestamp to format in milliseconds
10
+ * @param duration - The duration in seconds
11
+ * @returns Formatted string for display on X-axis
12
+ */
13
+ export declare const formatXAxisLabel: (timestamp: number, duration: number) => string;
14
+ //# sourceMappingURL=LineTimeSerieChart.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineTimeSerieChart.utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/charts/linetimeseries/LineTimeSerieChart.utils.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,QAA4B,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAElC;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,cAChB,MAAM,YACP,MAAM,KACf,MAaF,CAAC"}
@@ -1,13 +1,11 @@
1
- import { TIME_FORMATER, DAY_MONTH_ABBREVIATED_YEAR, DAY_MONTH_ABBREVIATED_HOUR_MINUTE, } from '../date/FormattedDateTime';
1
+ import { TIME_FORMATER, DAY_MONTH_ABBREVIATED_YEAR, DAY_MONTH_ABBREVIATED_HOUR_MINUTE, } from '../../date/FormattedDateTime';
2
2
  export const ONE_YEAR_MILLISECONDS = 366 * 24 * 60 * 60 * 1000;
3
3
  /**
4
- * Formats timestamp for X-axis labels based on time format and data range:
5
- * For 'date-time' format, return day-month-abbreviated-hour-minute format
6
- * For 'date' format, return YYYY-MM-DD format if time range is greater than 1 year, otherwise return MM-DD format
4
+ * Formats timestamp for X-axis labels based on duration
5
+ *
7
6
  *
8
7
  * @param timestamp - The timestamp to format in milliseconds
9
- * @param timeFormat - The format type ('date-time' or 'date')
10
- * @param chartData - The chart data to determine time range for optimal formatting
8
+ * @param duration - The duration in seconds
11
9
  * @returns Formatted string for display on X-axis
12
10
  */
13
11
  export const formatXAxisLabel = (timestamp, duration) => {
@@ -0,0 +1,23 @@
1
+ type SparklineProps = {
2
+ serie: {
3
+ data: [number, number | null][];
4
+ color?: string;
5
+ };
6
+ startingTimeStamp: number;
7
+ sampleDuration: number;
8
+ sampleInterval: number;
9
+ yAxisType?: 'default' | 'percentage';
10
+ };
11
+ /**
12
+ * Sparkline is a simple dynamically sized area chart.
13
+ * Used to show trends in data over time.
14
+ * @param serie - The data series to display
15
+ * @param startingTimeStamp - The starting timestamp in seconds
16
+ * @param sampleDuration - The total duration in seconds to cover in the sparkline
17
+ * @param sampleInterval - The interval in seconds between data points
18
+ * @param yAxisType - The type of y-axis to display
19
+ * @returns The sparkline component
20
+ */
21
+ export declare function Sparkline({ serie, startingTimeStamp, sampleDuration, sampleInterval, yAxisType, }: SparklineProps): import("react/jsx-runtime").JSX.Element;
22
+ export {};
23
+ //# sourceMappingURL=Sparkline.d.ts.map