@scality/core-ui 0.163.0 → 0.165.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/barchartv2/Barchart.component.d.ts +10 -2
- package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
- package/dist/components/barchartv2/Barchart.component.js +20 -11
- package/dist/components/barchartv2/utils.d.ts +10 -3
- package/dist/components/barchartv2/utils.d.ts.map +1 -1
- package/dist/components/barchartv2/utils.js +45 -22
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/next.d.ts +2 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +2 -0
- package/package.json +1 -1
- package/src/lib/components/accordion/Accordion.test.tsx +1 -1
- package/src/lib/components/barchartv2/Barchart.component.test.tsx +41 -18
- package/src/lib/components/barchartv2/Barchart.component.tsx +56 -14
- package/src/lib/components/barchartv2/utils.test.ts +82 -47
- package/src/lib/components/barchartv2/utils.ts +53 -16
- package/src/lib/components/healthselectorv2/HealthSelector.component.test.tsx +7 -7
- package/src/lib/components/infomessage/InfoMessageUtils.test.tsx +0 -1
- package/src/lib/components/inlineinput/InlineInput.test.tsx +10 -7
- package/src/lib/components/inputlist/InputList.test.tsx +1 -2
- package/src/lib/components/linetemporalchart/ChartUtil.test.ts +5 -4
- package/src/lib/components/selectv2/selectv2.test.tsx +8 -4
- package/src/lib/components/tablev2/TableSync.test.tsx +2 -3
- package/src/lib/components/tablev2/TableUtils.test.ts +6 -3
- package/src/lib/components/tablev2/Tablev2.test.tsx +2 -3
- package/src/lib/components/toggle/Toggle.test.tsx +1 -1
- package/src/lib/index.ts +0 -1
- package/src/lib/next.ts +2 -0
- package/stories/BarChart/barchart.stories.tsx +96 -5
- package/tsconfig.json +0 -1
|
@@ -37,17 +37,25 @@ export type BarchartSortFn<T extends BarchartBars> = (pointA: Record<T[number]['
|
|
|
37
37
|
}) => 1 | -1 | 0;
|
|
38
38
|
export type BarchartProps<T extends BarchartBars> = {
|
|
39
39
|
type: 'category' | TimeType;
|
|
40
|
-
bars
|
|
40
|
+
bars?: T;
|
|
41
41
|
tooltip?: BarchartTooltipFn<T>;
|
|
42
42
|
defaultSort?: BarchartSortFn<T>;
|
|
43
43
|
unitRange?: UnitRange;
|
|
44
|
-
helpTooltip?:
|
|
44
|
+
helpTooltip?: React.ReactNode;
|
|
45
45
|
stacked?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Sort the bars by default or by legend order
|
|
48
|
+
* legend will sort the bars by the order of the colorSet property of the ChartLegendWrapper component
|
|
49
|
+
* default will sort the bars by average values in descending order (biggest values will be at bottom)
|
|
50
|
+
* @default 'default'
|
|
51
|
+
*/
|
|
52
|
+
stackedBarSort?: 'default' | 'legend';
|
|
46
53
|
title?: string;
|
|
47
54
|
secondaryTitle?: string;
|
|
48
55
|
rightTitle?: React.ReactNode;
|
|
49
56
|
height?: number;
|
|
50
57
|
isLoading?: boolean;
|
|
58
|
+
isError?: boolean;
|
|
51
59
|
};
|
|
52
60
|
export declare const Barchart: <T extends BarchartBars>(props: BarchartProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
53
61
|
//# sourceMappingURL=Barchart.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Barchart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/Barchart.component.tsx"],"names":[],"mappings":"AAoBA,OAAO,
|
|
1
|
+
{"version":3,"file":"Barchart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/Barchart.component.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAGL,SAAS,EAEV,MAAM,SAAS,CAAC;AAkBjB,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE;QACT,SAAS,EAAE,IAAI,CAAC;QAChB,OAAO,EAAE,IAAI,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;K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AG,QAAQ,CAAC;IAC5B,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAkIF,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,YAAY,SAAS,aAAa,CAAC,CAAC,CAAC,4CAwIvE,CAAC"}
|
|
@@ -9,12 +9,12 @@ import { ConstrainedText } from '../constrainedtext/Constrainedtext.component';
|
|
|
9
9
|
import { IconHelp } from '../iconhelper/IconHelper';
|
|
10
10
|
import { Loader } from '../loader/Loader.component';
|
|
11
11
|
import { Text } from '../text/Text.component';
|
|
12
|
-
import { renderTooltipContent, useChartData } from './utils';
|
|
12
|
+
import { formatDate, renderTooltipContent, useChartData, } from './utils';
|
|
13
13
|
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
14
14
|
const CHART_CONSTANTS = {
|
|
15
15
|
TICK_WIDTH_OFFSET: 5,
|
|
16
16
|
BAR_SIZE: 12,
|
|
17
|
-
MIN_POINT_SIZE:
|
|
17
|
+
MIN_POINT_SIZE: 3,
|
|
18
18
|
DEFAULT_HEIGHT: 200,
|
|
19
19
|
CHART_MARGIN: {
|
|
20
20
|
left: 0,
|
|
@@ -24,11 +24,13 @@ const CHART_CONSTANTS = {
|
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
26
|
/* ---------------------------------- COMPONENTS ---------------------------------- */
|
|
27
|
-
const CustomTick = ({ x, y, payload, visibleTicksCount, width, }) => {
|
|
27
|
+
const CustomTick = ({ x, y, payload, visibleTicksCount, width, type, }) => {
|
|
28
28
|
const theme = useTheme();
|
|
29
29
|
const tickWidth = width / visibleTicksCount - CHART_CONSTANTS.TICK_WIDTH_OFFSET;
|
|
30
30
|
const centerX = x - tickWidth / 2;
|
|
31
|
-
return (_jsx("foreignObject", { x: centerX, y: y, width: tickWidth, color: theme.textSecondary, overflow: "visible", children: _jsx(ConstrainedText, { text: _jsx(Text, { variant: "Smaller", color: "textSecondary", children:
|
|
31
|
+
return (_jsx("foreignObject", { x: centerX, y: y, width: tickWidth, color: theme.textSecondary, overflow: "visible", children: _jsx(ConstrainedText, { text: _jsx(Text, { variant: "Smaller", color: "textSecondary", children: type.type === 'time'
|
|
32
|
+
? formatDate(new Date(payload.value), type.timeRange.interval)
|
|
33
|
+
: String(payload.value) }), centered: true, tooltipStyle: {
|
|
32
34
|
backgroundColor: theme.backgroundLevel1,
|
|
33
35
|
padding: spacing.r10,
|
|
34
36
|
borderRadius: spacing.r8,
|
|
@@ -43,10 +45,17 @@ const StyledResponsiveContainer = styled(ResponsiveContainer) `
|
|
|
43
45
|
}
|
|
44
46
|
`;
|
|
45
47
|
const ChartHeader = ({ title, secondaryTitle, helpTooltip, rightTitle, }) => {
|
|
46
|
-
return (_jsxs(Wrap, { children: [_jsxs(Stack, { gap: "r4", children: [_jsx(Text, { variant: "ChartTitle", children: title }), helpTooltip &&
|
|
48
|
+
return (_jsxs(Wrap, { children: [_jsxs(Stack, { gap: "r4", children: [_jsx(Text, { variant: "ChartTitle", children: title }), helpTooltip && _jsx(IconHelp, { tooltipMessage: helpTooltip }), secondaryTitle && (_jsx(Text, { color: "textSecondary", style: {
|
|
47
49
|
marginLeft: spacing.r8,
|
|
48
50
|
}, children: secondaryTitle }))] }), rightTitle && _jsx(Text, { children: rightTitle })] }));
|
|
49
51
|
};
|
|
52
|
+
const Error = ({ height }) => {
|
|
53
|
+
return (_jsx(Box, { height: height, style: {
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
display: 'flex',
|
|
57
|
+
}, children: _jsx(Text, { children: "Chart data is not available" }) }));
|
|
58
|
+
};
|
|
50
59
|
const Loading = ({ height }) => {
|
|
51
60
|
return (_jsx(Box, { height: height, style: {
|
|
52
61
|
alignItems: 'center',
|
|
@@ -59,26 +68,26 @@ export const Barchart = (props) => {
|
|
|
59
68
|
const theme = useTheme();
|
|
60
69
|
const { getColor } = useChartLegend();
|
|
61
70
|
const [hoveredValue, setHoveredValue] = useState();
|
|
62
|
-
const { height = CHART_CONSTANTS.DEFAULT_HEIGHT, bars, type = 'category', unitRange, stacked, defaultSort, tooltip, title, secondaryTitle, helpTooltip, rightTitle, isLoading, } = props;
|
|
71
|
+
const { height = CHART_CONSTANTS.DEFAULT_HEIGHT, bars, type = 'category', unitRange, stacked, stackedBarSort = 'default', defaultSort, tooltip, title, secondaryTitle, helpTooltip, rightTitle, isLoading, isError, } = props;
|
|
63
72
|
// Create colorSet from ChartLegendWrapper
|
|
64
|
-
const colorSet = bars.reduce((acc, bar) => {
|
|
73
|
+
const colorSet = bars === null || bars === void 0 ? void 0 : bars.reduce((acc, bar) => {
|
|
65
74
|
const color = getColor(bar.label);
|
|
66
75
|
if (color) {
|
|
67
76
|
acc[bar.label] = color;
|
|
68
77
|
}
|
|
69
78
|
return acc;
|
|
70
79
|
}, {});
|
|
71
|
-
const { rechartsBars, unitLabel, roundReferenceValue, rechartsData } = useChartData(bars, type, colorSet, stacked, defaultSort, unitRange);
|
|
72
|
-
return (_jsxs(Stack, { direction: "vertical", gap: "r8", children: [_jsx(ChartHeader, { title: title, secondaryTitle: secondaryTitle, helpTooltip: helpTooltip, rightTitle: rightTitle }), isLoading ? (_jsx(Loading, { height: height })) : (_jsx(StyledResponsiveContainer, { width: "100%", height: height, children: _jsxs(BarChart, { data: rechartsData, accessibilityLayer: true, barSize: CHART_CONSTANTS.BAR_SIZE, height: height, margin: CHART_CONSTANTS.CHART_MARGIN, children: [_jsx(CartesianGrid, { vertical: false, horizontal: false, fill: theme.backgroundLevel1 }), rechartsBars.map((bar) => {
|
|
80
|
+
const { rechartsBars, unitLabel, roundReferenceValue, rechartsData } = useChartData(bars || [], type, colorSet || {}, stacked, defaultSort, unitRange, stackedBarSort);
|
|
81
|
+
return (_jsxs(Stack, { direction: "vertical", gap: "r8", children: [_jsx(ChartHeader, { title: title, secondaryTitle: secondaryTitle, helpTooltip: helpTooltip, rightTitle: rightTitle }), isError || (!bars && !isLoading) ? (_jsx(Error, { height: height })) : isLoading ? (_jsx(Loading, { height: height })) : (_jsx(StyledResponsiveContainer, { width: "100%", height: height, children: _jsxs(BarChart, { data: rechartsData, accessibilityLayer: true, barSize: CHART_CONSTANTS.BAR_SIZE, height: height, margin: CHART_CONSTANTS.CHART_MARGIN, children: [_jsx(CartesianGrid, { vertical: false, horizontal: false, fill: theme.backgroundLevel1 }), rechartsBars.map((bar) => {
|
|
73
82
|
const { fill, dataKey, stackId } = bar;
|
|
74
|
-
return (_jsx(Bar, { dataKey: dataKey, fill: chartColors[fill] || fill, minPointSize: CHART_CONSTANTS.MIN_POINT_SIZE, stackId: stackId, onMouseOver: () => setHoveredValue(dataKey), onMouseLeave: () => setHoveredValue(undefined) }, dataKey));
|
|
83
|
+
return (_jsx(Bar, { dataKey: dataKey, fill: chartColors[fill] || fill, minPointSize: stacked ? 0 : CHART_CONSTANTS.MIN_POINT_SIZE, stackId: stackId, onMouseOver: () => setHoveredValue(dataKey), onMouseLeave: () => setHoveredValue(undefined) }, dataKey));
|
|
75
84
|
}), _jsx(YAxis, { tickCount: 1, unit: ` ${unitLabel}`, domain: [0, roundReferenceValue], tickFormatter: (value) => new Intl.NumberFormat('fr-FR').format(value.toFixed(0)) // Add a space as thousand separator
|
|
76
85
|
, axisLine: false, tick: {
|
|
77
86
|
fill: theme.textSecondary,
|
|
78
87
|
fontSize: fontSize.smaller,
|
|
79
88
|
}, tickLine: false, label: {
|
|
80
89
|
fill: theme.textSecondary,
|
|
81
|
-
}, orientation: "right" }), _jsx(ReferenceLine, { y: roundReferenceValue, fill: theme.border, strokeWidth: 0.5 }), _jsx(XAxis, { dataKey: "category", tick: (props) => _jsx(CustomTick, { ...props }), type: "category", interval: 0, allowDataOverflow: true, tickLine: {
|
|
90
|
+
}, orientation: "right" }), _jsx(ReferenceLine, { y: roundReferenceValue, fill: theme.border, strokeWidth: 0.5 }), _jsx(XAxis, { dataKey: "category", tick: (props) => _jsx(CustomTick, { ...props, type: type }), type: "category", interval: 0, allowDataOverflow: true, tickLine: {
|
|
82
91
|
stroke: theme.textSecondary,
|
|
83
92
|
}, axisLine: {
|
|
84
93
|
stroke: theme.textSecondary,
|
|
@@ -5,6 +5,13 @@ export declare const getRoundReferenceValue: (value: number) => number;
|
|
|
5
5
|
export declare const getMaxBarValue: (data: {
|
|
6
6
|
[key: string]: string | number;
|
|
7
7
|
}[], stacked?: boolean) => number;
|
|
8
|
+
/**
|
|
9
|
+
* Formats a date based on the interval
|
|
10
|
+
* @param date - Date object
|
|
11
|
+
* @param interval - Interval in milliseconds
|
|
12
|
+
* @returns Formatted string
|
|
13
|
+
*/
|
|
14
|
+
export declare const formatDate: (date: Date, interval: number) => string;
|
|
8
15
|
/**
|
|
9
16
|
* Transforms time-based data into chart format
|
|
10
17
|
*/
|
|
@@ -38,7 +45,7 @@ export declare const applySortingToData: <T extends BarchartBars>(data: {
|
|
|
38
45
|
* @param type - The chart type (category or time)
|
|
39
46
|
* @returns Recharts data format
|
|
40
47
|
*/
|
|
41
|
-
export declare const formatPrometheusDataToRechartsDataAndBars: <T extends BarchartBars>(bars: T, type: BarchartProps<T>["type"], colorSet: Record<string, ChartColors | string>, stacked?: boolean, defaultSort?: BarchartProps<T>["defaultSort"]) => {
|
|
48
|
+
export declare const formatPrometheusDataToRechartsDataAndBars: <T extends BarchartBars>(bars: T, type: BarchartProps<T>["type"], colorSet: Record<string, ChartColors | string>, stacked?: boolean, defaultSort?: BarchartProps<T>["defaultSort"], legendOrder?: string[]) => {
|
|
42
49
|
data: {
|
|
43
50
|
[key: string]: string | number;
|
|
44
51
|
}[];
|
|
@@ -76,7 +83,7 @@ export declare const sortStackedBars: (rechartsBars: {
|
|
|
76
83
|
stackId?: string;
|
|
77
84
|
}[], data: {
|
|
78
85
|
[key: string]: string | number;
|
|
79
|
-
}[], stacked?: boolean) => {
|
|
86
|
+
}[], stacked?: boolean, legendOrder?: string[]) => {
|
|
80
87
|
dataKey: string;
|
|
81
88
|
fill: string;
|
|
82
89
|
stackId?: string;
|
|
@@ -105,7 +112,7 @@ export declare const filterChartDataAndBarsByLegendSelection: (data: {
|
|
|
105
112
|
stackId?: string;
|
|
106
113
|
}[];
|
|
107
114
|
};
|
|
108
|
-
export declare const useChartData: <T extends BarchartBars>(bars: T, type: BarchartProps<T>["type"], colorSet: Record<string, ChartColors | string>, stacked?: boolean, defaultSort?: BarchartProps<T>["defaultSort"], unitRange?: UnitRange) => {
|
|
115
|
+
export declare const useChartData: <T extends BarchartBars>(bars: T, type: BarchartProps<T>["type"], colorSet: Record<string, ChartColors | string>, stacked?: boolean, defaultSort?: BarchartProps<T>["defaultSort"], unitRange?: UnitRange, stackedBarSort?: "default" | "legend") => {
|
|
109
116
|
rechartsBars: {
|
|
110
117
|
dataKey: string;
|
|
111
118
|
fill: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAe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oBAAoB,GAAI,CAAC,SAAS,YAAY,SAClD,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,WACjC,iBAAiB,CAAC,CAAC,CAAC,GAAG,SAAS,gBAC3B,MAAM,GAAG,SAAS,8BAwBjC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uCAAuC,SAC5C;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;CAAE,EAAE,gBAC5B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,qBAChD,MAAM,EAAE;;;;;iBADF,MAAM;cAAQ,MAAM;kBAAY,MAAM;;CA2BhE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,YAAY,QAC3C,CAAC,QACD,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,YACpB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,YACpC,OAAO,gBACH,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,cACjC,SAAS,mBACJ,SAAS,GAAG,QAAQ;;iBApCZ,MAAM;cAAQ,MAAM;kBAAY,MAAM;;;;;CAuEhE,CAAC"}
|
|
@@ -9,13 +9,17 @@ export const getRoundReferenceValue = (value) => {
|
|
|
9
9
|
// Normalized value between 1 and 10
|
|
10
10
|
const normalized = value / magnitude;
|
|
11
11
|
// Round to nice numbers based on normalized value
|
|
12
|
+
let result;
|
|
12
13
|
if (normalized <= 1)
|
|
13
|
-
|
|
14
|
-
if (normalized <= 2.5)
|
|
15
|
-
|
|
16
|
-
if (normalized <= 5)
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
result = magnitude;
|
|
15
|
+
else if (normalized <= 2.5)
|
|
16
|
+
result = 2.5 * magnitude;
|
|
17
|
+
else if (normalized <= 5)
|
|
18
|
+
result = 5 * magnitude;
|
|
19
|
+
else
|
|
20
|
+
result = 10 * magnitude;
|
|
21
|
+
// Ensure minimum value of 5 for better chart appearance
|
|
22
|
+
return Math.max(result, 5);
|
|
19
23
|
};
|
|
20
24
|
export const getMaxBarValue = (data, stacked) => {
|
|
21
25
|
const values = data.map((item) => {
|
|
@@ -34,9 +38,9 @@ export const getMaxBarValue = (data, stacked) => {
|
|
|
34
38
|
.filter((key) => key !== 'category')
|
|
35
39
|
.map((key) => Number(item[key]));
|
|
36
40
|
// Get the max value among the values in the object (corresponding to one bar)
|
|
37
|
-
return Math.max(...numberValues);
|
|
41
|
+
return Math.max(...numberValues, 0); // Ensure we don't get -Infinity
|
|
38
42
|
});
|
|
39
|
-
return Math.max(...values);
|
|
43
|
+
return Math.max(...values, 0);
|
|
40
44
|
};
|
|
41
45
|
/**
|
|
42
46
|
* Generates time ranges between start and end dates based on the given interval
|
|
@@ -47,9 +51,6 @@ export const getMaxBarValue = (data, stacked) => {
|
|
|
47
51
|
*/
|
|
48
52
|
const generateTimeRanges = (startDate, endDate, interval) => {
|
|
49
53
|
const ranges = [];
|
|
50
|
-
if (!startDate || !endDate || !interval) {
|
|
51
|
-
return ranges;
|
|
52
|
-
}
|
|
53
54
|
let currentDate = new Date(startDate.getTime());
|
|
54
55
|
while (currentDate.getTime() <= endDate.getTime()) {
|
|
55
56
|
const rangeEnd = new Date(currentDate.getTime() + interval);
|
|
@@ -67,7 +68,7 @@ const generateTimeRanges = (startDate, endDate, interval) => {
|
|
|
67
68
|
* @param interval - Interval in milliseconds
|
|
68
69
|
* @returns Formatted string
|
|
69
70
|
*/
|
|
70
|
-
const formatDate = (date, interval) => {
|
|
71
|
+
export const formatDate = (date, interval) => {
|
|
71
72
|
if (interval > 24 * 60 * 60 * 1000) {
|
|
72
73
|
return (DAY_MONTH_FORMATER.format(date).replace(/[ ,]/g, '') +
|
|
73
74
|
' ' +
|
|
@@ -104,7 +105,8 @@ export const transformTimeData = (bars, type, barDataKeys) => {
|
|
|
104
105
|
const categoryMap = new Map();
|
|
105
106
|
// Initialize all ranges with zeros
|
|
106
107
|
timeRanges.forEach((range) => {
|
|
107
|
-
const categoryDisplay = formatDate(range.start, type.timeRange.interval);
|
|
108
|
+
// const categoryDisplay = formatDate(range.start, type.timeRange.interval);
|
|
109
|
+
const categoryDisplay = range.start.getTime();
|
|
108
110
|
const initialData = {
|
|
109
111
|
category: categoryDisplay,
|
|
110
112
|
};
|
|
@@ -198,7 +200,7 @@ const getRechartsBarsAndBarDataKeys = (bars, colorSet, stacked) => {
|
|
|
198
200
|
* @param type - The chart type (category or time)
|
|
199
201
|
* @returns Recharts data format
|
|
200
202
|
*/
|
|
201
|
-
export const formatPrometheusDataToRechartsDataAndBars = (bars, type, colorSet, stacked, defaultSort) => {
|
|
203
|
+
export const formatPrometheusDataToRechartsDataAndBars = (bars, type, colorSet, stacked, defaultSort, legendOrder) => {
|
|
202
204
|
const { rechartsBars, barDataKeys } = getRechartsBarsAndBarDataKeys(bars, colorSet, stacked);
|
|
203
205
|
let data = type !== 'category' && type.type === 'time'
|
|
204
206
|
? transformTimeData(bars, type, barDataKeys)
|
|
@@ -206,7 +208,7 @@ export const formatPrometheusDataToRechartsDataAndBars = (bars, type, colorSet,
|
|
|
206
208
|
if (type === 'category' && defaultSort) {
|
|
207
209
|
data = applySortingToData(data, barDataKeys, defaultSort);
|
|
208
210
|
}
|
|
209
|
-
const sortedRechartsBars = sortStackedBars(rechartsBars, data, stacked);
|
|
211
|
+
const sortedRechartsBars = sortStackedBars(rechartsBars, data, stacked, legendOrder);
|
|
210
212
|
return {
|
|
211
213
|
rechartsBars: sortedRechartsBars,
|
|
212
214
|
data,
|
|
@@ -217,7 +219,7 @@ export const computeUnitLabelAndRoundReferenceValue = (data, maxValue, unitRange
|
|
|
217
219
|
const roundReferenceValue = getRoundReferenceValue(maxValue);
|
|
218
220
|
return { unitLabel: '', roundReferenceValue, rechartsData: data };
|
|
219
221
|
}
|
|
220
|
-
const { valueBase, unitLabel } = getUnitLabel(unitRange
|
|
222
|
+
const { valueBase, unitLabel } = getUnitLabel(unitRange, maxValue);
|
|
221
223
|
const topValue = Math.ceil(maxValue / valueBase / 10) * 10;
|
|
222
224
|
const roundReferenceValue = getRoundReferenceValue(topValue);
|
|
223
225
|
const rechartsData = data.map((dataPoint) => {
|
|
@@ -259,12 +261,31 @@ export function getUnitLabel(unitRange, maxValue) {
|
|
|
259
261
|
unitLabel: unitRange[index - 1].label,
|
|
260
262
|
};
|
|
261
263
|
}
|
|
262
|
-
// Sort stacked bars by their average values in descending order
|
|
263
|
-
// This ensures the largest bars appear at the bottom of the stack
|
|
264
|
-
export const sortStackedBars = (rechartsBars, data, stacked) => {
|
|
264
|
+
// Sort stacked bars by their average values in descending order or by legend order
|
|
265
|
+
// This ensures the largest bars appear at the bottom of the stack (default) or follow legend order
|
|
266
|
+
export const sortStackedBars = (rechartsBars, data, stacked, legendOrder) => {
|
|
265
267
|
if (!stacked) {
|
|
266
268
|
return rechartsBars;
|
|
267
269
|
}
|
|
270
|
+
// If legend order is provided, sort by legend order
|
|
271
|
+
if (legendOrder && legendOrder.length > 0) {
|
|
272
|
+
return [...rechartsBars].sort((a, b) => {
|
|
273
|
+
const indexA = legendOrder.indexOf(a.dataKey);
|
|
274
|
+
const indexB = legendOrder.indexOf(b.dataKey);
|
|
275
|
+
// If both items are in legend order, sort by their position
|
|
276
|
+
if (indexA !== -1 && indexB !== -1) {
|
|
277
|
+
return indexA - indexB;
|
|
278
|
+
}
|
|
279
|
+
// If only one item is in legend order, prioritize it
|
|
280
|
+
if (indexA !== -1)
|
|
281
|
+
return -1;
|
|
282
|
+
if (indexB !== -1)
|
|
283
|
+
return 1;
|
|
284
|
+
// If neither is in legend order, maintain original order
|
|
285
|
+
return 0;
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
// Default behavior: sort by average values
|
|
268
289
|
const barAverages = rechartsBars.map((bar) => {
|
|
269
290
|
const values = data
|
|
270
291
|
.map((item) => Number(item[bar.dataKey]) || 0)
|
|
@@ -321,9 +342,11 @@ export const filterChartDataAndBarsByLegendSelection = (data, rechartsBars, sele
|
|
|
321
342
|
});
|
|
322
343
|
return { filteredData, filteredRechartsBars };
|
|
323
344
|
};
|
|
324
|
-
export const useChartData = (bars, type, colorSet, stacked, defaultSort, unitRange) => {
|
|
325
|
-
const { selectedResources } = useChartLegend();
|
|
326
|
-
|
|
345
|
+
export const useChartData = (bars, type, colorSet, stacked, defaultSort, unitRange, stackedBarSort) => {
|
|
346
|
+
const { selectedResources, listResources } = useChartLegend();
|
|
347
|
+
// Get legend order when stackedBarSort is 'legend'
|
|
348
|
+
const legendOrder = stackedBarSort === 'legend' ? listResources() : undefined;
|
|
349
|
+
const { data, rechartsBars } = formatPrometheusDataToRechartsDataAndBars(bars, type, colorSet, stacked, defaultSort, legendOrder);
|
|
327
350
|
// Filter both data and bars to only include selected resources for accurate maxValue calculation
|
|
328
351
|
const { filteredData, filteredRechartsBars } = filterChartDataAndBarsByLegendSelection(data, rechartsBars, selectedResources);
|
|
329
352
|
const maxValue = getMaxBarValue(filteredData, stacked);
|
package/dist/index.d.ts
CHANGED
|
@@ -61,5 +61,4 @@ export { InfoMessage } from './components/infomessage/InfoMessage.component';
|
|
|
61
61
|
export { InputList } from './components/inputlist/InputList.component';
|
|
62
62
|
export { InlineInput } from './components/inlineinput/InlineInput';
|
|
63
63
|
export { UnsuccessfulResult } from './components/UnsuccessfulResult.component';
|
|
64
|
-
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
|
65
64
|
//# 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,MAAM,EAAE,MAAM,sCA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AAO,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"}
|
package/dist/index.js
CHANGED
|
@@ -61,4 +61,3 @@ export { InfoMessage } from './components/infomessage/InfoMessage.component';
|
|
|
61
61
|
export { InputList } from './components/inputlist/InputList.component';
|
|
62
62
|
export { InlineInput } from './components/inlineinput/InlineInput';
|
|
63
63
|
export { UnsuccessfulResult } from './components/UnsuccessfulResult.component';
|
|
64
|
-
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
package/dist/next.d.ts
CHANGED
|
@@ -15,4 +15,6 @@ export { Input } from './components/inputv2/inputv2';
|
|
|
15
15
|
export { Accordion } from './components/accordion/Accordion.component';
|
|
16
16
|
export { Barchart, BarchartSortFn, BarchartTooltipFn, } from './components/barchartv2/Barchart.component';
|
|
17
17
|
export { ChartLegendWrapper } from './components/chartlegend/ChartLegendWrapper';
|
|
18
|
+
export { ChartLegend } from './components/chartlegend/ChartLegend';
|
|
19
|
+
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
|
18
20
|
//# 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,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,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,kBAAkB,EAAE,MAAM,6CAA6C,CAAC"}
|
|
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,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,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,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC"}
|
package/dist/next.js
CHANGED
|
@@ -15,3 +15,5 @@ export { Input } from './components/inputv2/inputv2';
|
|
|
15
15
|
export { Accordion } from './components/accordion/Accordion.component';
|
|
16
16
|
export { Barchart, } from './components/barchartv2/Barchart.component';
|
|
17
17
|
export { ChartLegendWrapper } from './components/chartlegend/ChartLegendWrapper';
|
|
18
|
+
export { ChartLegend } from './components/chartlegend/ChartLegend';
|
|
19
|
+
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import { getWrapper } from '../../testUtils';
|
|
4
3
|
import { Barchart } from './Barchart.component';
|
|
5
4
|
import { ChartLegendWrapper } from '../chartlegend/ChartLegendWrapper';
|
|
@@ -15,7 +14,7 @@ jest.mock('recharts', () => {
|
|
|
15
14
|
...OriginalResponsiveContainerModule,
|
|
16
15
|
ResponsiveContainer: ({ height, children }) => (
|
|
17
16
|
<OriginalResponsiveContainerModule.ResponsiveContainer
|
|
18
|
-
|
|
17
|
+
aspect={3}
|
|
19
18
|
height={300}
|
|
20
19
|
data-testid="responsive-container"
|
|
21
20
|
>
|
|
@@ -93,6 +92,43 @@ describe('Barchart', () => {
|
|
|
93
92
|
expect(screen.getByText('Sat06Jul')).toBeInTheDocument();
|
|
94
93
|
expect(screen.getByText('Sun07Jul')).toBeInTheDocument();
|
|
95
94
|
});
|
|
95
|
+
it('should render the Barchart component with error state', async () => {
|
|
96
|
+
const { Wrapper } = getWrapper();
|
|
97
|
+
render(
|
|
98
|
+
<Wrapper>
|
|
99
|
+
<ChartLegendWrapper colorSet={testColorSet}>
|
|
100
|
+
<Barchart type="category" bars={[]} isError />
|
|
101
|
+
</ChartLegendWrapper>
|
|
102
|
+
</Wrapper>,
|
|
103
|
+
);
|
|
104
|
+
expect(
|
|
105
|
+
screen.getByText('Chart data is not available'),
|
|
106
|
+
).toBeInTheDocument();
|
|
107
|
+
});
|
|
108
|
+
it('should render the Barchart component with loading state', async () => {
|
|
109
|
+
const { Wrapper } = getWrapper();
|
|
110
|
+
render(
|
|
111
|
+
<Wrapper>
|
|
112
|
+
<ChartLegendWrapper colorSet={testColorSet}>
|
|
113
|
+
<Barchart type="category" bars={[]} isLoading />
|
|
114
|
+
</ChartLegendWrapper>
|
|
115
|
+
</Wrapper>,
|
|
116
|
+
);
|
|
117
|
+
expect(screen.getByText('Loading Chart Data...')).toBeInTheDocument();
|
|
118
|
+
});
|
|
119
|
+
it('should render the Barchart component with undefined bars', async () => {
|
|
120
|
+
const { Wrapper } = getWrapper();
|
|
121
|
+
render(
|
|
122
|
+
<Wrapper>
|
|
123
|
+
<ChartLegendWrapper colorSet={testColorSet}>
|
|
124
|
+
<Barchart type="category" bars={undefined} />
|
|
125
|
+
</ChartLegendWrapper>
|
|
126
|
+
</Wrapper>,
|
|
127
|
+
);
|
|
128
|
+
expect(
|
|
129
|
+
screen.getByText('Chart data is not available'),
|
|
130
|
+
).toBeInTheDocument();
|
|
131
|
+
});
|
|
96
132
|
});
|
|
97
133
|
|
|
98
134
|
describe('Time data', () => {
|
|
@@ -278,7 +314,7 @@ describe('Barchart', () => {
|
|
|
278
314
|
const { Wrapper } = getWrapper();
|
|
279
315
|
render(
|
|
280
316
|
<Wrapper>
|
|
281
|
-
<ChartLegendWrapper colorSet={testColorSet}>
|
|
317
|
+
<ChartLegendWrapper colorSet={{ ...testColorSet, Failed: 'red' }}>
|
|
282
318
|
<Barchart type="category" bars={testStackedBars} stacked={true} />
|
|
283
319
|
</ChartLegendWrapper>
|
|
284
320
|
</Wrapper>,
|
|
@@ -326,18 +362,7 @@ describe('Barchart', () => {
|
|
|
326
362
|
expect(categories[2]).toHaveTextContent('category1'); // 10 (lowest)
|
|
327
363
|
});
|
|
328
364
|
|
|
329
|
-
it('should render
|
|
330
|
-
const { Wrapper } = getWrapper();
|
|
331
|
-
render(
|
|
332
|
-
<Wrapper>
|
|
333
|
-
<ChartLegendWrapper colorSet={testColorSet}>
|
|
334
|
-
<Barchart type="category" bars={[]} isLoading />
|
|
335
|
-
</ChartLegendWrapper>
|
|
336
|
-
</Wrapper>,
|
|
337
|
-
);
|
|
338
|
-
expect(screen.getByText('Loading Chart Data...')).toBeInTheDocument();
|
|
339
|
-
});
|
|
340
|
-
it('should render header with title, secondary title, right title and help tooltip', async () => {
|
|
365
|
+
it('should render header with title, secondary title, right title and helpIcon', async () => {
|
|
341
366
|
const { Wrapper } = getWrapper();
|
|
342
367
|
render(
|
|
343
368
|
<Wrapper>
|
|
@@ -357,8 +382,6 @@ describe('Barchart', () => {
|
|
|
357
382
|
expect(screen.getByText('Test Title')).toBeInTheDocument();
|
|
358
383
|
expect(screen.getByText('Test Secondary Title')).toBeInTheDocument();
|
|
359
384
|
expect(screen.getByText('Test Right Title')).toBeInTheDocument();
|
|
360
|
-
|
|
361
|
-
expect(screen.getByLabelText('Test Help Tooltip')).toBeInTheDocument();
|
|
362
|
-
});
|
|
385
|
+
expect(screen.getByLabelText('Info')).toBeInTheDocument();
|
|
363
386
|
});
|
|
364
387
|
});
|