@scality/core-ui 0.166.0 → 0.168.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/.storybook/preview.js +6 -4
- package/README.md +27 -80
- package/dist/components/barchart/BarChart.component.d.ts +5 -0
- package/dist/components/barchart/BarChart.component.d.ts.map +1 -1
- package/dist/components/barchart/BarChart.component.js +5 -0
- package/dist/components/barchartv2/Barchart.component.d.ts +5 -1
- package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
- package/dist/components/barchartv2/Barchart.component.js +6 -2
- package/dist/components/barchartv2/utils.js +2 -2
- package/dist/components/button/Button.component.d.ts +2 -1
- package/dist/components/button/Button.component.d.ts.map +1 -1
- package/dist/components/button/Button.component.js +2 -1
- package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegend.js +7 -13
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts +1 -2
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegendWrapper.js +4 -9
- package/dist/components/date/FormattedDateTime.d.ts +6 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +11 -0
- package/dist/components/icon/Icon.component.d.ts +9 -11
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +2 -0
- package/dist/components/linetemporalchart/ChartUtil.d.ts +3 -2
- package/dist/components/linetemporalchart/ChartUtil.d.ts.map +1 -1
- package/dist/components/linetemporalchart/ChartUtil.js +30 -20
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts +4 -0
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +1 -1
- package/dist/components/linetemporalchart/LineTemporalChart.component.js +4 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +8 -2
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +17 -11
- package/dist/index.d.ts +1 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -11
- package/dist/next.d.ts +1 -0
- package/dist/next.d.ts.map +1 -1
- package/jest.config.js +1 -0
- package/package.json +16 -37
- package/src/lib/components/barchart/BarChart.component.tsx +5 -0
- package/src/lib/components/barchartv2/Barchart.component.test.tsx +11 -7
- package/src/lib/components/barchartv2/Barchart.component.tsx +15 -3
- package/src/lib/components/barchartv2/utils.test.ts +2 -2
- package/src/lib/components/barchartv2/utils.ts +2 -2
- package/src/lib/components/button/Button.component.tsx +2 -1
- package/src/lib/components/chartlegend/ChartLegend.test.tsx +17 -0
- package/src/lib/components/chartlegend/ChartLegend.tsx +6 -12
- package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +5 -13
- package/src/lib/components/date/FormattedDateTime.tsx +14 -1
- package/src/lib/components/icon/Icon.component.tsx +12 -1
- package/src/lib/components/linetemporalchart/ChartUtil.test.ts +23 -35
- package/src/lib/components/linetemporalchart/ChartUtil.ts +38 -26
- package/src/lib/components/linetemporalchart/LineTemporalChart.component.tsx +19 -15
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +36 -13
- package/src/lib/components/linetimeseriechart/linetimeseriechart.test.tsx +68 -0
- package/src/lib/components/selectv2/selectv2.test.tsx +1 -1
- package/src/lib/components/toast/useMutationsHandler.test.tsx +22 -32
- package/src/lib/index.ts +6 -11
- package/src/lib/next.ts +1 -0
- package/stories/BarChart/barchart.stories.tsx +108 -13
- package/stories/barchart.stories.tsx +1 -1
- package/stories/card.stories.tsx +7 -5
- package/stories/controls.ts +19 -20
- package/stories/linecharttemporal.stories.tsx +1 -1
- package/stories/linetimeseriechart.stories.tsx +146 -0
- package/stories/navbar.stories.tsx +103 -0
- package/stories/tabsv2.stories.tsx +51 -56
- package/dist/components/areachart/AreaChart.component.d.ts +0 -13
- package/dist/components/areachart/AreaChart.component.d.ts.map +0 -1
- package/dist/components/areachart/AreaChart.component.js +0 -27
- package/dist/components/chips/Chips.component.d.ts +0 -21
- package/dist/components/chips/Chips.component.d.ts.map +0 -1
- package/dist/components/chips/Chips.component.js +0 -105
- package/dist/components/cloudprogressbar/CloudProgressBar.component.d.ts +0 -10
- package/dist/components/cloudprogressbar/CloudProgressBar.component.d.ts.map +0 -1
- package/dist/components/cloudprogressbar/CloudProgressBar.component.js +0 -38
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.d.ts +0 -9
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.d.ts.map +0 -1
- package/dist/components/collapsiblepanel/CollapsiblePanel.component.js +0 -44
- package/dist/components/linechart/LineChart.component.d.ts +0 -21
- package/dist/components/linechart/LineChart.component.d.ts.map +0 -1
- package/dist/components/linechart/LineChart.component.js +0 -109
- package/dist/components/multiselect/MultiSelect.component.d.ts +0 -28
- package/dist/components/multiselect/MultiSelect.component.d.ts.map +0 -1
- package/dist/components/multiselect/MultiSelect.component.js +0 -73
- package/dist/components/select/Select.component.d.ts +0 -14
- package/dist/components/select/Select.component.d.ts.map +0 -1
- package/dist/components/select/Select.component.js +0 -71
- package/dist/components/spacedbox/SpacedBox.d.ts +0 -34
- package/dist/components/spacedbox/SpacedBox.d.ts.map +0 -1
- package/dist/components/spacedbox/SpacedBox.js +0 -64
- package/dist/components/sparkline/SparkLine.component.d.ts +0 -18
- package/dist/components/sparkline/SparkLine.component.d.ts.map +0 -1
- package/dist/components/sparkline/SparkLine.component.js +0 -148
- package/dist/components/vegachart/VegaChart.component.d.ts +0 -13
- package/dist/components/vegachart/VegaChart.component.d.ts.map +0 -1
- package/dist/components/vegachart/VegaChart.component.js +0 -120
- package/plopfile.js +0 -38
- package/src/lib/components/areachart/AreaChart.component.tsx +0 -49
- package/src/lib/components/chips/Chips.component.tsx +0 -169
- package/src/lib/components/cloudprogressbar/CloudProgressBar.component.tsx +0 -105
- package/src/lib/components/collapsiblepanel/CollapsiblePanel.component.tsx +0 -77
- package/src/lib/components/linechart/LineChart.component.tsx +0 -152
- package/src/lib/components/multiselect/MultiSelect.component.tsx +0 -158
- package/src/lib/components/select/Select.component.tsx +0 -98
- package/src/lib/components/spacedbox/SpacedBox.ts +0 -116
- package/src/lib/components/sparkline/SparkLine.component.tsx +0 -176
- package/src/lib/components/vegachart/VegaChart.component.tsx +0 -146
- package/stories/areachart.stories.tsx +0 -120
- package/stories/chips.stories.tsx +0 -107
- package/stories/cloudprogressbar.stories.tsx +0 -93
- package/stories/collapsiblepanel.stories.tsx +0 -57
- package/stories/data/areachart.ts +0 -122
- package/stories/data/sparklinechart.ts +0 -164
- package/stories/linechart.stories.tsx +0 -319
- package/stories/multiselect.stories.tsx +0 -126
- package/stories/select.stories.tsx +0 -52
- package/stories/sparkline.stories.tsx +0 -85
- package/stories/vegachart.stories.tsx +0 -98
|
@@ -43,6 +43,12 @@ export function convertDataBaseValue(data, base) {
|
|
|
43
43
|
* @returns {any}
|
|
44
44
|
*/
|
|
45
45
|
export function getUnitLabel(unitRange, maxValue) {
|
|
46
|
+
if (!unitRange || unitRange.length === 0) {
|
|
47
|
+
return {
|
|
48
|
+
valueBase: 1,
|
|
49
|
+
unitLabel: '',
|
|
50
|
+
};
|
|
51
|
+
}
|
|
46
52
|
// first sort the unitRange
|
|
47
53
|
unitRange.sort((unitA, unitB) => {
|
|
48
54
|
return unitA.threshold - unitB.threshold;
|
|
@@ -65,42 +71,46 @@ export function getUnitLabel(unitRange, maxValue) {
|
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
67
73
|
* This function manually adds the missing data points with `null` value caused by downtime of the VMs
|
|
74
|
+
* Missing data points are only added when the gap between consecutive data points is bigger than 2 intervals
|
|
68
75
|
*
|
|
69
76
|
* @param {array} orginalValues - The array of the data points are already sorted according to the time series
|
|
70
77
|
* @param {number} startingTimeStamp - The starting timestamp in seconds
|
|
71
78
|
* @param {number} sampleDuration - The time span value in seconds
|
|
72
|
-
* @param {number}
|
|
79
|
+
* @param {number} sampleInterval - The time difference between two data points in seconds
|
|
73
80
|
*
|
|
74
81
|
*/
|
|
75
|
-
export function addMissingDataPoint(orginalValues, startingTimeStamp, sampleDuration,
|
|
82
|
+
export function addMissingDataPoint(orginalValues, startingTimeStamp, sampleDuration, sampleInterval) {
|
|
76
83
|
if (!orginalValues ||
|
|
77
84
|
startingTimeStamp === undefined ||
|
|
78
85
|
!sampleDuration ||
|
|
79
|
-
!
|
|
86
|
+
!sampleInterval ||
|
|
80
87
|
startingTimeStamp < 0 ||
|
|
81
88
|
sampleDuration <= 0 ||
|
|
82
|
-
|
|
89
|
+
sampleInterval <= 0) {
|
|
83
90
|
return [];
|
|
84
91
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
let samplingPointTime = startingTimeStamp;
|
|
88
|
-
// initialize the array with all "NAN" value, in order for the tooltip to display dash(-)
|
|
89
|
-
for (let i = 0; i < numberOfDataPoints; i++) {
|
|
90
|
-
newValues.push([samplingPointTime, NAN_STRING]);
|
|
91
|
-
samplingPointTime += sampleFrequency;
|
|
92
|
-
}
|
|
93
|
-
// copy the existing data points from `orginalValue` array to `newValues`
|
|
94
|
-
if (newValues.length === 0)
|
|
92
|
+
// If there are no original values, return empty array
|
|
93
|
+
if (orginalValues.length === 0) {
|
|
95
94
|
return [];
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
}
|
|
96
|
+
const newValues = [];
|
|
97
|
+
// Process all but the last element
|
|
98
|
+
for (let i = 0; i < orginalValues.length - 1; i++) {
|
|
99
|
+
// Always add the current data point
|
|
100
|
+
newValues.push(orginalValues[i]);
|
|
101
|
+
const currentTimestamp = orginalValues[i][0];
|
|
102
|
+
const nextTimestamp = orginalValues[i + 1][0];
|
|
103
|
+
const gap = nextTimestamp - currentTimestamp;
|
|
104
|
+
// Calculate how many missing points to add
|
|
105
|
+
const missingIntervals = Math.floor(gap / sampleInterval) - 1;
|
|
106
|
+
// Add missing data points with NAN_STRING (only executes if missingIntervals > 0)
|
|
107
|
+
for (let j = 1; j <= missingIntervals; j++) {
|
|
108
|
+
const missingTimestamp = currentTimestamp + j * sampleInterval;
|
|
109
|
+
newValues.push([missingTimestamp, NAN_STRING]);
|
|
102
110
|
}
|
|
103
111
|
}
|
|
112
|
+
// Add the last element
|
|
113
|
+
newValues.push(orginalValues[orginalValues.length - 1]);
|
|
104
114
|
return newValues;
|
|
105
115
|
}
|
|
106
116
|
// get the value for the based value
|
|
@@ -37,6 +37,10 @@ export type LineChartProps = {
|
|
|
37
37
|
unitLabel: string;
|
|
38
38
|
}, tooltipData: any) => string;
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use LineTimeSerieChart instead
|
|
42
|
+
* @example import { LineTimeSerieChart } from '@scality/core-ui/dist/next';
|
|
43
|
+
*/
|
|
40
44
|
declare function LineTemporalChart({ series, title, height, startingTimeStamp, unitRange, isLoading, isLegendHidden, yAxisType, yAxisTitle, helpText, renderTooltipSerie, onHover, ...rest }: LineChartProps): import("react/jsx-runtime").JSX.Element;
|
|
41
45
|
export { LineTemporalChart };
|
|
42
46
|
//# sourceMappingURL=LineTemporalChart.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineTemporalChart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetemporalchart/LineTemporalChart.component.tsx"],"names":[],"mappings":"AAoCA,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAC3D,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,aAAa;;;GAqBzB,CAAC;AA+BF,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAEhC,eAAe,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtE,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B,OAAO,EACP,GAAG,IAAI,EACR,EAAE,cAAc,2CAomBhB;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"LineTemporalChart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetemporalchart/LineTemporalChart.component.tsx"],"names":[],"mappings":"AAoCA,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAC3D,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,aAAa;;;GAqBzB,CAAC;AA+BF,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAEhC,eAAe,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtE,cAAc,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtE,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAE1B,SAAS,CAAC,EAAE;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,SAAS,GAAG,YAAY,GAAG,aAAa,CAAC;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,kBAAkB,CAAC,EAAE,CACnB,IAAI,EAAE;QACJ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;KACnB,EACD,WAAW,EAAE,GAAG,KACb,MAAM,CAAC;CACb,CAAC;AAkCF;;;GAGG;AACH,iBAAS,iBAAiB,CAAC,EACzB,MAAM,EACN,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,SAAS,EACT,SAAiB,EACjB,cAAsB,EACtB,SAAqB,EACrB,UAAU,EACV,QAAQ,EACR,kBAAkB,EAClB,OAAO,EACP,GAAG,IAAI,EACR,EAAE,cAAc,2CAomBhB;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -94,6 +94,10 @@ const colorRange = [
|
|
|
94
94
|
darken(0.3, lineColor8),
|
|
95
95
|
];
|
|
96
96
|
// Note: we need to make sure the start time and end timefor the prometheus query between the series are the same.
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated Use LineTimeSerieChart instead
|
|
99
|
+
* @example import { LineTimeSerieChart } from '@scality/core-ui/dist/next';
|
|
100
|
+
*/
|
|
97
101
|
function LineTemporalChart({ series, title, height, startingTimeStamp, unitRange, isLoading = false, isLegendHidden = false, yAxisType = 'default', yAxisTitle, helpText, renderTooltipSerie, onHover, ...rest }) {
|
|
98
102
|
// property validation
|
|
99
103
|
if (!['default', 'percentage', 'symmetrical'].includes(yAxisType)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type Serie = {
|
|
2
2
|
resource: string;
|
|
3
|
-
data: [number, string | null][];
|
|
3
|
+
data: [number, number | string | null][];
|
|
4
4
|
getTooltipLabel: (metricPrefix?: string, resource?: string) => string;
|
|
5
5
|
metricPrefix?: string;
|
|
6
6
|
isLineDashed?: boolean;
|
|
@@ -27,9 +27,15 @@ export type LineChartProps = (NonSymmetricalChartSerie | SymmetricalChartSerie)
|
|
|
27
27
|
label: string;
|
|
28
28
|
}[];
|
|
29
29
|
isLoading?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The format of the x axis, default is 'date-time' which is like 01 Sep 16:00
|
|
32
|
+
* If you want to display the date only, you can set it to 'date' which is like 2025-09-01
|
|
33
|
+
* This will affect the format of the tooltip as well
|
|
34
|
+
*/
|
|
35
|
+
timeFormat?: 'date-time' | 'date';
|
|
30
36
|
yAxisTitle?: string;
|
|
31
37
|
helpText?: string;
|
|
32
38
|
};
|
|
33
|
-
export declare function LineTimeSerieChart({ series, title, height, startingTimeStamp, interval, duration, unitRange, isLoading, yAxisType, yAxisTitle, helpText, ...rest }: LineChartProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare function LineTimeSerieChart({ series, title, height, startingTimeStamp, interval, duration, unitRange, isLoading, timeFormat, yAxisType, yAxisTitle, helpText, ...rest }: LineChartProps): import("react/jsx-runtime").JSX.Element;
|
|
34
40
|
export {};
|
|
35
41
|
//# sourceMappingURL=linetimeseriechart.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linetimeseriechart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linetimeseriechart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx"],"names":[],"mappings":"AA2FA,MAAM,MAAM,KAAK,GAAG;IAElB,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAEz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
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Line, LineChart, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis, CartesianGrid, } from 'recharts';
|
|
3
|
-
import { useMemo, useRef } from 'react';
|
|
3
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
4
4
|
import { useTheme } from 'styled-components';
|
|
5
5
|
import { addMissingDataPoint } from '../linetemporalchart/ChartUtil';
|
|
6
6
|
import styled from 'styled-components';
|
|
@@ -12,7 +12,7 @@ import { spacing } from '../../spacing';
|
|
|
12
12
|
import { getUnitLabel } from '../linetemporalchart/ChartUtil';
|
|
13
13
|
import { Icon } from '../icon/Icon.component';
|
|
14
14
|
import { Tooltip as TooltipComponent } from '../tooltip/Tooltip.component';
|
|
15
|
-
import { DAY_MONTH_ABBREVIATED_HOUR_MINUTE, FormattedDateTime, } from '../date/FormattedDateTime';
|
|
15
|
+
import { DAY_MONTH_ABBREVIATED_HOUR_MINUTE, FormattedDateTime, YEAR_MONTH_DAY_FORMATTER, } from '../date/FormattedDateTime';
|
|
16
16
|
const LineTemporalChartWrapper = styled.div `
|
|
17
17
|
display: flex;
|
|
18
18
|
flex-direction: column;
|
|
@@ -67,7 +67,7 @@ const TooltipName = styled.div `
|
|
|
67
67
|
const TooltipInstanceValue = styled.div `
|
|
68
68
|
justify-content: flex-end;
|
|
69
69
|
`;
|
|
70
|
-
const CustomTooltip = ({ active, payload, label, unitLabel, }) => {
|
|
70
|
+
const CustomTooltip = ({ active, payload, label, unitLabel, timeFormat, }) => {
|
|
71
71
|
if (!active || !payload || !payload.length || !label)
|
|
72
72
|
return null;
|
|
73
73
|
// We can't use the default itemSorter method because it's a custom tooltip.
|
|
@@ -83,14 +83,16 @@ const CustomTooltip = ({ active, payload, label, unitLabel, }) => {
|
|
|
83
83
|
}
|
|
84
84
|
return bValue - aValue; // Positives before negatives
|
|
85
85
|
});
|
|
86
|
-
return (_jsxs(TooltipContainer, { children: [_jsx(TooltipTime, { children: _jsx(FormattedDateTime, { format:
|
|
86
|
+
return (_jsxs(TooltipContainer, { children: [_jsx(TooltipTime, { children: _jsx(FormattedDateTime, { format: timeFormat === 'date-time'
|
|
87
|
+
? 'day-month-abbreviated-hour-minute-second'
|
|
88
|
+
: 'long-date', value: new Date(label) }) }), sortedPayload.map((entry, index) => (_jsxs(TooltipValue, { children: [_jsx(TooltipLegend, { color: entry.color }), _jsxs(TooltipContent, { children: [_jsx(TooltipName, { children: entry.name }), _jsx(TooltipInstanceValue, { children: isNaN(Number(entry.value))
|
|
87
89
|
? '-'
|
|
88
90
|
: `${Number(entry.value).toFixed(2)}${unitLabel}` })] })] }, index)))] }));
|
|
89
91
|
};
|
|
90
92
|
const isSymmetricalSeries = (series) => {
|
|
91
93
|
return 'above' in series && 'below' in series;
|
|
92
94
|
};
|
|
93
|
-
export function LineTimeSerieChart({ series, title, height, startingTimeStamp, interval, duration, unitRange, isLoading = false, yAxisType = 'default', yAxisTitle, helpText, ...rest }) {
|
|
95
|
+
export function LineTimeSerieChart({ series, title, height, startingTimeStamp, interval, duration, unitRange, isLoading = false, timeFormat = 'date-time', yAxisType = 'default', yAxisTitle, helpText, ...rest }) {
|
|
94
96
|
const theme = useTheme();
|
|
95
97
|
const { getColor } = useChartLegend();
|
|
96
98
|
const chartRef = useRef(null);
|
|
@@ -217,11 +219,15 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, i
|
|
|
217
219
|
};
|
|
218
220
|
}, [series, getColor]);
|
|
219
221
|
// Format time for display the tick in the x axis
|
|
220
|
-
const
|
|
222
|
+
const formatXAxisLabel = useCallback((timestamp) => {
|
|
221
223
|
const date = new Date(timestamp);
|
|
222
|
-
return
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
return timeFormat === 'date-time'
|
|
225
|
+
? DAY_MONTH_ABBREVIATED_HOUR_MINUTE.format(date).replace(',', '')
|
|
226
|
+
: timeFormat === 'date'
|
|
227
|
+
? YEAR_MONTH_DAY_FORMATTER.format(date)
|
|
228
|
+
: '';
|
|
229
|
+
}, [timeFormat]);
|
|
230
|
+
return (_jsxs(LineTemporalChartWrapper, { children: [_jsxs(ChartHeader, { children: [_jsxs(ChartTitleText, { children: [title, " ", unitLabel && `(${unitLabel})`] }), helpText && (_jsx(TooltipComponent, { placement: 'right', overlay: _jsx(SmallerText, { children: helpText }), children: _jsx(Icon, { name: "Info", color: theme.buttonSecondary }) })), isLoading && _jsx(Loader, {})] }), _jsx(ResponsiveContainer, { width: "100%", height: height, children: _jsxs(LineChart, { data: rechartsData, ref: chartRef, margin: { top: 0, right: 0, bottom: 0, left: 0 }, "aria-label": `Time series chart for ${title}`, children: [_jsx(CartesianGrid, { vertical: true, horizontal: true, verticalPoints: [0], horizontalPoints: [0], stroke: theme.border, fill: theme.backgroundLevel4, strokeWidth: 1 }), _jsx(XAxis, { dataKey: "timestamp", type: "number", domain: ['dataMin', 'dataMax'], ticks: xAxisTicks, tickFormatter: formatXAxisLabel, tickCount: 5, tick: {
|
|
225
231
|
fill: theme.textSecondary,
|
|
226
232
|
fontSize: fontSize.smaller,
|
|
227
233
|
}, axisLine: { stroke: theme.border } }), _jsx(YAxis, { orientation: "right", allowDataOverflow: false, label: {
|
|
@@ -240,8 +246,8 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, i
|
|
|
240
246
|
: [0, topValue], axisLine: { stroke: theme.border }, tick: {
|
|
241
247
|
fill: theme.textSecondary,
|
|
242
248
|
fontSize: fontSize.smaller,
|
|
243
|
-
}, tickFormatter: (value) => Math.round(value).toString() }), _jsx(Tooltip, { content: _jsx(CustomTooltip, { unitLabel: unitLabel }) }), yAxisType === 'symmetrical' && (_jsx(ReferenceLine, { y: 0, stroke: theme.border })), Object.entries(groupedSeries).map(([resource, resourceSeries]) => resourceSeries.map((serie, serieIndex) => {
|
|
249
|
+
}, tickFormatter: (value) => Math.round(value).toString() }), _jsx(Tooltip, { content: _jsx(CustomTooltip, { unitLabel: unitLabel, timeFormat: timeFormat }) }), yAxisType === 'symmetrical' && (_jsx(ReferenceLine, { y: 0, stroke: theme.border })), Object.entries(groupedSeries).map(([resource, resourceSeries]) => resourceSeries.map((serie, serieIndex) => {
|
|
244
250
|
const label = serie.getTooltipLabel(serie.metricPrefix, serie.resource);
|
|
245
|
-
return (_jsx(Line, { type: "monotone", dataKey: label, stroke: colorMapping[resource], dot: false }, `${title}-${resource}-${serieIndex}`));
|
|
251
|
+
return (_jsx(Line, { type: "monotone", dataKey: label, stroke: colorMapping[resource], dot: false, isAnimationActive: false }, `${title}-${resource}-${serieIndex}`));
|
|
246
252
|
}))] }) })] }));
|
|
247
253
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export { Banner } from './components/banner/Banner.component';
|
|
2
2
|
export { Breadcrumb } from './components/breadcrumb/Breadcrumb.component';
|
|
3
|
-
export { Button } from './components/button/Button.component';
|
|
4
3
|
export { Checkbox } from './components/checkbox/Checkbox.component';
|
|
5
|
-
export { Chips } from './components/chips/Chips.component';
|
|
6
4
|
export { Dropdown } from './components/dropdown/Dropdown.component';
|
|
7
5
|
export { LOADER_SIZE, STATUS_CRITICAL, STATUS_WARNING, STATUS_SUCCESS, STATUS_HEALTHY, STATUS_INFO, STATUS_UNKNOWN, STATUS_NONE, Status, } from './components/constants';
|
|
8
6
|
export { Layout } from './components/layout/Layout.component';
|
|
@@ -11,22 +9,14 @@ export { Modal } from './components/modal/Modal.component';
|
|
|
11
9
|
export { Navbar } from './components/navbar/Navbar.component';
|
|
12
10
|
export { Notifications } from './components/notifications/Notifications.component';
|
|
13
11
|
export { SearchInput } from './components/searchinput/SearchInput.component';
|
|
14
|
-
export { Select } from './components/select/Select.component';
|
|
15
12
|
export { Sidebar } from './components/sidebar/Sidebar.component';
|
|
16
13
|
export { Steppers } from './components/steppers/Steppers.component';
|
|
17
14
|
export { Toggle } from './components/toggle/Toggle.component';
|
|
18
15
|
export { Tooltip } from './components/tooltip/Tooltip.component';
|
|
19
|
-
export { MultiSelect } from './components/multiselect/MultiSelect.component';
|
|
20
|
-
export { VegaChart } from './components/vegachart/VegaChart.component';
|
|
21
|
-
export { LineChart } from './components/linechart/LineChart.component';
|
|
22
16
|
export { ProgressBar } from './components/progressbar/ProgressBar.component';
|
|
23
17
|
export { TextArea } from './components/textarea/TextArea.component';
|
|
24
|
-
export { CloudProgressBar } from './components/cloudprogressbar/CloudProgressBar.component';
|
|
25
|
-
export { Sparkline } from './components/sparkline/SparkLine.component';
|
|
26
18
|
export { BarChart } from './components/barchart/BarChart.component';
|
|
27
19
|
export { CircularProgressBar } from './components/circularprogressbar/CircularProgressBar.component';
|
|
28
|
-
export { AreaChart } from './components/areachart/AreaChart.component';
|
|
29
|
-
export { CollapsiblePanel } from './components/collapsiblepanel/CollapsiblePanel.component';
|
|
30
20
|
export { LateralNavbarLayout } from './components/lateralnavbarlayout/LateralNavbarLayout.component';
|
|
31
21
|
export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBar.component';
|
|
32
22
|
export { ConstrainedText } from './components/constrainedtext/Constrainedtext.component';
|
|
@@ -38,7 +28,6 @@ export { ErrorPage404 } from './components/error-pages/ErrorPage404.component';
|
|
|
38
28
|
export { ErrorPage500 } from './components/error-pages/ErrorPage500.component';
|
|
39
29
|
export { ErrorPageAuth } from './components/error-pages/ErrorPageAuth.component';
|
|
40
30
|
export { TextBadge } from './components/textbadge/TextBadge.component';
|
|
41
|
-
export { SpacedBox } from './components/spacedbox/SpacedBox';
|
|
42
31
|
export { Layout as Layout2 } from './components/layout/v2';
|
|
43
32
|
export { TwoPanelLayout } from './components/layout/v2/panels';
|
|
44
33
|
export { AppContainer } from './components/layout/v2/AppContainer';
|
|
@@ -61,4 +50,5 @@ export { InfoMessage } from './components/infomessage/InfoMessage.component';
|
|
|
61
50
|
export { InputList } from './components/inputlist/InputList.component';
|
|
62
51
|
export { InlineInput } from './components/inlineinput/InlineInput';
|
|
63
52
|
export { UnsuccessfulResult } from './components/UnsuccessfulResult.component';
|
|
53
|
+
export { CoreUITheme } from './style/theme';
|
|
64
54
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACpE,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACd,cAAc,EACd,WAAW,EACX,cAAc,EACd,WAAW,EACX,MAAM,GACP,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,gDAAgD,CAAC;AAE7E,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,OAAO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AO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AACnF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,gDAAgD,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export { Banner } from './components/banner/Banner.component';
|
|
2
2
|
export { Breadcrumb } from './components/breadcrumb/Breadcrumb.component';
|
|
3
|
-
export { Button } from './components/button/Button.component';
|
|
4
3
|
export { Checkbox } from './components/checkbox/Checkbox.component';
|
|
5
|
-
export { Chips } from './components/chips/Chips.component';
|
|
6
4
|
export { Dropdown } from './components/dropdown/Dropdown.component';
|
|
7
5
|
export { LOADER_SIZE, STATUS_CRITICAL, STATUS_WARNING, STATUS_SUCCESS, STATUS_HEALTHY, STATUS_INFO, STATUS_UNKNOWN, STATUS_NONE, } from './components/constants';
|
|
8
6
|
export { Layout } from './components/layout/Layout.component';
|
|
@@ -11,22 +9,14 @@ export { Modal } from './components/modal/Modal.component';
|
|
|
11
9
|
export { Navbar } from './components/navbar/Navbar.component';
|
|
12
10
|
export { Notifications } from './components/notifications/Notifications.component';
|
|
13
11
|
export { SearchInput } from './components/searchinput/SearchInput.component';
|
|
14
|
-
export { Select } from './components/select/Select.component';
|
|
15
12
|
export { Sidebar } from './components/sidebar/Sidebar.component';
|
|
16
13
|
export { Steppers } from './components/steppers/Steppers.component';
|
|
17
14
|
export { Toggle } from './components/toggle/Toggle.component';
|
|
18
15
|
export { Tooltip } from './components/tooltip/Tooltip.component';
|
|
19
|
-
export { MultiSelect } from './components/multiselect/MultiSelect.component';
|
|
20
|
-
export { VegaChart } from './components/vegachart/VegaChart.component';
|
|
21
|
-
export { LineChart } from './components/linechart/LineChart.component';
|
|
22
16
|
export { ProgressBar } from './components/progressbar/ProgressBar.component';
|
|
23
17
|
export { TextArea } from './components/textarea/TextArea.component';
|
|
24
|
-
export { CloudProgressBar } from './components/cloudprogressbar/CloudProgressBar.component';
|
|
25
|
-
export { Sparkline } from './components/sparkline/SparkLine.component';
|
|
26
18
|
export { BarChart } from './components/barchart/BarChart.component';
|
|
27
19
|
export { CircularProgressBar } from './components/circularprogressbar/CircularProgressBar.component';
|
|
28
|
-
export { AreaChart } from './components/areachart/AreaChart.component';
|
|
29
|
-
export { CollapsiblePanel } from './components/collapsiblepanel/CollapsiblePanel.component';
|
|
30
20
|
export { LateralNavbarLayout } from './components/lateralnavbarlayout/LateralNavbarLayout.component';
|
|
31
21
|
export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBar.component';
|
|
32
22
|
export { ConstrainedText } from './components/constrainedtext/Constrainedtext.component';
|
|
@@ -38,7 +28,6 @@ export { ErrorPage404 } from './components/error-pages/ErrorPage404.component';
|
|
|
38
28
|
export { ErrorPage500 } from './components/error-pages/ErrorPage500.component';
|
|
39
29
|
export { ErrorPageAuth } from './components/error-pages/ErrorPageAuth.component';
|
|
40
30
|
export { TextBadge } from './components/textbadge/TextBadge.component';
|
|
41
|
-
export { SpacedBox } from './components/spacedbox/SpacedBox';
|
|
42
31
|
export { Layout as Layout2 } from './components/layout/v2';
|
|
43
32
|
export { TwoPanelLayout } from './components/layout/v2/panels';
|
|
44
33
|
export { AppContainer } from './components/layout/v2/AppContainer';
|
package/dist/next.d.ts
CHANGED
|
@@ -18,4 +18,5 @@ export { ChartTooltip } from './components/barchartv2/ChartTooltip';
|
|
|
18
18
|
export { ChartLegendWrapper } from './components/chartlegend/ChartLegendWrapper';
|
|
19
19
|
export { ChartLegend } from './components/chartlegend/ChartLegend';
|
|
20
20
|
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
|
21
|
+
export { CoreUITheme } from './style/theme';
|
|
21
22
|
//# sourceMappingURL=next.d.ts.map
|
package/dist/next.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../src/lib/next.ts"],"names":[],"mappings":"AAAA,OAAO,2CAA2C,CAAC;AACnD,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4DAA4D,CAAC;AAC/F,OAAO,EACL,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE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DAAsD,CAAC;AAC3F,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAC;AACvE,OAAO,EACL,QAAQ,EACR,cAAc,EACd,iBAAiB,GAClB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scality/core-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.168.0",
|
|
4
4
|
"description": "Scality common React component library",
|
|
5
5
|
"author": "Scality Engineering",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -19,12 +19,10 @@
|
|
|
19
19
|
"lint": "eslint src/* --ext .js --no-error-on-unmatched-pattern",
|
|
20
20
|
"prepare": "npm run build",
|
|
21
21
|
"postbuild": "npm run copy-files",
|
|
22
|
-
"plop": "plop",
|
|
23
22
|
"test": "jest",
|
|
24
23
|
"storybook": "storybook dev -p 3000",
|
|
25
24
|
"build-storybook": "storybook build",
|
|
26
|
-
"storybook:deploy": "storybook-to-ghpages"
|
|
27
|
-
"preview": "jest-preview"
|
|
25
|
+
"storybook:deploy": "storybook-to-ghpages"
|
|
28
26
|
},
|
|
29
27
|
"keywords": [],
|
|
30
28
|
"browserslist": [
|
|
@@ -40,23 +38,19 @@
|
|
|
40
38
|
"@babel/preset-react": "^7.16.7",
|
|
41
39
|
"@babel/preset-typescript": "^7.16.7",
|
|
42
40
|
"@chromatic-com/storybook": "^1.9.0",
|
|
43
|
-
"@storybook/addon-actions": "^8.
|
|
44
|
-
"@storybook/addon-essentials": "^8.
|
|
45
|
-
"@storybook/addon-
|
|
46
|
-
"@storybook/addon-
|
|
47
|
-
"@storybook/addon-storysource": "^8.3.6",
|
|
41
|
+
"@storybook/addon-actions": "^8.6.14",
|
|
42
|
+
"@storybook/addon-essentials": "^8.6.14",
|
|
43
|
+
"@storybook/addon-mdx-gfm": "^8.6.14",
|
|
44
|
+
"@storybook/addon-storysource": "^8.6.14",
|
|
48
45
|
"@storybook/addon-webpack5-compiler-swc": "^1.0.5",
|
|
49
|
-
"@storybook/blocks": "^8.
|
|
50
|
-
"@storybook/manager-api": "^8.
|
|
51
|
-
"@storybook/react": "^8.
|
|
52
|
-
"@storybook/react-webpack5": "^8.
|
|
53
|
-
"@storybook/
|
|
54
|
-
"@storybook/theming": "^8.3.6",
|
|
46
|
+
"@storybook/blocks": "^8.6.14",
|
|
47
|
+
"@storybook/manager-api": "^8.6.14",
|
|
48
|
+
"@storybook/react": "^8.6.14",
|
|
49
|
+
"@storybook/react-webpack5": "^8.6.14",
|
|
50
|
+
"@storybook/theming": "^8.6.14",
|
|
55
51
|
"@testing-library/jest-dom": "^5.14.1",
|
|
56
52
|
"@testing-library/react": "^15.0.7",
|
|
57
|
-
"@testing-library/react-hooks": "^8.0.1",
|
|
58
53
|
"@testing-library/user-event": "^13.5.0",
|
|
59
|
-
"@types/jest": "^27.5.0",
|
|
60
54
|
"@types/react": "^18.3.12",
|
|
61
55
|
"@types/react-dom": "^18.3.1",
|
|
62
56
|
"@types/react-router": "^5.1.20",
|
|
@@ -70,21 +64,17 @@
|
|
|
70
64
|
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
71
65
|
"@typescript-eslint/parser": "^6.12.0",
|
|
72
66
|
"copyfiles": "^2.4.1",
|
|
73
|
-
"cross-env": "^7.0.3",
|
|
74
|
-
"csstype": "^3.1.0",
|
|
75
67
|
"eslint": "^8.15.0",
|
|
76
68
|
"eslint-config-react-app": "^7.0.1",
|
|
77
69
|
"eslint-plugin-storybook": "^0.10.1",
|
|
78
70
|
"husky": "^3.0.5",
|
|
79
|
-
"
|
|
80
|
-
"jest": "^26.6.3",
|
|
71
|
+
"jest": "^30.0.5",
|
|
81
72
|
"jest-canvas-mock": "^2.3.1",
|
|
82
|
-
"jest-
|
|
83
|
-
"plop": "^2.4.0",
|
|
73
|
+
"jest-environment-jsdom": "^30.0.5",
|
|
84
74
|
"regenerator-runtime": "^0.13.7",
|
|
85
75
|
"rimraf": "^3.0.0",
|
|
86
76
|
"source-map-explorer": "^2.0.1",
|
|
87
|
-
"storybook": "^8.
|
|
77
|
+
"storybook": "^8.6.14",
|
|
88
78
|
"typescript": "^5.3.2"
|
|
89
79
|
},
|
|
90
80
|
"husky": {
|
|
@@ -92,15 +82,6 @@
|
|
|
92
82
|
"pre-commit": "npm run lint"
|
|
93
83
|
}
|
|
94
84
|
},
|
|
95
|
-
"jest": {
|
|
96
|
-
"setupFiles": [
|
|
97
|
-
"jest-canvas-mock"
|
|
98
|
-
],
|
|
99
|
-
"transform": {
|
|
100
|
-
"^.+\\.[tj]sx?$": "babel-jest",
|
|
101
|
-
"^.+\\.mdx?$": "@storybook/addon-docs/jest-transform-mdx"
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
85
|
"dependencies": {
|
|
105
86
|
"@floating-ui/dom": "^1.6.3",
|
|
106
87
|
"@floating-ui/react": "^0.26.28",
|
|
@@ -114,16 +95,14 @@
|
|
|
114
95
|
"downshift": "^7.0.5",
|
|
115
96
|
"polished": "3.4.1",
|
|
116
97
|
"pretty-bytes": "^5.6.0",
|
|
117
|
-
"react-debounce-input": "3.2.2",
|
|
118
98
|
"react-dropzone": "^14.2.3",
|
|
119
99
|
"react-hook-form": "^7.49.2",
|
|
120
100
|
"react-query": "^3.34.0",
|
|
121
|
-
"react-router": "7.
|
|
122
|
-
"react-router-dom": "7.
|
|
101
|
+
"react-router": "7.8.1",
|
|
102
|
+
"react-router-dom": "7.8.1",
|
|
123
103
|
"react-select": "4.3.1",
|
|
124
104
|
"react-table": "^7.7.0",
|
|
125
105
|
"react-test-renderer": "^18.3.1",
|
|
126
|
-
"react-virtualized": "9.22.3",
|
|
127
106
|
"react-virtualized-auto-sizer": "^1.0.24",
|
|
128
107
|
"react-window": "^1.8.6",
|
|
129
108
|
"recharts": "^3.0.2",
|
|
@@ -60,7 +60,7 @@ describe('Barchart', () => {
|
|
|
60
60
|
render(
|
|
61
61
|
<Wrapper>
|
|
62
62
|
<ChartLegendWrapper colorSet={testColorSet}>
|
|
63
|
-
<Barchart type=
|
|
63
|
+
<Barchart type={{ type: 'category' }} bars={testBars} />
|
|
64
64
|
</ChartLegendWrapper>
|
|
65
65
|
</Wrapper>,
|
|
66
66
|
);
|
|
@@ -98,7 +98,7 @@ describe('Barchart', () => {
|
|
|
98
98
|
render(
|
|
99
99
|
<Wrapper>
|
|
100
100
|
<ChartLegendWrapper colorSet={testColorSet}>
|
|
101
|
-
<Barchart type=
|
|
101
|
+
<Barchart type={{ type: 'category' }} bars={[]} isError />
|
|
102
102
|
</ChartLegendWrapper>
|
|
103
103
|
</Wrapper>,
|
|
104
104
|
);
|
|
@@ -111,7 +111,7 @@ describe('Barchart', () => {
|
|
|
111
111
|
render(
|
|
112
112
|
<Wrapper>
|
|
113
113
|
<ChartLegendWrapper colorSet={testColorSet}>
|
|
114
|
-
<Barchart type=
|
|
114
|
+
<Barchart type={{ type: 'category' }} bars={[]} isLoading />
|
|
115
115
|
</ChartLegendWrapper>
|
|
116
116
|
</Wrapper>,
|
|
117
117
|
);
|
|
@@ -122,7 +122,7 @@ describe('Barchart', () => {
|
|
|
122
122
|
render(
|
|
123
123
|
<Wrapper>
|
|
124
124
|
<ChartLegendWrapper colorSet={testColorSet}>
|
|
125
|
-
<Barchart type=
|
|
125
|
+
<Barchart type={{ type: 'category' }} bars={undefined} />
|
|
126
126
|
</ChartLegendWrapper>
|
|
127
127
|
</Wrapper>,
|
|
128
128
|
);
|
|
@@ -316,7 +316,11 @@ describe('Barchart', () => {
|
|
|
316
316
|
render(
|
|
317
317
|
<Wrapper>
|
|
318
318
|
<ChartLegendWrapper colorSet={{ ...testColorSet, Failed: 'red' }}>
|
|
319
|
-
<Barchart
|
|
319
|
+
<Barchart
|
|
320
|
+
type={{ type: 'category' }}
|
|
321
|
+
bars={testStackedBars}
|
|
322
|
+
stacked
|
|
323
|
+
/>
|
|
320
324
|
</ChartLegendWrapper>
|
|
321
325
|
</Wrapper>,
|
|
322
326
|
);
|
|
@@ -344,7 +348,7 @@ describe('Barchart', () => {
|
|
|
344
348
|
<Wrapper>
|
|
345
349
|
<ChartLegendWrapper colorSet={testColorSet}>
|
|
346
350
|
<Barchart
|
|
347
|
-
type=
|
|
351
|
+
type={{ type: 'category' }}
|
|
348
352
|
bars={testBars}
|
|
349
353
|
defaultSort={(pointA, pointB) => {
|
|
350
354
|
const valueA = pointA.Success;
|
|
@@ -369,7 +373,7 @@ describe('Barchart', () => {
|
|
|
369
373
|
<Wrapper>
|
|
370
374
|
<ChartLegendWrapper colorSet={testColorSet}>
|
|
371
375
|
<Barchart
|
|
372
|
-
type=
|
|
376
|
+
type={{ type: 'category' }}
|
|
373
377
|
bars={[]}
|
|
374
378
|
title="Test Title"
|
|
375
379
|
secondaryTitle="Test Secondary Title"
|
|
@@ -45,6 +45,11 @@ export type TimeType = {
|
|
|
45
45
|
interval: number;
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
|
+
|
|
49
|
+
export type CategoryType = {
|
|
50
|
+
type: 'category';
|
|
51
|
+
gap?: number;
|
|
52
|
+
};
|
|
48
53
|
export type Point = {
|
|
49
54
|
key: string | number;
|
|
50
55
|
values: { label: string; value: number }[];
|
|
@@ -70,7 +75,7 @@ export type BarchartSortFn<T extends BarchartBars> = (
|
|
|
70
75
|
) => 1 | -1 | 0;
|
|
71
76
|
|
|
72
77
|
export type BarchartProps<T extends BarchartBars> = {
|
|
73
|
-
type:
|
|
78
|
+
type: CategoryType | TimeType;
|
|
74
79
|
bars?: T;
|
|
75
80
|
tooltip?: BarchartTooltipFn<T>;
|
|
76
81
|
defaultSort?: BarchartSortFn<T>;
|
|
@@ -260,7 +265,7 @@ export const Barchart = <T extends BarchartBars>(props: BarchartProps<T>) => {
|
|
|
260
265
|
const {
|
|
261
266
|
height = CHART_CONSTANTS.DEFAULT_HEIGHT,
|
|
262
267
|
bars,
|
|
263
|
-
type = 'category',
|
|
268
|
+
type = { type: 'category' },
|
|
264
269
|
unitRange,
|
|
265
270
|
stacked,
|
|
266
271
|
stackedBarSort = 'default',
|
|
@@ -314,9 +319,16 @@ export const Barchart = <T extends BarchartBars>(props: BarchartProps<T>) => {
|
|
|
314
319
|
<BarChart
|
|
315
320
|
data={rechartsData}
|
|
316
321
|
accessibilityLayer
|
|
317
|
-
barSize={
|
|
322
|
+
barSize={
|
|
323
|
+
type.type === 'category'
|
|
324
|
+
? type.gap === 0
|
|
325
|
+
? undefined
|
|
326
|
+
: CHART_CONSTANTS.BAR_SIZE
|
|
327
|
+
: CHART_CONSTANTS.BAR_SIZE
|
|
328
|
+
}
|
|
318
329
|
height={height}
|
|
319
330
|
margin={CHART_CONSTANTS.CHART_MARGIN}
|
|
331
|
+
barCategoryGap={type.type === 'category' ? type.gap : undefined}
|
|
320
332
|
>
|
|
321
333
|
<CartesianGrid
|
|
322
334
|
vertical={false}
|
|
@@ -570,7 +570,7 @@ describe('formatPrometheusDataToRechartsDataAndBars', () => {
|
|
|
570
570
|
|
|
571
571
|
const result = formatPrometheusDataToRechartsDataAndBars(
|
|
572
572
|
bars,
|
|
573
|
-
'category',
|
|
573
|
+
{ type: 'category' },
|
|
574
574
|
{
|
|
575
575
|
Success: coreUIAvailableThemes.darkRebrand.statusHealthy,
|
|
576
576
|
Failed: coreUIAvailableThemes.darkRebrand.statusCritical,
|
|
@@ -647,7 +647,7 @@ describe('formatPrometheusDataToRechartsDataAndBars', () => {
|
|
|
647
647
|
|
|
648
648
|
const result = formatPrometheusDataToRechartsDataAndBars(
|
|
649
649
|
bars,
|
|
650
|
-
'category',
|
|
650
|
+
{ type: 'category' },
|
|
651
651
|
mockTheme,
|
|
652
652
|
false,
|
|
653
653
|
(pointA, pointB) => {
|
|
@@ -271,11 +271,11 @@ export const formatPrometheusDataToRechartsDataAndBars = <
|
|
|
271
271
|
);
|
|
272
272
|
|
|
273
273
|
let data =
|
|
274
|
-
type !== 'category' && type.type === 'time'
|
|
274
|
+
type.type !== 'category' && type.type === 'time'
|
|
275
275
|
? transformTimeData(bars, type, barDataKeys)
|
|
276
276
|
: transformCategoryData(bars, barDataKeys);
|
|
277
277
|
|
|
278
|
-
if (type === 'category' && defaultSort) {
|
|
278
|
+
if (type.type === 'category' && defaultSort) {
|
|
279
279
|
data = applySortingToData(data, barDataKeys, defaultSort);
|
|
280
280
|
}
|
|
281
281
|
|