@scality/core-ui 0.170.0 → 0.171.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/uuid.js +11 -0
- package/dist/components/barchartv2/Barchart.component.js +2 -2
- package/dist/components/chartlegend/ChartLegend.d.ts +3 -1
- package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegend.js +2 -2
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts +3 -1
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegendWrapper.js +43 -9
- package/dist/components/icon/Icon.component.d.ts +2 -0
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +2 -0
- package/dist/components/linetemporalchart/ChartUtil.d.ts.map +1 -1
- package/dist/components/linetemporalchart/ChartUtil.js +12 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +10 -5
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +84 -49
- package/dist/components/text/Text.component.d.ts +2 -1
- package/dist/components/text/Text.component.d.ts.map +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +1 -1
- package/package.json +3 -1
- package/src/lib/components/barchartv2/Barchart.component.tsx +2 -2
- package/src/lib/components/chartlegend/ChartLegend.tsx +4 -2
- package/src/lib/components/chartlegend/ChartLegendWrapper.test.tsx +197 -0
- package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +65 -9
- package/src/lib/components/icon/Icon.component.tsx +2 -0
- package/src/lib/components/linetemporalchart/ChartUtil.ts +26 -0
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +227 -157
- package/src/lib/components/text/Text.component.tsx +8 -1
- package/src/lib/next.ts +4 -1
- package/stories/BarChart/barchart.stories.tsx +7 -1
- package/stories/linetimeseriechart.stories.tsx +217 -1
|
@@ -14,13 +14,13 @@ import { Text } from '../text/Text.component';
|
|
|
14
14
|
import { ChartTooltip } from './ChartTooltip';
|
|
15
15
|
import { useChartData } from './utils';
|
|
16
16
|
const CHART_CONSTANTS = {
|
|
17
|
-
TICK_WIDTH_OFFSET:
|
|
17
|
+
TICK_WIDTH_OFFSET: 4,
|
|
18
18
|
BAR_SIZE: 12,
|
|
19
19
|
MIN_POINT_SIZE: 3,
|
|
20
20
|
DEFAULT_HEIGHT: 200,
|
|
21
21
|
CHART_MARGIN: {
|
|
22
22
|
left: 0,
|
|
23
|
-
right:
|
|
23
|
+
right: -10,
|
|
24
24
|
top: 0,
|
|
25
25
|
bottom: 0,
|
|
26
26
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { TextVariant } from '../text/Text.component';
|
|
1
2
|
type ChartLegendProps = {
|
|
2
3
|
shape: 'line' | 'rectangle';
|
|
3
4
|
disabled?: boolean;
|
|
4
5
|
direction?: 'horizontal' | 'vertical';
|
|
6
|
+
legendSize?: TextVariant;
|
|
5
7
|
};
|
|
6
8
|
export declare const LegendItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
7
9
|
disabled?: boolean;
|
|
@@ -12,6 +14,6 @@ export declare const LegendShape: import("styled-components").StyledComponent<"d
|
|
|
12
14
|
shape: "line" | "rectangle";
|
|
13
15
|
chartColors: Record<string, string>;
|
|
14
16
|
}, never>;
|
|
15
|
-
export declare const ChartLegend: ({ shape, disabled, direction, }: ChartLegendProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const ChartLegend: ({ shape, disabled, direction, legendSize, }: ChartLegendProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
18
|
export {};
|
|
17
19
|
//# sourceMappingURL=ChartLegend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartLegend.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegend.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChartLegend.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegend.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAI3D,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"}
|
|
@@ -44,7 +44,7 @@ export const LegendShape = styled.div `
|
|
|
44
44
|
}
|
|
45
45
|
}}
|
|
46
46
|
`;
|
|
47
|
-
export const ChartLegend = ({ shape, disabled = false, direction = 'horizontal', }) => {
|
|
47
|
+
export const ChartLegend = ({ shape, disabled = false, direction = 'horizontal', legendSize = 'Basic', }) => {
|
|
48
48
|
const { listResources, getColor, isSelected, addSelectedResource, removeSelectedResource, selectAllResources, selectOnlyResource, isOnlyOneSelected, } = useChartLegend();
|
|
49
49
|
const resources = listResources();
|
|
50
50
|
const handleLegendClick = useCallback((resource, event) => {
|
|
@@ -83,6 +83,6 @@ export const ChartLegend = ({ shape, disabled = false, direction = 'horizontal',
|
|
|
83
83
|
return (_jsx(Legend, { direction: direction, children: resources.map((resource) => {
|
|
84
84
|
const color = getColor(resource);
|
|
85
85
|
const selected = isSelected(resource);
|
|
86
|
-
return (_jsxs(LegendItem, { disabled: disabled, selected: selected, "aria-label": `${resource} ${selected ? 'selected' : 'not selected'}`, onClick: (event) => handleLegendClick(resource, event), children: [_jsx(LegendShape, { color: color, shape: shape, chartColors: chartColors }), _jsx(Text, { variant:
|
|
86
|
+
return (_jsxs(LegendItem, { disabled: disabled, selected: selected, "aria-label": `${resource} ${selected ? 'selected' : 'not selected'}`, onClick: (event) => handleLegendClick(resource, event), children: [_jsx(LegendShape, { color: color, shape: shape, chartColors: chartColors }), _jsx(Text, { variant: legendSize, children: resource })] }, resource));
|
|
87
87
|
}) }));
|
|
88
88
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ChartColors } from '../../style/theme';
|
|
3
|
+
export declare const useChartId: () => string;
|
|
3
4
|
export type ChartLegendState = {
|
|
4
5
|
selectedResources: string[];
|
|
5
6
|
addSelectedResource: (resource: string) => void;
|
|
@@ -10,10 +11,11 @@ export type ChartLegendState = {
|
|
|
10
11
|
getColor: (resource: string) => string | undefined;
|
|
11
12
|
listResources: () => string[];
|
|
12
13
|
isOnlyOneSelected: () => boolean;
|
|
14
|
+
register: (chartId: string, seriesNames: string[]) => void;
|
|
13
15
|
};
|
|
14
16
|
export type ChartLegendWrapperProps = {
|
|
15
17
|
children: ReactNode;
|
|
16
|
-
colorSet: Record<string, ChartColors | string
|
|
18
|
+
colorSet: Record<string, ChartColors | string> | ((seriesNames: string[]) => Record<string, ChartColors | string>);
|
|
17
19
|
};
|
|
18
20
|
export declare const ChartLegendWrapper: ({ children, colorSet, }: ChartLegendWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
21
|
export declare const useChartLegend: () => ChartLegendState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartLegendWrapper.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegendWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,
|
|
1
|
+
{"version":3,"file":"ChartLegendWrapper.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/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
-
import { createContext, useContext, useState, useMemo, useCallback, } from 'react';
|
|
2
|
+
import { createContext, useContext, useState, useMemo, useCallback, useEffect, useRef, } from 'react';
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
+
export const useChartId = () => {
|
|
5
|
+
const idRef = useRef(null);
|
|
6
|
+
if (idRef.current === null) {
|
|
7
|
+
idRef.current = uuidv4();
|
|
8
|
+
}
|
|
9
|
+
return idRef.current;
|
|
10
|
+
};
|
|
3
11
|
const ChartLegendContext = createContext(null);
|
|
4
12
|
export const ChartLegendWrapper = ({ children, colorSet, }) => {
|
|
5
|
-
const
|
|
13
|
+
const [registeredColorSets, setRegisteredColorSets] = useState({});
|
|
14
|
+
const [internalColorSet, setInternalColorSet] = useState(() => {
|
|
15
|
+
return typeof colorSet === 'function' ? {} : colorSet;
|
|
16
|
+
});
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (typeof colorSet === 'function') {
|
|
19
|
+
const allUniqueSeriesNames = Array.from(new Set(Object.values(registeredColorSets).flat()));
|
|
20
|
+
if (allUniqueSeriesNames.length > 0) {
|
|
21
|
+
const newColorSet = colorSet(allUniqueSeriesNames);
|
|
22
|
+
setInternalColorSet(newColorSet);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
setInternalColorSet(colorSet);
|
|
27
|
+
}
|
|
28
|
+
}, [registeredColorSets, colorSet]);
|
|
29
|
+
const allResources = useMemo(() => Object.keys(internalColorSet), [internalColorSet]);
|
|
6
30
|
const [selectedResources, setSelectedResources] = useState(allResources);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setSelectedResources(allResources);
|
|
33
|
+
}, [allResources]);
|
|
34
|
+
const register = useCallback((chartId, seriesNames) => {
|
|
35
|
+
setRegisteredColorSets((prev) => ({
|
|
36
|
+
...prev,
|
|
37
|
+
[chartId]: seriesNames,
|
|
38
|
+
}));
|
|
39
|
+
}, []);
|
|
7
40
|
const addSelectedResource = useCallback((resource) => {
|
|
8
41
|
setSelectedResources((prev) => prev.includes(resource) ? prev : [...prev, resource]);
|
|
9
42
|
}, []);
|
|
@@ -11,8 +44,8 @@ export const ChartLegendWrapper = ({ children, colorSet, }) => {
|
|
|
11
44
|
setSelectedResources((prev) => prev.filter((r) => r !== resource));
|
|
12
45
|
}, []);
|
|
13
46
|
const selectAllResources = useCallback(() => {
|
|
14
|
-
setSelectedResources(
|
|
15
|
-
}, [
|
|
47
|
+
setSelectedResources(Object.keys(internalColorSet));
|
|
48
|
+
}, [internalColorSet]);
|
|
16
49
|
const selectOnlyResource = useCallback((resource) => {
|
|
17
50
|
setSelectedResources([resource]);
|
|
18
51
|
}, []);
|
|
@@ -23,16 +56,16 @@ export const ChartLegendWrapper = ({ children, colorSet, }) => {
|
|
|
23
56
|
return selectedResources.includes(resource);
|
|
24
57
|
}, [selectedResources]);
|
|
25
58
|
const getColor = useCallback((resource) => {
|
|
26
|
-
const color =
|
|
59
|
+
const color = internalColorSet[resource];
|
|
27
60
|
if (!color) {
|
|
28
61
|
console.warn(`ChartLegendWrapper: No color defined for resource "${resource}"`);
|
|
29
62
|
return undefined;
|
|
30
63
|
}
|
|
31
64
|
return color;
|
|
32
|
-
}, [
|
|
65
|
+
}, [internalColorSet]);
|
|
33
66
|
const listResources = useCallback(() => {
|
|
34
|
-
return Object.keys(
|
|
35
|
-
}, [
|
|
67
|
+
return Object.keys(internalColorSet);
|
|
68
|
+
}, [internalColorSet]);
|
|
36
69
|
const chartLegendState = useMemo(() => ({
|
|
37
70
|
selectedResources,
|
|
38
71
|
addSelectedResource,
|
|
@@ -43,6 +76,7 @@ export const ChartLegendWrapper = ({ children, colorSet, }) => {
|
|
|
43
76
|
getColor,
|
|
44
77
|
listResources,
|
|
45
78
|
isOnlyOneSelected,
|
|
79
|
+
register,
|
|
46
80
|
}), [
|
|
47
81
|
selectedResources,
|
|
48
82
|
addSelectedResource,
|
|
@@ -53,10 +87,10 @@ export const ChartLegendWrapper = ({ children, colorSet, }) => {
|
|
|
53
87
|
getColor,
|
|
54
88
|
listResources,
|
|
55
89
|
isOnlyOneSelected,
|
|
90
|
+
register,
|
|
56
91
|
]);
|
|
57
92
|
return (_jsx(ChartLegendContext.Provider, { value: chartLegendState, children: children }));
|
|
58
93
|
};
|
|
59
|
-
// Hook for accessing legend state in custom components
|
|
60
94
|
export const useChartLegend = () => {
|
|
61
95
|
const context = useContext(ChartLegendContext);
|
|
62
96
|
if (!context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/icon/Icon.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EACL,aAAa,EAKd,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOhD,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"Icon.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/icon/Icon.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EACL,aAAa,EAKd,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOhD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+HrB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAOtG,CAAC;AAgBF,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,SAAS,GAAG,MAAM,OAAO,WAAW,CAAC;AACzE,MAAM,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC;AAC1C,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAiBF,eAAO,MAAM,WAAW;UAAsB,QAAQ;SAiCrD,CAAC;AA2DF,iBAAS,IAAI,CAAC,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,2CAU7C;AAED,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -131,6 +131,8 @@ export const iconTable = {
|
|
|
131
131
|
Stop: 'fas faStop',
|
|
132
132
|
Play: 'fas faPlay',
|
|
133
133
|
Mail: 'fas faEnvelope',
|
|
134
|
+
ThumbsUp: 'fas faThumbsUp',
|
|
135
|
+
ThumbsDown: 'fas faThumbsDown',
|
|
134
136
|
};
|
|
135
137
|
export const customIcons = {
|
|
136
138
|
'Remote-user': ({ 'aria-label': ariaLabel, color, size }) => (_jsx(RemoteUser, { ariaLabel: ariaLabel, color: color, size: size })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartUtil.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetemporalchart/ChartUtil.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,+BAA+B,CAAC;AAEvC,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;IAEtB,eAAe,EAAE,OAAO,CAAC;IAEzB,QAAQ,EAAE,OAAO,CAAC;CACnB,EAAE,CAAC;AAKJ,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,UAEtD;AACD,wBAAgB,gBAAgB,CAC9B,2BAA2B,EAAE,KAAK,EAAE,GACnC,QAAQ,CAqBV;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAU3E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE;IACT,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,EAAE,EACH,QAAQ,EAAE,MAAM,GACf;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAwCA;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,EACjD,iBAAiB,CAAC,EAAE,MAAM,EAC1B,cAAc,CAAC,EAAE,MAAM,EACvB,cAAc,CAAC,EAAE,MAAM,GACtB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"ChartUtil.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetemporalchart/ChartUtil.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE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Ae,WAAY,KAAK,EAAE,KAAG,MAAM,EAMvD,CAAC"}
|
|
@@ -94,8 +94,16 @@ export function addMissingDataPoint(orginalValues, startingTimeStamp, sampleDura
|
|
|
94
94
|
return [];
|
|
95
95
|
}
|
|
96
96
|
const newValues = [];
|
|
97
|
+
// add missing data points for the starting time
|
|
98
|
+
for (let i = startingTimeStamp; i < orginalValues[0][0]; i += sampleInterval) {
|
|
99
|
+
newValues.push([i, NAN_STRING]);
|
|
100
|
+
}
|
|
97
101
|
// Process all but the last element
|
|
98
102
|
for (let i = 0; i < orginalValues.length - 1; i++) {
|
|
103
|
+
if (orginalValues[i][0] < startingTimeStamp ||
|
|
104
|
+
orginalValues[i][0] > startingTimeStamp + sampleDuration) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
99
107
|
// Always add the current data point
|
|
100
108
|
newValues.push(orginalValues[i]);
|
|
101
109
|
const currentTimestamp = orginalValues[i][0];
|
|
@@ -111,6 +119,10 @@ export function addMissingDataPoint(orginalValues, startingTimeStamp, sampleDura
|
|
|
111
119
|
}
|
|
112
120
|
// Add the last element
|
|
113
121
|
newValues.push(orginalValues[orginalValues.length - 1]);
|
|
122
|
+
// add missing data points for the ending time
|
|
123
|
+
for (let i = orginalValues[orginalValues.length - 1][0] + sampleInterval; i < startingTimeStamp + sampleDuration; i += sampleInterval) {
|
|
124
|
+
newValues.push([i, NAN_STRING]);
|
|
125
|
+
}
|
|
114
126
|
return newValues;
|
|
115
127
|
}
|
|
116
128
|
// get the value for the based value
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { TooltipContentProps } from 'recharts';
|
|
2
|
+
export declare const TooltipContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const TooltipTime: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
1
4
|
export type Serie = {
|
|
2
5
|
resource: string;
|
|
3
6
|
data: [number, number | string | null][];
|
|
@@ -7,14 +10,14 @@ export type Serie = {
|
|
|
7
10
|
};
|
|
8
11
|
type NonSymmetricalChartSerie = {
|
|
9
12
|
yAxisType?: 'default' | 'percentage';
|
|
10
|
-
series: Serie[];
|
|
13
|
+
series: Serie[] | undefined;
|
|
11
14
|
};
|
|
12
15
|
type SymmetricalChartSerie = {
|
|
13
16
|
yAxisType: 'symmetrical';
|
|
14
17
|
series: {
|
|
15
|
-
above: Serie[];
|
|
16
|
-
below: Serie[];
|
|
17
|
-
};
|
|
18
|
+
above: Serie[] | undefined;
|
|
19
|
+
below: Serie[] | undefined;
|
|
20
|
+
} | undefined;
|
|
18
21
|
};
|
|
19
22
|
export type LineChartProps = (NonSymmetricalChartSerie | SymmetricalChartSerie) & {
|
|
20
23
|
title: string;
|
|
@@ -26,6 +29,7 @@ export type LineChartProps = (NonSymmetricalChartSerie | SymmetricalChartSerie)
|
|
|
26
29
|
threshold: number;
|
|
27
30
|
label: string;
|
|
28
31
|
}[];
|
|
32
|
+
syncId?: string;
|
|
29
33
|
isLoading?: boolean;
|
|
30
34
|
/**
|
|
31
35
|
* The format of the x axis, default is 'date-time' which is like 01 Sep 16:00
|
|
@@ -35,7 +39,8 @@ export type LineChartProps = (NonSymmetricalChartSerie | SymmetricalChartSerie)
|
|
|
35
39
|
timeFormat?: 'date-time' | 'date';
|
|
36
40
|
yAxisTitle?: string;
|
|
37
41
|
helpText?: string;
|
|
42
|
+
renderTooltip?: (tooltipProps: TooltipContentProps<number, string>, unitLabel?: string, timeFormat?: 'date-time' | 'date') => React.ReactNode;
|
|
38
43
|
};
|
|
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;
|
|
44
|
+
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;
|
|
40
45
|
export {};
|
|
41
46
|
//# 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":"AAAA,OAAO,EAOL,mBAAmB,EAGpB,MAAM,UAAU,CAAC;AA8BlB,eAAO,MAAM,gBAAgB,yGAO5B,CAAC;AAEF,eAAO,MAAM,WAAW,yGAMvB,CAAC;AAwCF,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,UAAU,CAAC,EAAE,WAAW,GAAG,MAAM,KAC9B,KAAK,CAAC,SAAS,CAAC;CACtB,CAAC;AA6EF,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,2CAmWhB"}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Line, LineChart, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis,
|
|
3
|
-
import { useCallback, useMemo, useRef } from 'react';
|
|
4
|
-
import { useTheme } from 'styled-components';
|
|
5
|
-
import {
|
|
6
|
-
import styled from 'styled-components';
|
|
2
|
+
import { CartesianGrid, Line, LineChart, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts';
|
|
3
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import styled, { useTheme } from 'styled-components';
|
|
5
|
+
import { spacing } from '../../spacing';
|
|
7
6
|
import { fontSize, fontWeight } from '../../style/theme';
|
|
7
|
+
import { Box } from '../box/Box';
|
|
8
8
|
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
9
|
-
import {
|
|
10
|
-
import { Loader } from '../loader/Loader.component';
|
|
11
|
-
import { spacing } from '../../spacing';
|
|
12
|
-
import { getUnitLabel } from '../linetemporalchart/ChartUtil';
|
|
9
|
+
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
13
10
|
import { Icon } from '../icon/Icon.component';
|
|
11
|
+
import { addMissingDataPoint, getUnitLabel, } from '../linetemporalchart/ChartUtil';
|
|
12
|
+
import { Loader } from '../loader/Loader.component';
|
|
13
|
+
import { ChartTitleText, SmallerText } from '../text/Text.component';
|
|
14
14
|
import { Tooltip as TooltipComponent } from '../tooltip/Tooltip.component';
|
|
15
|
-
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
16
|
-
import { Box } from '../box/Box';
|
|
17
15
|
import { formatXAxisLabel } from './utils';
|
|
18
16
|
const LineTemporalChartWrapper = styled.div `
|
|
19
17
|
display: flex;
|
|
@@ -25,7 +23,7 @@ const ChartHeader = styled.div `
|
|
|
25
23
|
display: flex;
|
|
26
24
|
align-items: center;
|
|
27
25
|
`;
|
|
28
|
-
const TooltipContainer = styled.div `
|
|
26
|
+
export const TooltipContainer = styled.div `
|
|
29
27
|
background-color: ${(props) => props.theme.backgroundLevel1};
|
|
30
28
|
padding: ${spacing.r8};
|
|
31
29
|
border: 1px solid ${(props) => props.theme.border};
|
|
@@ -33,7 +31,7 @@ const TooltipContainer = styled.div `
|
|
|
33
31
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
34
32
|
max-width: 250px;
|
|
35
33
|
`;
|
|
36
|
-
const TooltipTime = styled.div `
|
|
34
|
+
export const TooltipTime = styled.div `
|
|
37
35
|
margin-bottom: ${spacing.r8};
|
|
38
36
|
color: ${(props) => props.theme.textPrimary};
|
|
39
37
|
font-size: ${fontSize.smaller};
|
|
@@ -73,9 +71,13 @@ const TooltipInstanceValue = styled.div `
|
|
|
73
71
|
flex-shrink: 0;
|
|
74
72
|
text-align: right;
|
|
75
73
|
`;
|
|
76
|
-
const CustomTooltip = ({
|
|
77
|
-
|
|
74
|
+
const CustomTooltip = ({ unitLabel, timeFormat, isChartActive, tooltipProps, renderTooltip, }) => {
|
|
75
|
+
const { active, payload, label, ...rest } = tooltipProps;
|
|
76
|
+
if (!active || !payload || !payload.length || !label || !isChartActive)
|
|
78
77
|
return null;
|
|
78
|
+
if (renderTooltip) {
|
|
79
|
+
return renderTooltip(tooltipProps, unitLabel, timeFormat);
|
|
80
|
+
}
|
|
79
81
|
// We can't use the default itemSorter method because it's a custom tooltip.
|
|
80
82
|
// Sort the payload here instead
|
|
81
83
|
const sortedPayload = [...payload].sort((a, b) => {
|
|
@@ -98,23 +100,42 @@ const CustomTooltip = ({ active, payload, label, unitLabel, timeFormat, }) => {
|
|
|
98
100
|
const isSymmetricalSeries = (series) => {
|
|
99
101
|
return 'above' in series && 'below' in series;
|
|
100
102
|
};
|
|
101
|
-
export function LineTimeSerieChart({ series, title, height, startingTimeStamp, interval, duration, unitRange, isLoading = false, timeFormat = 'date-time', yAxisType = 'default', yAxisTitle, helpText, ...rest }) {
|
|
103
|
+
export function LineTimeSerieChart({ series, title, height, startingTimeStamp, interval, duration, unitRange, isLoading = false, timeFormat = 'date-time', yAxisType = 'default', yAxisTitle, helpText, syncId, renderTooltip, ...rest }) {
|
|
102
104
|
const theme = useTheme();
|
|
103
|
-
const { getColor } = useChartLegend();
|
|
105
|
+
const { getColor, selectedResources } = useChartLegend();
|
|
104
106
|
const chartRef = useRef(null);
|
|
107
|
+
const [isChartActive, setIsChartActive] = useState(false);
|
|
105
108
|
const chartData = useMemo(() => {
|
|
109
|
+
// Guard against empty/undefined series data
|
|
110
|
+
if (!series || (Array.isArray(series) && series.length === 0)) {
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
// Handle symmetrical series with empty above/below arrays
|
|
114
|
+
if (isSymmetricalSeries(series)) {
|
|
115
|
+
if ((!series.above || series.above.length === 0) &&
|
|
116
|
+
(!series.below || series.below.length === 0)) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
106
120
|
// 1. Add missing data points
|
|
107
121
|
const normalizedSeries = yAxisType === 'symmetrical' && isSymmetricalSeries(series)
|
|
108
122
|
? {
|
|
109
|
-
above: series.above
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
above: series.above
|
|
124
|
+
? series.above.map((line) => ({
|
|
125
|
+
...line,
|
|
126
|
+
data: addMissingDataPoint(line.data, startingTimeStamp, duration, interval),
|
|
127
|
+
}))
|
|
128
|
+
: [],
|
|
113
129
|
// Convert positive values to negative values
|
|
114
|
-
below: series.below
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
130
|
+
below: series.below
|
|
131
|
+
? series.below.map((line) => ({
|
|
132
|
+
...line,
|
|
133
|
+
data: addMissingDataPoint(line.data, startingTimeStamp, duration, interval).map(([timestamp, value]) => [
|
|
134
|
+
timestamp,
|
|
135
|
+
value === null ? null : `-${Number(value)}`,
|
|
136
|
+
]),
|
|
137
|
+
}))
|
|
138
|
+
: [],
|
|
118
139
|
}
|
|
119
140
|
: series.map((line) => ({
|
|
120
141
|
...line,
|
|
@@ -177,6 +198,14 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, i
|
|
|
177
198
|
return !isNaN(num) && num !== null ? num : null;
|
|
178
199
|
})
|
|
179
200
|
.filter((value) => value !== null));
|
|
201
|
+
// Guard against empty values array
|
|
202
|
+
if (values.length === 0) {
|
|
203
|
+
return {
|
|
204
|
+
topValue: 100, // Default value for empty charts
|
|
205
|
+
unitLabel: '',
|
|
206
|
+
rechartsData: [],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
180
209
|
const top = Math.abs(Math.max(...values));
|
|
181
210
|
const bottom = Math.abs(Math.min(...values));
|
|
182
211
|
const maxValue = Math.max(top, bottom);
|
|
@@ -196,11 +225,17 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, i
|
|
|
196
225
|
// Group series by resource and create color mapping
|
|
197
226
|
const { colorMapping, groupedSeries } = useMemo(() => {
|
|
198
227
|
const mapping = {};
|
|
228
|
+
// Guard against empty/undefined series
|
|
229
|
+
if (!series) {
|
|
230
|
+
return { colorMapping: mapping, groupedSeries: {} };
|
|
231
|
+
}
|
|
199
232
|
const allSeries = isSymmetricalSeries(series)
|
|
200
|
-
? [...series.above, ...series.below]
|
|
233
|
+
? [...(series.above || []), ...(series.below || [])]
|
|
201
234
|
: series;
|
|
202
235
|
// Group series by resource
|
|
203
|
-
const groups = allSeries
|
|
236
|
+
const groups = allSeries
|
|
237
|
+
.filter((serie) => selectedResources.includes(serie.resource))
|
|
238
|
+
.reduce((acc, serie) => {
|
|
204
239
|
const key = serie.resource;
|
|
205
240
|
if (!acc[key]) {
|
|
206
241
|
acc[key] = [];
|
|
@@ -222,30 +257,30 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, i
|
|
|
222
257
|
colorMapping: mapping,
|
|
223
258
|
groupedSeries: groups,
|
|
224
259
|
};
|
|
225
|
-
}, [series, getColor]);
|
|
260
|
+
}, [series, getColor, selectedResources]);
|
|
226
261
|
// Format time for display the tick in the x axis
|
|
227
262
|
const formatXAxisLabelCallback = useCallback((timestamp) => formatXAxisLabel(timestamp, timeFormat, chartData), [timeFormat, chartData]);
|
|
228
|
-
return (_jsxs(LineTemporalChartWrapper, { children: [_jsxs(ChartHeader, { children: [_jsxs(ChartTitleText, { children: [title, " ", unitLabel && `(${unitLabel})`] }), helpText && (_jsx(Box, { ml: spacing.r4, children: _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: formatXAxisLabelCallback, tickCount: 5, tick: {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
263
|
+
return (_jsxs(LineTemporalChartWrapper, { children: [_jsxs(ChartHeader, { children: [_jsxs(ChartTitleText, { children: [title, " ", unitLabel && `(${unitLabel})`] }), helpText && (_jsx(Box, { ml: spacing.r4, children: _jsx(TooltipComponent, { placement: 'right', overlay: _jsx(SmallerText, { children: helpText }), children: _jsx(Icon, { name: "Info", color: theme.buttonSecondary }) }) })), isLoading && _jsx(Loader, {})] }), _jsx("div", { onFocus: () => setIsChartActive(true), onBlur: () => setIsChartActive(false), onFocusCapture: () => setIsChartActive(true), onBlurCapture: () => setIsChartActive(false), children: _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}`, syncId: syncId, onMouseEnter: () => setIsChartActive(true), onMouseLeave: () => setIsChartActive(false), 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: formatXAxisLabelCallback, tickCount: 5, tick: {
|
|
264
|
+
fill: theme.textSecondary,
|
|
265
|
+
fontSize: fontSize.smaller,
|
|
266
|
+
}, axisLine: { stroke: theme.border } }), _jsx(YAxis, { orientation: "right", allowDataOverflow: false, label: {
|
|
267
|
+
value: yAxisTitle,
|
|
268
|
+
angle: 90,
|
|
269
|
+
position: 'insideRight',
|
|
270
|
+
style: {
|
|
271
|
+
textAnchor: 'middle',
|
|
272
|
+
fill: theme.textSecondary,
|
|
273
|
+
fontSize: fontSize.smaller,
|
|
274
|
+
},
|
|
275
|
+
}, domain: yAxisType === 'percentage'
|
|
276
|
+
? [0, 100]
|
|
277
|
+
: yAxisType === 'symmetrical'
|
|
278
|
+
? [-topValue, topValue]
|
|
279
|
+
: [0, topValue], axisLine: { stroke: theme.border }, tick: {
|
|
237
280
|
fill: theme.textSecondary,
|
|
238
281
|
fontSize: fontSize.smaller,
|
|
239
|
-
},
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
? [-topValue, topValue]
|
|
244
|
-
: [0, topValue], axisLine: { stroke: theme.border }, tick: {
|
|
245
|
-
fill: theme.textSecondary,
|
|
246
|
-
fontSize: fontSize.smaller,
|
|
247
|
-
}, tickFormatter: (value) => Math.round(value).toString(), tickCount: 5, interval: 'preserveStartEnd' }), _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) => {
|
|
248
|
-
const label = serie.getTooltipLabel(serie.metricPrefix, serie.resource);
|
|
249
|
-
return (_jsx(Line, { type: "monotone", dataKey: label, stroke: colorMapping[resource], dot: false, isAnimationActive: false }, `${title}-${resource}-${serieIndex}`));
|
|
250
|
-
}))] }) })] }));
|
|
282
|
+
}, tickFormatter: (value) => Math.round(value).toString(), tickCount: 5, interval: 'preserveStartEnd' }), _jsx(Tooltip, { content: (props) => (_jsx(CustomTooltip, { unitLabel: unitLabel, timeFormat: timeFormat, renderTooltip: renderTooltip, tooltipProps: props, isChartActive: isChartActive })) }), yAxisType === 'symmetrical' && (_jsx(ReferenceLine, { y: 0, stroke: theme.border })), Object.entries(groupedSeries).map(([resource, resourceSeries]) => resourceSeries.map((serie, serieIndex) => {
|
|
283
|
+
const label = serie.getTooltipLabel(serie.metricPrefix, serie.resource);
|
|
284
|
+
return (_jsx(Line, { type: "monotone", dataKey: label, stroke: colorMapping[resource], dot: false, isAnimationActive: false }, `${title}-${resource}-${serieIndex}`));
|
|
285
|
+
}))] }) }) })] }));
|
|
251
286
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CoreUITheme } from '../../style/theme';
|
|
2
|
+
export type TextVariant = 'ChartTitle' | 'Basic' | 'Smaller' | 'Larger' | 'Large';
|
|
2
3
|
type Status = 'unknown' | 'healthy' | 'warning' | 'critical';
|
|
3
4
|
type Props = {
|
|
4
5
|
children: React.ReactNode | string;
|
|
@@ -22,7 +23,7 @@ export declare const GentleEmphaseSecondaryText: import("styled-components").Sty
|
|
|
22
23
|
alignRight?: boolean;
|
|
23
24
|
}, never>;
|
|
24
25
|
export declare const Text: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {
|
|
25
|
-
variant?:
|
|
26
|
+
variant?: TextVariant;
|
|
26
27
|
color?: keyof CoreUITheme;
|
|
27
28
|
isEmphazed?: boolean;
|
|
28
29
|
isGentleEmphazed?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/text/Text.component.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,KAAK,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAC7D,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,MA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;AACD,eAAO,MAAM,0BAA0B;iBACxB,OAAO;SAUrB,CAAC;AAEF,eAAO,MAAM,IAAI;cACL,WAAW;YACb,MAAM,WAAW;iBACZ,OAAO;uBACD,OAAO;SA2C3B,CAAC;AAEF,eAAO,MAAM,IAAI,uGAchB,CAAC"}
|
package/dist/next.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ 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 { ChartTooltip } from './components/barchartv2/ChartTooltip';
|
|
18
|
-
export { ChartLegendWrapper } from './components/chartlegend/ChartLegendWrapper';
|
|
18
|
+
export { ChartLegendWrapper, useChartId, } from './components/chartlegend/ChartLegendWrapper';
|
|
19
19
|
export { ChartLegend } from './components/chartlegend/ChartLegend';
|
|
20
20
|
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
|
21
21
|
export { CoreUITheme } from './style/theme';
|
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,OA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AS,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,EACL,kBAAkB,EAClB,UAAU,GACX,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/next.js
CHANGED
|
@@ -15,6 +15,6 @@ 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 { ChartTooltip } from './components/barchartv2/ChartTooltip';
|
|
18
|
-
export { ChartLegendWrapper } from './components/chartlegend/ChartLegendWrapper';
|
|
18
|
+
export { ChartLegendWrapper, useChartId, } from './components/chartlegend/ChartLegendWrapper';
|
|
19
19
|
export { ChartLegend } from './components/chartlegend/ChartLegend';
|
|
20
20
|
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scality/core-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.171.0",
|
|
4
4
|
"description": "Scality common React component library",
|
|
5
5
|
"author": "Scality Engineering",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"@types/react-window": "^1.8.5",
|
|
62
62
|
"@types/styled-components": "^5.1.25",
|
|
63
63
|
"@types/styled-system": "^5.1.15",
|
|
64
|
+
"@types/uuid": "^10.0.0",
|
|
64
65
|
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
65
66
|
"@typescript-eslint/parser": "^6.12.0",
|
|
66
67
|
"copyfiles": "^2.4.1",
|
|
@@ -109,6 +110,7 @@
|
|
|
109
110
|
"recharts": "^3.0.2",
|
|
110
111
|
"styled-components": "^5.2.1",
|
|
111
112
|
"styled-system": "^5.1.5",
|
|
113
|
+
"uuid": "^13.0.0",
|
|
112
114
|
"vega": "^5.17.3",
|
|
113
115
|
"vega-embed": "6.0.0",
|
|
114
116
|
"vega-lite": "5.0.0",
|
|
@@ -24,13 +24,13 @@ import { ChartTooltip } from './ChartTooltip';
|
|
|
24
24
|
import { UnitRange, useChartData } from './utils';
|
|
25
25
|
|
|
26
26
|
const CHART_CONSTANTS = {
|
|
27
|
-
TICK_WIDTH_OFFSET:
|
|
27
|
+
TICK_WIDTH_OFFSET: 4,
|
|
28
28
|
BAR_SIZE: 12,
|
|
29
29
|
MIN_POINT_SIZE: 3,
|
|
30
30
|
DEFAULT_HEIGHT: 200,
|
|
31
31
|
CHART_MARGIN: {
|
|
32
32
|
left: 0,
|
|
33
|
-
right:
|
|
33
|
+
right: -10,
|
|
34
34
|
top: 0,
|
|
35
35
|
bottom: 0,
|
|
36
36
|
},
|