@scality/core-ui 0.167.0 → 0.169.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/.github/workflows/github-pages.yml +5 -3
- package/.storybook/preview.js +1 -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 +12 -7
- package/dist/components/barchartv2/ChartTooltip.d.ts +9 -13
- package/dist/components/barchartv2/ChartTooltip.d.ts.map +1 -1
- package/dist/components/barchartv2/ChartTooltip.js +14 -4
- package/dist/components/barchartv2/utils.d.ts +9 -2
- package/dist/components/barchartv2/utils.d.ts.map +1 -1
- package/dist/components/barchartv2/utils.js +14 -18
- package/dist/components/buttonv2/Buttonv2.component.d.ts.map +1 -1
- package/dist/components/buttonv2/Buttonv2.component.js +27 -6
- package/dist/components/date/FormattedDateTime.d.ts +20 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +36 -0
- package/dist/components/linetemporalchart/ChartUtil.d.ts.map +1 -1
- package/dist/components/linetemporalchart/ChartUtil.js +6 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +7 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +36 -32
- package/dist/components/linetimeseriechart/utils.d.ts +16 -0
- package/dist/components/linetimeseriechart/utils.d.ts.map +1 -0
- package/dist/components/linetimeseriechart/utils.js +28 -0
- package/dist/style/theme.d.ts +2 -2
- package/dist/style/theme.d.ts.map +1 -1
- package/dist/style/theme.js +26 -0
- package/package.json +5 -4
- package/src/lib/components/barchartv2/Barchart.component.test.tsx +12 -8
- package/src/lib/components/barchartv2/Barchart.component.tsx +29 -9
- package/src/lib/components/barchartv2/ChartTooltip.test.tsx +119 -0
- package/src/lib/components/barchartv2/ChartTooltip.tsx +49 -19
- package/src/lib/components/barchartv2/utils.test.ts +31 -46
- package/src/lib/components/barchartv2/utils.ts +24 -31
- package/src/lib/components/buttonv2/Buttonv2.component.tsx +27 -6
- package/src/lib/components/date/FormattedDateTime.tsx +43 -1
- package/src/lib/components/linetemporalchart/ChartUtil.ts +6 -0
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +81 -54
- package/src/lib/components/linetimeseriechart/linetimeseriechart.test.tsx +71 -0
- package/src/lib/components/linetimeseriechart/utils.test.ts +87 -0
- package/src/lib/components/linetimeseriechart/utils.ts +43 -0
- package/src/lib/style/theme.ts +26 -0
- package/stories/BarChart/barchart.stories.tsx +108 -13
- package/stories/color.mdx +12 -0
- package/stories/linetimeseriechart.stories.tsx +97 -0
|
@@ -11,7 +11,9 @@ jobs:
|
|
|
11
11
|
- uses: actions/setup-node@v4
|
|
12
12
|
with:
|
|
13
13
|
node-version: 20
|
|
14
|
-
- run:
|
|
15
|
-
|
|
14
|
+
- run: |
|
|
15
|
+
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
|
|
16
|
+
npm ci
|
|
17
|
+
npm run storybook:deploy
|
|
16
18
|
env:
|
|
17
|
-
|
|
19
|
+
STORYBOOK_DISABLE_TELEMETRY: 1
|
package/.storybook/preview.js
CHANGED
|
@@ -18,6 +18,7 @@ export const globalTypes = {
|
|
|
18
18
|
{ value: 'darkRebrand', title: ' A-Dark', icon: 'moon' },
|
|
19
19
|
{ value: 'artescaLight', title: 'A-Light', icon: 'sun' },
|
|
20
20
|
{ value: 'ring9dark', title: 'R-Dark', icon: 'moon' },
|
|
21
|
+
{ value: 'G-Dark', title: 'G-Dark', icon: 'moon' },
|
|
21
22
|
],
|
|
22
23
|
},
|
|
23
24
|
},
|
|
@@ -7,6 +7,10 @@ export type TimeType = {
|
|
|
7
7
|
interval: number;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
+
export type CategoryType = {
|
|
11
|
+
type: 'category';
|
|
12
|
+
gap?: number;
|
|
13
|
+
};
|
|
10
14
|
export type Point = {
|
|
11
15
|
key: string | number;
|
|
12
16
|
values: {
|
|
@@ -36,7 +40,7 @@ export type BarchartSortFn<T extends BarchartBars> = (pointA: Record<T[number]['
|
|
|
36
40
|
category: string | number;
|
|
37
41
|
}) => 1 | -1 | 0;
|
|
38
42
|
export type BarchartProps<T extends BarchartBars> = {
|
|
39
|
-
type:
|
|
43
|
+
type: CategoryType | TimeType;
|
|
40
44
|
bars?: T;
|
|
41
45
|
tooltip?: BarchartTooltipFn<T>;
|
|
42
46
|
defaultSort?: BarchartSortFn<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Barchart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/Barchart.component.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Barchart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/Barchart.component.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAC;AAiBlD,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;KAClB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,SAAS;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAA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,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;AAEF,UAAU,eAAe;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB;AAID;;;;;GAKG;AACH,eAAO,MAAM,UAAU,cACV,MAAM,YACP,MAAM,KACf,KAAK,CAAC,SAoBR,CAAC;AAEF,eAAO,MAAM,UAAU,uDAOpB,eAAe,4CAkCjB,CAAC;AA2EF,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,YAAY,SAAS,aAAa,CAAC,CAAC,CAAC,4CAsJvE,CAAC"}
|
|
@@ -5,13 +5,14 @@ import styled, { useTheme } from 'styled-components';
|
|
|
5
5
|
import { spacing, Stack, Wrap } from '../../spacing';
|
|
6
6
|
import { chartColors, fontSize } from '../../style/theme';
|
|
7
7
|
import { Box } from '../box/Box';
|
|
8
|
+
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
8
9
|
import { ConstrainedText } from '../constrainedtext/Constrainedtext.component';
|
|
10
|
+
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
9
11
|
import { IconHelp } from '../iconhelper/IconHelper';
|
|
10
12
|
import { Loader } from '../loader/Loader.component';
|
|
11
13
|
import { Text } from '../text/Text.component';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
14
|
+
import { ChartTooltip } from './ChartTooltip';
|
|
15
|
+
import { useChartData } from './utils';
|
|
15
16
|
const CHART_CONSTANTS = {
|
|
16
17
|
TICK_WIDTH_OFFSET: 5,
|
|
17
18
|
BAR_SIZE: 12,
|
|
@@ -94,7 +95,7 @@ export const Barchart = (props) => {
|
|
|
94
95
|
const theme = useTheme();
|
|
95
96
|
const { getColor } = useChartLegend();
|
|
96
97
|
const [hoveredValue, setHoveredValue] = useState();
|
|
97
|
-
const { height = CHART_CONSTANTS.DEFAULT_HEIGHT, bars, type = 'category', unitRange, stacked, stackedBarSort = 'default', defaultSort, tooltip, title, secondaryTitle, helpTooltip, rightTitle, isLoading, isError, } = props;
|
|
98
|
+
const { height = CHART_CONSTANTS.DEFAULT_HEIGHT, bars, type = { type: 'category' }, unitRange, stacked, stackedBarSort = 'default', defaultSort, tooltip, title, secondaryTitle, helpTooltip, rightTitle, isLoading, isError, } = props;
|
|
98
99
|
// Create colorSet from ChartLegendWrapper
|
|
99
100
|
const colorSet = bars === null || bars === void 0 ? void 0 : bars.reduce((acc, bar) => {
|
|
100
101
|
const color = getColor(bar.label);
|
|
@@ -104,9 +105,13 @@ export const Barchart = (props) => {
|
|
|
104
105
|
return acc;
|
|
105
106
|
}, {});
|
|
106
107
|
const { rechartsBars, unitLabel, roundReferenceValue, rechartsData } = useChartData(bars || [], type, colorSet || {}, stacked, defaultSort, unitRange, stackedBarSort);
|
|
107
|
-
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:
|
|
108
|
+
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: type.type === 'category'
|
|
109
|
+
? type.gap === 0
|
|
110
|
+
? undefined
|
|
111
|
+
: CHART_CONSTANTS.BAR_SIZE
|
|
112
|
+
: CHART_CONSTANTS.BAR_SIZE, height: height, margin: CHART_CONSTANTS.CHART_MARGIN, barCategoryGap: type.type === 'category' ? type.gap : undefined, children: [_jsx(CartesianGrid, { vertical: false, horizontal: false, fill: theme.backgroundLevel1 }), rechartsBars.map((bar) => {
|
|
108
113
|
const { fill, dataKey, stackId } = bar;
|
|
109
|
-
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));
|
|
114
|
+
return (_jsx(Bar, { dataKey: dataKey, fill: chartColors[fill] || fill, minPointSize: stacked ? 0 : CHART_CONSTANTS.MIN_POINT_SIZE, stackId: stackId, isAnimationActive: false, onMouseOver: () => setHoveredValue(dataKey), onMouseLeave: () => setHoveredValue(undefined) }, dataKey));
|
|
110
115
|
}), _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
|
|
111
116
|
, axisLine: false, tick: {
|
|
112
117
|
fill: theme.textSecondary,
|
|
@@ -117,5 +122,5 @@ export const Barchart = (props) => {
|
|
|
117
122
|
stroke: theme.textSecondary,
|
|
118
123
|
}, axisLine: {
|
|
119
124
|
stroke: theme.textSecondary,
|
|
120
|
-
} }), _jsx(Tooltip, { content: (props) =>
|
|
125
|
+
} }), _jsx(Tooltip, { content: (props) => (_jsx(ChartTooltip, { type: type, colorSet: colorSet, tooltipProps: props, hoveredValue: hoveredValue, tooltip: tooltip })), cursor: false })] }) }))] }));
|
|
121
126
|
};
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { BarchartBars } from './Barchart.component';
|
|
1
|
+
import { BarchartBars, BarchartTooltipFn, CategoryType, TimeType } from './Barchart.component';
|
|
2
|
+
import { TooltipContentProps } from 'recharts';
|
|
2
3
|
export declare const ChartTooltipContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
4
|
export declare const ChartTooltipItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
4
5
|
isHovered: boolean;
|
|
5
6
|
}, never>;
|
|
6
|
-
export declare const ChartTooltip: <T extends BarchartBars>({ type,
|
|
7
|
-
type:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
isHovered: boolean;
|
|
14
|
-
}[];
|
|
15
|
-
};
|
|
16
|
-
colorSet: Record<string, string>;
|
|
17
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const ChartTooltip: <T extends BarchartBars>({ type, tooltipProps, colorSet, hoveredValue, tooltip, }: {
|
|
8
|
+
type: TimeType | CategoryType;
|
|
9
|
+
tooltipProps: TooltipContentProps<number, string>;
|
|
10
|
+
colorSet?: Record<string, string>;
|
|
11
|
+
hoveredValue: string | undefined;
|
|
12
|
+
tooltip?: BarchartTooltipFn<T>;
|
|
13
|
+
}) => string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
18
14
|
//# sourceMappingURL=ChartTooltip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/ChartTooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/ChartTooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,eAAO,MAAM,qBAAqB,yGAYjC,CAAC;AAEF,eAAO,MAAM,gBAAgB;eAA2B,OAAO;SAM9D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,YAAY,4DAMhD;IACD,IAAI,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC9B,YAAY,EAAE,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAChC,iIAwDA,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { spacing, Stack, Wrap } from '../../spacing';
|
|
4
4
|
import { Text } from '../text/Text.component';
|
|
5
5
|
import { fontSize, fontWeight } from '../../style/theme';
|
|
6
6
|
import { LegendShape } from '../chartlegend/ChartLegend';
|
|
7
7
|
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
8
|
+
import { getCurrentPoint } from './utils';
|
|
8
9
|
export const ChartTooltipContainer = styled.div `
|
|
9
10
|
background-color: ${({ theme }) => theme.backgroundLevel1};
|
|
10
11
|
padding: ${spacing.r4} ${spacing.r8};
|
|
@@ -24,8 +25,17 @@ export const ChartTooltipItem = styled.div `
|
|
|
24
25
|
gap: 8px;
|
|
25
26
|
font-weight: ${({ isHovered }) => isHovered ? fontWeight.bold : fontWeight.base};
|
|
26
27
|
`;
|
|
27
|
-
export const ChartTooltip = ({ type,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
export const ChartTooltip = ({ type, tooltipProps, colorSet, hoveredValue, tooltip, }) => {
|
|
29
|
+
const { active } = tooltipProps;
|
|
30
|
+
if (!active) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const currentPoint = getCurrentPoint(tooltipProps, hoveredValue);
|
|
34
|
+
if (tooltip) {
|
|
35
|
+
return tooltip(currentPoint);
|
|
36
|
+
}
|
|
37
|
+
return (_jsxs(ChartTooltipContainer, { children: [_jsx(Text, { isEmphazed: true, children: type.type === 'time' ? (_jsxs(_Fragment, { children: [_jsx(FormattedDateTime, { format: "long-date", value: new Date(currentPoint.category) }), ' ', type.type === 'time' &&
|
|
38
|
+
type.timeRange.interval < 24 * 60 * 60 * 1000 && (_jsx(FormattedDateTime, { format: "time", value: new Date(currentPoint.category) }))] })) : (currentPoint.category) }), _jsx(Stack, { direction: "vertical", gap: "r8", style: { width: '100%' }, children: currentPoint.values.map((value) => {
|
|
39
|
+
return (_jsxs(Wrap, { gap: spacing.r32, children: [_jsxs(ChartTooltipItem, { isHovered: value.isHovered, children: [colorSet && (_jsx(LegendShape, { color: colorSet[value.label], shape: "rectangle", chartColors: colorSet })), value.label] }), _jsx(ChartTooltipItem, { isHovered: value.isHovered, children: value.value })] }, value.label));
|
|
30
40
|
}) })] }));
|
|
31
41
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BarchartProps, BarchartBars
|
|
1
|
+
import { BarchartProps, BarchartBars } from './Barchart.component';
|
|
2
2
|
import { TooltipContentProps } from 'recharts';
|
|
3
3
|
import { ChartColors } from '../../style/theme';
|
|
4
4
|
export declare const getRoundReferenceValue: (value: number) => number;
|
|
@@ -81,7 +81,6 @@ export declare const sortStackedBars: (rechartsBars: {
|
|
|
81
81
|
fill: string;
|
|
82
82
|
stackId?: string;
|
|
83
83
|
}[];
|
|
84
|
-
export declare const renderTooltipContent: <T extends BarchartBars>(props: TooltipContentProps<number, string>, tooltip: BarchartTooltipFn<T> | undefined, hoveredValue: string | undefined) => import("react").ReactNode;
|
|
85
84
|
/**
|
|
86
85
|
* Filters both chart data and recharts bars to only include selected resources from legend
|
|
87
86
|
* @param data - Array of chart data objects with category and resource values
|
|
@@ -115,4 +114,12 @@ export declare const useChartData: <T extends BarchartBars>(bars: T, type: Barch
|
|
|
115
114
|
roundReferenceValue: number;
|
|
116
115
|
rechartsData: any;
|
|
117
116
|
};
|
|
117
|
+
export declare const getCurrentPoint: <T extends BarchartBars>(props: TooltipContentProps<number, string>, hoveredValue: string | undefined) => {
|
|
118
|
+
category: string | number;
|
|
119
|
+
values: {
|
|
120
|
+
label: T[number]["label"];
|
|
121
|
+
value: number;
|
|
122
|
+
isHovered: boolean;
|
|
123
|
+
}[];
|
|
124
|
+
};
|
|
118
125
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EAEb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG7D,eAAO,MAAM,sBAAsB,UAAW,MAAM,KAAG,MAkBtD,CAAC;AAEF,eAAO,MAAM,cAAc,SACnB;IAAE,CAAC,GAAG,EAAE,MAA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,QAAQ;;iBApCZ,MAAM;cAAQ,MAAM;kBAAY,MAAM;;;;;CAuEhE,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,YAAY,SAC7C,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,gBAC5B,MAAM,GAAG,SAAS;cAeX,MAAM,GAAG,MAAM;;eAV3B,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;eAClB,MAAM;mBACF,OAAO;;CAWrB,CAAC"}
|
|
@@ -174,10 +174,10 @@ const getRechartsBarsAndBarDataKeys = (bars, colorSet, stacked) => {
|
|
|
174
174
|
*/
|
|
175
175
|
export const formatPrometheusDataToRechartsDataAndBars = (bars, type, colorSet, stacked, defaultSort, legendOrder) => {
|
|
176
176
|
const { rechartsBars, barDataKeys } = getRechartsBarsAndBarDataKeys(bars, colorSet, stacked);
|
|
177
|
-
let data = type !== 'category' && type.type === 'time'
|
|
177
|
+
let data = type.type !== 'category' && type.type === 'time'
|
|
178
178
|
? transformTimeData(bars, type, barDataKeys)
|
|
179
179
|
: transformCategoryData(bars, barDataKeys);
|
|
180
|
-
if (type === 'category' && defaultSort) {
|
|
180
|
+
if (type.type === 'category' && defaultSort) {
|
|
181
181
|
data = applySortingToData(data, barDataKeys, defaultSort);
|
|
182
182
|
}
|
|
183
183
|
const sortedRechartsBars = sortStackedBars(rechartsBars, data, stacked, legendOrder);
|
|
@@ -270,22 +270,6 @@ export const sortStackedBars = (rechartsBars, data, stacked, legendOrder) => {
|
|
|
270
270
|
// Remove the average property and keep only the bar data
|
|
271
271
|
return barAverages.map(({ average, ...bar }) => bar);
|
|
272
272
|
};
|
|
273
|
-
export const renderTooltipContent = (props, tooltip, hoveredValue) => {
|
|
274
|
-
const { active, payload, label } = props;
|
|
275
|
-
if (!active || !tooltip) {
|
|
276
|
-
return null;
|
|
277
|
-
}
|
|
278
|
-
const tooltipValues = payload.map((item) => ({
|
|
279
|
-
label: item.name,
|
|
280
|
-
value: item.value,
|
|
281
|
-
isHovered: item.name === hoveredValue,
|
|
282
|
-
}));
|
|
283
|
-
const currentPoint = {
|
|
284
|
-
category: label,
|
|
285
|
-
values: tooltipValues,
|
|
286
|
-
};
|
|
287
|
-
return tooltip(currentPoint);
|
|
288
|
-
};
|
|
289
273
|
/**
|
|
290
274
|
* Filters both chart data and recharts bars to only include selected resources from legend
|
|
291
275
|
* @param data - Array of chart data objects with category and resource values
|
|
@@ -330,3 +314,15 @@ export const useChartData = (bars, type, colorSet, stacked, defaultSort, unitRan
|
|
|
330
314
|
rechartsData,
|
|
331
315
|
};
|
|
332
316
|
};
|
|
317
|
+
export const getCurrentPoint = (props, hoveredValue) => {
|
|
318
|
+
const { payload, label } = props;
|
|
319
|
+
const tooltipValues = payload.map((item) => ({
|
|
320
|
+
label: item.name,
|
|
321
|
+
value: item.value,
|
|
322
|
+
isHovered: item.name === hoveredValue,
|
|
323
|
+
}));
|
|
324
|
+
return {
|
|
325
|
+
category: label,
|
|
326
|
+
values: tooltipValues,
|
|
327
|
+
};
|
|
328
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Buttonv2.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/buttonv2/Buttonv2.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAI7C,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAW,KAAK,IAAI,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE9E,eAAO,MAAM,iBAAiB,oIAI7B,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,IAAI,CACtB,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,MAAM,GAAG,OAAO,CACjB,GAAG;IACF,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzD,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,QAAQ,CAA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C;CACrB,CAAC;AACF,eAAO,MAAM,YAAY,+GA0KxB,CAAC;AACF,eAAO,MAAM,WAAW,0GAIvB,CAAC;AACF,eAAO,MAAM,UAAU;WAAwB,KAAK,CAAC,SAAS;SAS7D,CAAC;AAEF,eAAO,MAAM,YAAY;;;SAaxB,CAAC;AAEF,iBAAS,MAAM,CAAC,EACd,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,OAAO,EACP,OAAO,EACP,SAAS,EACT,GAAG,IAAI,EACR,EAAE,KAAK,2CAqDP;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -35,8 +35,10 @@ export const ButtonStyled = styled.button `
|
|
|
35
35
|
switch (props.variant) {
|
|
36
36
|
case 'primary':
|
|
37
37
|
return css `
|
|
38
|
-
background
|
|
39
|
-
|
|
38
|
+
background: ${brand.buttonPrimary};
|
|
39
|
+
background-clip: padding-box, border-box;
|
|
40
|
+
border: ${spacing.r1} solid transparent;
|
|
41
|
+
border-color: ${brand.buttonPrimary};
|
|
40
42
|
color: ${brand.textPrimary};
|
|
41
43
|
&:hover:enabled {
|
|
42
44
|
cursor: pointer;
|
|
@@ -56,8 +58,10 @@ export const ButtonStyled = styled.button `
|
|
|
56
58
|
`;
|
|
57
59
|
case 'secondary':
|
|
58
60
|
return css `
|
|
59
|
-
background
|
|
60
|
-
|
|
61
|
+
background: ${brand.buttonSecondary};
|
|
62
|
+
background-clip: padding-box, border-box;
|
|
63
|
+
border: ${spacing.r1} solid transparent;
|
|
64
|
+
border-color: ${brand.buttonSecondary};
|
|
61
65
|
color: ${brand.textPrimary};
|
|
62
66
|
&:hover:enabled {
|
|
63
67
|
cursor: pointer;
|
|
@@ -71,7 +75,8 @@ export const ButtonStyled = styled.button `
|
|
|
71
75
|
&:active:enabled {
|
|
72
76
|
cursor: pointer;
|
|
73
77
|
color: ${brand.textPrimary};
|
|
74
|
-
border: ${spacing.r1} solid
|
|
78
|
+
border: ${spacing.r1} solid transparent;
|
|
79
|
+
border-color: ${brand.buttonSecondary};
|
|
75
80
|
}
|
|
76
81
|
`;
|
|
77
82
|
case 'danger':
|
|
@@ -93,13 +98,18 @@ export const ButtonStyled = styled.button `
|
|
|
93
98
|
`;
|
|
94
99
|
case 'outline':
|
|
95
100
|
return css `
|
|
96
|
-
border: ${spacing.r1} solid
|
|
101
|
+
border: ${spacing.r1} solid transparent;
|
|
102
|
+
border-color: ${brand.buttonSecondary};
|
|
97
103
|
background-color: transparent;
|
|
98
104
|
color: ${brand.textPrimary};
|
|
99
105
|
&:hover:enabled {
|
|
100
106
|
cursor: pointer;
|
|
101
107
|
border-color: ${brand.infoPrimary};
|
|
102
108
|
color: ${brand.textPrimary};
|
|
109
|
+
|
|
110
|
+
&::before {
|
|
111
|
+
background-image: ${brand.buttonPrimary};
|
|
112
|
+
}
|
|
103
113
|
}
|
|
104
114
|
&:focus-visible:enabled {
|
|
105
115
|
${FocusVisibleStyle}
|
|
@@ -110,6 +120,17 @@ export const ButtonStyled = styled.button `
|
|
|
110
120
|
border: ${spacing.r1} solid ${brand.infoSecondary};
|
|
111
121
|
color: ${brand.textPrimary};
|
|
112
122
|
}
|
|
123
|
+
&::before {
|
|
124
|
+
content: '';
|
|
125
|
+
position: absolute;
|
|
126
|
+
inset: 0;
|
|
127
|
+
padding: ${spacing.r1};
|
|
128
|
+
background-image: ${brand.buttonSecondary};
|
|
129
|
+
border-radius: inherit;
|
|
130
|
+
mask: linear-gradient(white, white) content-box, linear-gradient(white, white);
|
|
131
|
+
mask-composite: exclude;
|
|
132
|
+
pointer-events: none;
|
|
133
|
+
}
|
|
113
134
|
`;
|
|
114
135
|
default:
|
|
115
136
|
}
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
export declare const LONG_DATE_FORMATER: Intl.DateTimeFormat;
|
|
2
|
+
/**
|
|
3
|
+
* @description Long date formatter, without weekday.
|
|
4
|
+
* @example 01 September 2025
|
|
5
|
+
*/
|
|
6
|
+
export declare const LONG_DATE_FORMATER_WITHOUT_WEEKDAY: Intl.DateTimeFormat;
|
|
2
7
|
export declare const DATE_FORMATER: Intl.DateTimeFormat;
|
|
3
8
|
export declare const DAY_MONTH_FORMATER: Intl.DateTimeFormat;
|
|
4
9
|
export declare const TIME_SECOND_FORMATER: Intl.DateTimeFormat;
|
|
5
10
|
export declare const TIME_FORMATER: Intl.DateTimeFormat;
|
|
6
11
|
export declare const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND: Intl.DateTimeFormat;
|
|
12
|
+
/**
|
|
13
|
+
* @description Day month abbreviated hour minute formatter, without second.
|
|
14
|
+
* @example 15 Sept 14:30
|
|
15
|
+
*/
|
|
7
16
|
export declare const DAY_MONTH_ABBREVIATED_HOUR_MINUTE: Intl.DateTimeFormat;
|
|
17
|
+
/**
|
|
18
|
+
* @description Year month day formatter, without time. Used for describing long term date.
|
|
19
|
+
* @example 2025-01-01
|
|
20
|
+
*/
|
|
21
|
+
export declare const YEAR_MONTH_DAY_FORMATTER: Intl.DateTimeFormat;
|
|
22
|
+
/**
|
|
23
|
+
* @description Month day formatter, without year. Used for short term date ranges.
|
|
24
|
+
* @example 01-15
|
|
25
|
+
*/
|
|
26
|
+
export declare const MONTH_DAY_FORMATTER: Intl.DateTimeFormat;
|
|
8
27
|
type FormattedDateTimeProps = {
|
|
9
|
-
format: 'date' | 'date-time' | 'date-time-second' | 'time' | 'time-second' | 'relative' | 'day-month-abbreviated-hour-minute' | 'day-month-abbreviated-hour-minute-second' | 'long-date' | 'chart-date';
|
|
28
|
+
format: 'date' | 'date-time' | 'date-time-second' | 'time' | 'time-second' | 'relative' | 'day-month-abbreviated-hour-minute' | 'day-month-abbreviated-hour-minute-second' | 'long-date' | 'long-date-without-weekday' | 'chart-date' | 'year-month-day' | 'month-day';
|
|
10
29
|
value: Date;
|
|
11
30
|
};
|
|
12
31
|
export declare const FormattedDateTime: ({ format, value, }: FormattedDateTimeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormattedDateTime.d.ts","sourceRoot":"","sources":["../../../src/lib/components/date/FormattedDateTime.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,qBAK7B,CAAC;AAEH,eAAO,MAAM,aAAa,qBAKxB,CAAC;AAEH,eAAO,MAAM,kBAAkB,qBAI7B,CAAC;AAEH,eAAO,MAAM,oBAAoB,qBAK/B,CAAC;AAEH,eAAO,MAAM,aAAa,qBAIxB,CAAC;AAEH,eAAO,MAAM,wCAAwC,qBAUpD,CAAC;AAEF,eAAO,MAAM,iCAAiC,qBAM5C,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EACF,MAAM,GACN,WAAW,GACX,kBAAkB,GAClB,MAAM,GACN,aAAa,GACb,UAAU,GACV,mCAAmC,GACnC,0CAA0C,GAC1C,WAAW,GACX,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"FormattedDateTime.d.ts","sourceRoot":"","sources":["../../../src/lib/components/date/FormattedDateTime.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,qBAK7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kCAAkC,qBAI7C,CAAC;AAEH,eAAO,MAAM,aAAa,qBAKxB,CAAC;AAEH,eAAO,MAAM,kBAAkB,qBAI7B,CAAC;AAEH,eAAO,MAAM,oBAAoB,qBAK/B,CAAC;AAEH,eAAO,MAAM,aAAa,qBAIxB,CAAC;AAEH,eAAO,MAAM,wCAAwC,qBAUpD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iCAAiC,qBAM5C,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB,qBAInC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,qBAG9B,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EACF,MAAM,GACN,WAAW,GACX,kBAAkB,GAClB,MAAM,GACN,aAAa,GACb,UAAU,GACV,mCAAmC,GACnC,0CAA0C,GAC1C,WAAW,GACX,2BAA2B,GAC3B,YAAY,GACZ,gBAAgB,GAChB,WAAW,CAAC;IAEhB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAaF,eAAO,MAAM,iBAAiB,uBAG3B,sBAAsB,4CA2HxB,CAAC"}
|
|
@@ -7,6 +7,15 @@ export const LONG_DATE_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
|
7
7
|
month: 'long',
|
|
8
8
|
day: 'numeric',
|
|
9
9
|
});
|
|
10
|
+
/**
|
|
11
|
+
* @description Long date formatter, without weekday.
|
|
12
|
+
* @example 01 September 2025
|
|
13
|
+
*/
|
|
14
|
+
export const LONG_DATE_FORMATER_WITHOUT_WEEKDAY = Intl.DateTimeFormat('en-GB', {
|
|
15
|
+
year: 'numeric',
|
|
16
|
+
month: 'long',
|
|
17
|
+
day: '2-digit',
|
|
18
|
+
});
|
|
10
19
|
export const DATE_FORMATER = Intl.DateTimeFormat('fr-CA', {
|
|
11
20
|
year: 'numeric',
|
|
12
21
|
month: '2-digit',
|
|
@@ -37,6 +46,10 @@ export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND = Intl.DateTimeFormat('en-
|
|
|
37
46
|
second: '2-digit',
|
|
38
47
|
hour12: false,
|
|
39
48
|
});
|
|
49
|
+
/**
|
|
50
|
+
* @description Day month abbreviated hour minute formatter, without second.
|
|
51
|
+
* @example 15 Sept 14:30
|
|
52
|
+
*/
|
|
40
53
|
export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE = Intl.DateTimeFormat('en-GB', {
|
|
41
54
|
day: 'numeric',
|
|
42
55
|
month: 'short',
|
|
@@ -44,6 +57,23 @@ export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE = Intl.DateTimeFormat('en-GB', {
|
|
|
44
57
|
minute: '2-digit',
|
|
45
58
|
hour12: false,
|
|
46
59
|
});
|
|
60
|
+
/**
|
|
61
|
+
* @description Year month day formatter, without time. Used for describing long term date.
|
|
62
|
+
* @example 2025-01-01
|
|
63
|
+
*/
|
|
64
|
+
export const YEAR_MONTH_DAY_FORMATTER = Intl.DateTimeFormat('en-CA', {
|
|
65
|
+
year: 'numeric',
|
|
66
|
+
month: '2-digit',
|
|
67
|
+
day: '2-digit',
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* @description Month day formatter, without year. Used for short term date ranges.
|
|
71
|
+
* @example 01-15
|
|
72
|
+
*/
|
|
73
|
+
export const MONTH_DAY_FORMATTER = Intl.DateTimeFormat('en-CA', {
|
|
74
|
+
month: '2-digit',
|
|
75
|
+
day: '2-digit',
|
|
76
|
+
});
|
|
47
77
|
const isItFutureOrIsItPast = (timeDiff, stringToBeFormatted) => {
|
|
48
78
|
if (timeDiff > 0) {
|
|
49
79
|
return `${stringToBeFormatted} ago`;
|
|
@@ -91,8 +121,14 @@ export const FormattedDateTime = ({ format, value, }) => {
|
|
|
91
121
|
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND.format(value).replace(',', '') }));
|
|
92
122
|
case 'long-date':
|
|
93
123
|
return _jsx(_Fragment, { children: LONG_DATE_FORMATER.format(value) });
|
|
124
|
+
case 'long-date-without-weekday':
|
|
125
|
+
return _jsx(_Fragment, { children: LONG_DATE_FORMATER_WITHOUT_WEEKDAY.format(value) });
|
|
94
126
|
case 'chart-date':
|
|
95
127
|
return _jsx(_Fragment, { children: DAY_MONTH_FORMATER.format(value).replace(/[ ,]/g, '') });
|
|
128
|
+
case 'year-month-day':
|
|
129
|
+
return _jsx(_Fragment, { children: YEAR_MONTH_DAY_FORMATTER.format(value) });
|
|
130
|
+
case 'month-day':
|
|
131
|
+
return _jsx(_Fragment, { children: MONTH_DAY_FORMATTER.format(value) });
|
|
96
132
|
default:
|
|
97
133
|
return _jsx(_Fragment, {});
|
|
98
134
|
}
|
|
@@ -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,
|
|
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,CA2CpC;AAGD,eAAO,MAAM,gBAAgB,UAAW,MAAM,QAAQ,MAAM,WAE3D,CAAC;AACF,eAAO,MAAM,4BAA4B,GAAI,CAAC,SAAS,CAAC,QAAQ,MAAM,KAAG,CAQxE,CAAC;AACF,eAAO,MAAM,gBAAgB,kBAAmB,MAAM,QAAQ,MAAM,WAEnE,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,KAAK,EAAE,KAAG,MAAM,EAMvD,CAAC"}
|
|
@@ -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;
|
|
@@ -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":"AAoGA,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,MA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