@scality/core-ui 0.165.0 → 0.166.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 +19 -0
- package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
- package/dist/components/barchartv2/Barchart.component.js +31 -5
- package/dist/components/barchartv2/ChartTooltip.d.ts +18 -0
- package/dist/components/barchartv2/ChartTooltip.d.ts.map +1 -0
- package/dist/components/barchartv2/ChartTooltip.js +31 -0
- package/dist/components/barchartv2/utils.d.ts +0 -7
- package/dist/components/barchartv2/utils.d.ts.map +1 -1
- package/dist/components/barchartv2/utils.js +1 -29
- package/dist/components/chartlegend/ChartLegend.d.ts +9 -0
- package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegend.js +38 -9
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts +4 -0
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegendWrapper.js +23 -2
- package/dist/components/constants.d.ts +2 -0
- package/dist/components/constants.d.ts.map +1 -1
- package/dist/components/constants.js +6 -0
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts +3 -1
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
- package/dist/components/constrainedtext/Constrainedtext.component.js +2 -2
- package/dist/components/date/FormattedDateTime.d.ts +2 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +10 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +3 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +5 -7
- package/dist/components/text/Text.component.js +1 -1
- package/dist/components/toast/Toast.component.d.ts.map +1 -1
- package/dist/components/toast/Toast.component.js +24 -11
- package/dist/next.d.ts +1 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +1 -0
- package/package.json +1 -2
- package/src/lib/components/barchartv2/Barchart.component.test.tsx +99 -1
- package/src/lib/components/barchartv2/Barchart.component.tsx +39 -11
- package/src/lib/components/barchartv2/ChartTooltip.tsx +76 -0
- package/src/lib/components/barchartv2/utils.ts +2 -33
- package/src/lib/components/chartlegend/ChartLegend.test.tsx +218 -0
- package/src/lib/components/chartlegend/ChartLegend.tsx +42 -8
- package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +75 -29
- package/src/lib/components/constants.ts +11 -0
- package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +5 -2
- package/src/lib/components/date/FormattedDateTime.tsx +15 -1
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +8 -6
- package/src/lib/components/text/Text.component.tsx +1 -1
- package/src/lib/components/toast/Toast.component.tsx +27 -19
- package/src/lib/next.ts +1 -0
- package/stories/constrainedtext.stories.tsx +4 -1
- package/stories/linetimeseriechart.stories.tsx +30 -25
|
@@ -57,5 +57,24 @@ export type BarchartProps<T extends BarchartBars> = {
|
|
|
57
57
|
isLoading?: boolean;
|
|
58
58
|
isError?: boolean;
|
|
59
59
|
};
|
|
60
|
+
interface CustomTickProps {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
payload: {
|
|
64
|
+
value: number;
|
|
65
|
+
};
|
|
66
|
+
visibleTicksCount: number;
|
|
67
|
+
width: number;
|
|
68
|
+
type: TimeType;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Formats a date based on the interval
|
|
72
|
+
* @param timestamp - Timestamp
|
|
73
|
+
* @param interval - Interval in milliseconds
|
|
74
|
+
* @returns Formatted string
|
|
75
|
+
*/
|
|
76
|
+
export declare const formatDate: (timestamp: number, interval: number) => React.ReactNode;
|
|
77
|
+
export declare const CustomTick: ({ x, y, payload, visibleTicksCount, width, type, }: CustomTickProps) => import("react/jsx-runtime").JSX.Element;
|
|
60
78
|
export declare const Barchart: <T extends BarchartBars>(props: BarchartProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
export {};
|
|
61
80
|
//# 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,EAAwB,SAAS,EAAgB,MAAM,SAAS,CAAC;AAmBxE,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;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,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC;CACvE,EAAE,CAAC;AAEJ,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,YAAY,IAAI,CAAC,YAAY,EAAE;IACrE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,MAAM,EAAE;QAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM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,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,4CAwIvE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
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 { useState } from 'react';
|
|
3
3
|
import { Bar, BarChart, CartesianGrid, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts';
|
|
4
4
|
import styled, { useTheme } from 'styled-components';
|
|
@@ -9,8 +9,9 @@ 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 {
|
|
12
|
+
import { renderTooltipContent, useChartData } from './utils';
|
|
13
13
|
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
14
|
+
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
14
15
|
const CHART_CONSTANTS = {
|
|
15
16
|
TICK_WIDTH_OFFSET: 5,
|
|
16
17
|
BAR_SIZE: 12,
|
|
@@ -24,12 +25,37 @@ const CHART_CONSTANTS = {
|
|
|
24
25
|
},
|
|
25
26
|
};
|
|
26
27
|
/* ---------------------------------- COMPONENTS ---------------------------------- */
|
|
27
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Formats a date based on the interval
|
|
30
|
+
* @param timestamp - Timestamp
|
|
31
|
+
* @param interval - Interval in milliseconds
|
|
32
|
+
* @returns Formatted string
|
|
33
|
+
*/
|
|
34
|
+
export const formatDate = (timestamp, interval) => {
|
|
35
|
+
const date = new Date(timestamp);
|
|
36
|
+
// More than 24 hours interval - use day and time format
|
|
37
|
+
if (interval > 24 * 60 * 60 * 1000) {
|
|
38
|
+
return (_jsxs(_Fragment, { children: [_jsx(FormattedDateTime, { format: "chart-date", value: date }), ' ', _jsx(FormattedDateTime, { format: "time", value: date })] }));
|
|
39
|
+
}
|
|
40
|
+
else if (interval === 24 * 60 * 60 * 1000) {
|
|
41
|
+
// Daily interval - use day format
|
|
42
|
+
return _jsx(FormattedDateTime, { format: "chart-date", value: date });
|
|
43
|
+
}
|
|
44
|
+
else if (interval >= 60 * 1000) {
|
|
45
|
+
//Hourly and minute intervals - use minute format
|
|
46
|
+
return _jsx(FormattedDateTime, { format: "time", value: date });
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// minute interval or less - use full timestamp
|
|
50
|
+
return timestamp;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export const CustomTick = ({ x, y, payload, visibleTicksCount, width, type, }) => {
|
|
28
54
|
const theme = useTheme();
|
|
29
55
|
const tickWidth = width / visibleTicksCount - CHART_CONSTANTS.TICK_WIDTH_OFFSET;
|
|
30
56
|
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",
|
|
32
|
-
? formatDate(
|
|
57
|
+
return (_jsx("foreignObject", { x: centerX, y: y, width: tickWidth, color: theme.textSecondary, overflow: "visible", children: _jsx(ConstrainedText, { color: "textSecondary", text: _jsx(Text, { variant: "Smaller", children: type.type === 'time'
|
|
58
|
+
? formatDate(payload.value, type.timeRange.interval)
|
|
33
59
|
: String(payload.value) }), centered: true, tooltipStyle: {
|
|
34
60
|
backgroundColor: theme.backgroundLevel1,
|
|
35
61
|
padding: spacing.r10,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BarchartBars } from './Barchart.component';
|
|
2
|
+
export declare const ChartTooltipContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const ChartTooltipItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
4
|
+
isHovered: boolean;
|
|
5
|
+
}, never>;
|
|
6
|
+
export declare const ChartTooltip: <T extends BarchartBars>({ type, currentPoint, colorSet, }: {
|
|
7
|
+
type: "time" | "category";
|
|
8
|
+
currentPoint: {
|
|
9
|
+
category: string | number;
|
|
10
|
+
values: {
|
|
11
|
+
label: T[number]["label"];
|
|
12
|
+
value: number;
|
|
13
|
+
isHovered: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
colorSet: Record<string, string>;
|
|
17
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=ChartTooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/ChartTooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKpD,eAAO,MAAM,qBAAqB,yGAYjC,CAAC;AAEF,eAAO,MAAM,gBAAgB;eAA2B,OAAO;SAM9D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,YAAY,qCAIhD;IACD,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,YAAY,EAAE;QACZ,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;QAC1B,MAAM,EAAE;YAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,OAAO,CAAA;SAAE,EAAE,CAAC;KAC5E,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,4CAkCA,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { spacing, Stack, Wrap } from '../../spacing';
|
|
4
|
+
import { Text } from '../text/Text.component';
|
|
5
|
+
import { fontSize, fontWeight } from '../../style/theme';
|
|
6
|
+
import { LegendShape } from '../chartlegend/ChartLegend';
|
|
7
|
+
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
8
|
+
export const ChartTooltipContainer = styled.div `
|
|
9
|
+
background-color: ${({ theme }) => theme.backgroundLevel1};
|
|
10
|
+
padding: ${spacing.r4} ${spacing.r8};
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
width: max-content;
|
|
13
|
+
max-width: 40rem;
|
|
14
|
+
border: 1px solid ${({ theme }) => theme.border};
|
|
15
|
+
display: flex;
|
|
16
|
+
font-size: ${fontSize.small};
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: 16px;
|
|
19
|
+
align-items: center;
|
|
20
|
+
`;
|
|
21
|
+
export const ChartTooltipItem = styled.div `
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 8px;
|
|
25
|
+
font-weight: ${({ isHovered }) => isHovered ? fontWeight.bold : fontWeight.base};
|
|
26
|
+
`;
|
|
27
|
+
export const ChartTooltip = ({ type, currentPoint, colorSet, }) => {
|
|
28
|
+
return (_jsxs(ChartTooltipContainer, { children: [_jsx(Text, { isEmphazed: true, children: type === 'time' ? (_jsx(FormattedDateTime, { format: "long-date", value: new Date(currentPoint.category) })) : (currentPoint.category) }), _jsx(Stack, { direction: "vertical", gap: "r8", style: { width: '100%' }, children: currentPoint.values.map((value) => {
|
|
29
|
+
return (_jsxs(Wrap, { children: [_jsxs(ChartTooltipItem, { isHovered: value.isHovered, children: [_jsx(LegendShape, { color: colorSet[value.label], shape: "rectangle", chartColors: colorSet }), value.label] }), _jsx(ChartTooltipItem, { isHovered: value.isHovered, children: value.value })] }, value.label));
|
|
30
|
+
}) })] }));
|
|
31
|
+
};
|
|
@@ -5,13 +5,6 @@ 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;
|
|
15
8
|
/**
|
|
16
9
|
* Transforms time-based data into chart format
|
|
17
10
|
*/
|
|
@@ -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;
|
|
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;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,MAAM,GAAG,MAAM,GAAG,MAAM,C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AM,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"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DAY_MONTH_FORMATER, TIME_FORMATER } from '../date/FormattedDateTime';
|
|
2
1
|
import { chartColors } from '../../style/theme';
|
|
3
2
|
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
4
3
|
export const getRoundReferenceValue = (value) => {
|
|
@@ -62,31 +61,6 @@ const generateTimeRanges = (startDate, endDate, interval) => {
|
|
|
62
61
|
}
|
|
63
62
|
return ranges;
|
|
64
63
|
};
|
|
65
|
-
/**
|
|
66
|
-
* Formats a date based on the interval
|
|
67
|
-
* @param date - Date object
|
|
68
|
-
* @param interval - Interval in milliseconds
|
|
69
|
-
* @returns Formatted string
|
|
70
|
-
*/
|
|
71
|
-
export const formatDate = (date, interval) => {
|
|
72
|
-
if (interval > 24 * 60 * 60 * 1000) {
|
|
73
|
-
return (DAY_MONTH_FORMATER.format(date).replace(/[ ,]/g, '') +
|
|
74
|
-
' ' +
|
|
75
|
-
TIME_FORMATER.format(date));
|
|
76
|
-
}
|
|
77
|
-
else if (interval === 24 * 60 * 60 * 1000) {
|
|
78
|
-
// Daily or longer intervals - use day format
|
|
79
|
-
return DAY_MONTH_FORMATER.format(date).replace(/[ ,]/g, '');
|
|
80
|
-
}
|
|
81
|
-
else if (interval >= 60 * 1000) {
|
|
82
|
-
//Handle hourly and minute intervals - use minute format
|
|
83
|
-
return TIME_FORMATER.format(date);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// Second intervals or less - use full timestamp
|
|
87
|
-
return date.toISOString();
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
64
|
/**
|
|
91
65
|
* Finds the time range that contains the given date
|
|
92
66
|
* @param date - Data point date
|
|
@@ -105,10 +79,8 @@ export const transformTimeData = (bars, type, barDataKeys) => {
|
|
|
105
79
|
const categoryMap = new Map();
|
|
106
80
|
// Initialize all ranges with zeros
|
|
107
81
|
timeRanges.forEach((range) => {
|
|
108
|
-
// const categoryDisplay = formatDate(range.start, type.timeRange.interval);
|
|
109
|
-
const categoryDisplay = range.start.getTime();
|
|
110
82
|
const initialData = {
|
|
111
|
-
category:
|
|
83
|
+
category: range.start.getTime(),
|
|
112
84
|
};
|
|
113
85
|
barDataKeys.forEach((dataKey) => {
|
|
114
86
|
initialData[dataKey] = 0;
|
|
@@ -3,6 +3,15 @@ type ChartLegendProps = {
|
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
direction?: 'horizontal' | 'vertical';
|
|
5
5
|
};
|
|
6
|
+
export declare const LegendItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
selected?: boolean;
|
|
9
|
+
}, never>;
|
|
10
|
+
export declare const LegendShape: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
11
|
+
color?: string;
|
|
12
|
+
shape: "line" | "rectangle";
|
|
13
|
+
chartColors: Record<string, string>;
|
|
14
|
+
}, never>;
|
|
6
15
|
export declare const ChartLegend: ({ shape, disabled, direction, }: ChartLegendProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
16
|
export {};
|
|
8
17
|
//# sourceMappingURL=ChartLegend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartLegend.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegend.tsx"],"names":[],"mappings":"AAMA,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACvC,CAAC;
|
|
1
|
+
{"version":3,"file":"ChartLegend.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegend.tsx"],"names":[],"mappings":"AAMA,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACvC,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,oCAIrB,gBAAgB,4CA+ElB,CAAC"}
|
|
@@ -10,7 +10,7 @@ const Legend = styled.div `
|
|
|
10
10
|
gap: ${({ direction }) => (direction === 'horizontal' ? '16px' : '8px')};
|
|
11
11
|
flex-wrap: wrap;
|
|
12
12
|
`;
|
|
13
|
-
const LegendItem = styled.div `
|
|
13
|
+
export const LegendItem = styled.div `
|
|
14
14
|
display: flex;
|
|
15
15
|
align-items: center;
|
|
16
16
|
gap: 8px;
|
|
@@ -22,7 +22,7 @@ const LegendItem = styled.div `
|
|
|
22
22
|
opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
|
-
const LegendShape = styled.div `
|
|
25
|
+
export const LegendShape = styled.div `
|
|
26
26
|
${({ shape, color, chartColors }) => {
|
|
27
27
|
if (shape === 'line') {
|
|
28
28
|
return `
|
|
@@ -45,21 +45,50 @@ const LegendShape = styled.div `
|
|
|
45
45
|
}}
|
|
46
46
|
`;
|
|
47
47
|
export const ChartLegend = ({ shape, disabled = false, direction = 'horizontal', }) => {
|
|
48
|
-
const { listResources, getColor, isSelected, addSelectedResource, removeSelectedResource, } = useChartLegend();
|
|
48
|
+
const { listResources, getColor, isSelected, addSelectedResource, removeSelectedResource, selectAllResources, getAllResourcesCount, getSelectedCount, selectOnlyResource, } = useChartLegend();
|
|
49
49
|
const resources = listResources();
|
|
50
|
-
const handleLegendClick = useCallback((resource) => {
|
|
50
|
+
const handleLegendClick = useCallback((resource, event) => {
|
|
51
51
|
if (disabled)
|
|
52
52
|
return;
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const isModifierClick = event.metaKey || event.ctrlKey;
|
|
54
|
+
const itemIsSelected = isSelected(resource);
|
|
55
|
+
if (isModifierClick) {
|
|
56
|
+
if (itemIsSelected) {
|
|
57
|
+
if (getSelectedCount() === 1) {
|
|
58
|
+
selectAllResources();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
removeSelectedResource(resource);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
addSelectedResource(resource);
|
|
66
|
+
}
|
|
55
67
|
}
|
|
56
68
|
else {
|
|
57
|
-
|
|
69
|
+
if (getSelectedCount() === getAllResourcesCount()) {
|
|
70
|
+
selectOnlyResource(resource);
|
|
71
|
+
}
|
|
72
|
+
else if (itemIsSelected) {
|
|
73
|
+
selectAllResources();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
selectOnlyResource(resource);
|
|
77
|
+
}
|
|
58
78
|
}
|
|
59
|
-
}, [
|
|
79
|
+
}, [
|
|
80
|
+
disabled,
|
|
81
|
+
isSelected,
|
|
82
|
+
addSelectedResource,
|
|
83
|
+
removeSelectedResource,
|
|
84
|
+
selectAllResources,
|
|
85
|
+
selectOnlyResource,
|
|
86
|
+
getAllResourcesCount,
|
|
87
|
+
getSelectedCount,
|
|
88
|
+
]);
|
|
60
89
|
return (_jsx(Legend, { direction: direction, children: resources.map((resource) => {
|
|
61
90
|
const color = getColor(resource);
|
|
62
91
|
const selected = isSelected(resource);
|
|
63
|
-
return (_jsxs(LegendItem, { disabled: disabled, selected: selected, onClick: () => handleLegendClick(resource), children: [_jsx(LegendShape, { color: color, shape: shape, chartColors: chartColors }), _jsx(Text, { variant: "Basic", children: resource })] }, resource));
|
|
92
|
+
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: "Basic", children: resource })] }, resource));
|
|
64
93
|
}) }));
|
|
65
94
|
};
|
|
@@ -4,9 +4,13 @@ export type ChartLegendState = {
|
|
|
4
4
|
selectedResources: string[];
|
|
5
5
|
addSelectedResource: (resource: string) => void;
|
|
6
6
|
removeSelectedResource: (resource: string) => void;
|
|
7
|
+
selectAllResources: () => void;
|
|
8
|
+
selectOnlyResource: (resource: string) => void;
|
|
7
9
|
isSelected: (resource: string) => boolean;
|
|
8
10
|
getColor: (resource: string) => string | undefined;
|
|
9
11
|
listResources: () => string[];
|
|
12
|
+
getAllResourcesCount: () => number;
|
|
13
|
+
getSelectedCount: () => number;
|
|
10
14
|
};
|
|
11
15
|
export type ChartLegendWrapperProps = {
|
|
12
16
|
children: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartLegendWrapper.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegendWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ChartLegendWrapper.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegendWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAGV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,sBAAsB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAC1C,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACnD,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;IAC9B,oBAAoB,EAAE,MAAM,MAAM,CAAC;IACnC,gBAAgB,EAAE,MAAM,MAAM,CAAC;CAChC,CAAC;AAIF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,kBAAkB,4BAG5B,uBAAuB,4CAwFzB,CAAC;AAGF,eAAO,MAAM,cAAc,wBAM1B,CAAC"}
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import { createContext, useContext, useState, useMemo, useCallback, } from 'react';
|
|
3
3
|
const ChartLegendContext = createContext(null);
|
|
4
4
|
export const ChartLegendWrapper = ({ children, colorSet, }) => {
|
|
5
|
-
const
|
|
5
|
+
const allResources = Object.keys(colorSet);
|
|
6
|
+
const [selectedResources, setSelectedResources] = useState(allResources);
|
|
6
7
|
const addSelectedResource = useCallback((resource) => {
|
|
7
8
|
setSelectedResources((prev) => prev.includes(resource) ? prev : [...prev, resource]);
|
|
8
9
|
}, []);
|
|
9
10
|
const removeSelectedResource = useCallback((resource) => {
|
|
10
11
|
setSelectedResources((prev) => prev.filter((r) => r !== resource));
|
|
11
12
|
}, []);
|
|
13
|
+
const selectAllResources = useCallback(() => {
|
|
14
|
+
setSelectedResources(allResources);
|
|
15
|
+
}, [allResources]);
|
|
16
|
+
const selectOnlyResource = useCallback((resource) => {
|
|
17
|
+
setSelectedResources([resource]);
|
|
18
|
+
}, []);
|
|
19
|
+
const getAllResourcesCount = useCallback(() => {
|
|
20
|
+
return allResources.length;
|
|
21
|
+
}, [allResources]);
|
|
22
|
+
const getSelectedCount = useCallback(() => {
|
|
23
|
+
return selectedResources.length;
|
|
24
|
+
}, [selectedResources]);
|
|
12
25
|
const isSelected = useCallback((resource) => {
|
|
13
26
|
return selectedResources.includes(resource);
|
|
14
27
|
}, [selectedResources]);
|
|
@@ -27,16 +40,24 @@ export const ChartLegendWrapper = ({ children, colorSet, }) => {
|
|
|
27
40
|
selectedResources,
|
|
28
41
|
addSelectedResource,
|
|
29
42
|
removeSelectedResource,
|
|
43
|
+
selectAllResources,
|
|
44
|
+
selectOnlyResource,
|
|
30
45
|
isSelected,
|
|
31
46
|
getColor,
|
|
32
47
|
listResources,
|
|
48
|
+
getAllResourcesCount,
|
|
49
|
+
getSelectedCount,
|
|
33
50
|
}), [
|
|
34
51
|
selectedResources,
|
|
35
52
|
addSelectedResource,
|
|
36
53
|
removeSelectedResource,
|
|
54
|
+
selectAllResources,
|
|
55
|
+
selectOnlyResource,
|
|
37
56
|
isSelected,
|
|
38
57
|
getColor,
|
|
39
58
|
listResources,
|
|
59
|
+
getAllResourcesCount,
|
|
60
|
+
getSelectedCount,
|
|
40
61
|
]);
|
|
41
62
|
return (_jsx(ChartLegendContext.Provider, { value: chartLegendState, children: children }));
|
|
42
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/components/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAE;KAAG,GAAG,IAAI,IAAI,GAAG,GAAG;CAQ7C,CAAC;AACF,MAAM,MAAM,IAAI,GACZ,SAAS,GACT,OAAO,GACP,MAAM,GACN,OAAO,GACP,Q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CY_LAST_SEVEN_DAYS,
|
|
33
|
+
/** @deprecated Use `interval` instead */
|
|
32
34
|
frequency: SAMPLE_FREQUENCY_LAST_SEVEN_DAYS,
|
|
33
35
|
},
|
|
34
36
|
{
|
|
35
37
|
query: QUERY_LAST_TWENTY_FOUR_HOURS,
|
|
36
38
|
label: LAST_TWENTY_FOUR_HOURS,
|
|
37
39
|
duration: SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
|
|
40
|
+
interval: SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS,
|
|
41
|
+
/** @deprecated Use `interval` instead */
|
|
38
42
|
frequency: SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS,
|
|
39
43
|
},
|
|
40
44
|
{
|
|
41
45
|
query: QUERY_LAST_ONE_HOUR,
|
|
42
46
|
label: LAST_ONE_HOUR,
|
|
43
47
|
duration: SAMPLE_DURATION_LAST_ONE_HOUR,
|
|
48
|
+
interval: SAMPLE_FREQUENCY_LAST_ONE_HOUR,
|
|
49
|
+
/** @deprecated Use `interval` instead */
|
|
44
50
|
frequency: SAMPLE_FREQUENCY_LAST_ONE_HOUR,
|
|
45
51
|
},
|
|
46
52
|
];
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { $PropertyType } from 'utility-types';
|
|
2
2
|
import { Props as TooltipProps } from '../tooltip/Tooltip.component';
|
|
3
|
+
import { CoreUITheme } from '../../style/theme';
|
|
3
4
|
type Props = {
|
|
4
5
|
text: string | number | JSX.Element | JSX.Element[];
|
|
5
6
|
tooltipStyle?: $PropertyType<TooltipProps, 'overlayStyle'>;
|
|
6
7
|
tooltipPlacement?: $PropertyType<TooltipProps, 'placement'>;
|
|
7
8
|
lineClamp?: number;
|
|
8
9
|
centered?: boolean;
|
|
10
|
+
color?: keyof CoreUITheme;
|
|
9
11
|
};
|
|
10
|
-
declare function ConstrainedText({ text, tooltipStyle, tooltipPlacement, lineClamp, centered, }: Props): JSX.Element;
|
|
12
|
+
declare function ConstrainedText({ text, tooltipStyle, tooltipPlacement, lineClamp, color, centered, }: Props): JSX.Element;
|
|
11
13
|
export { ConstrainedText };
|
|
12
14
|
//# sourceMappingURL=Constrainedtext.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constrainedtext.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/constrainedtext/Constrainedtext.component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"Constrainedtext.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/constrainedtext/Constrainedtext.component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACpD,YAAY,CAAC,EAAE,aAAa,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IAC3D,gBAAgB,CAAC,EAAE,aAAa,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,WAAW,CAAC;CAC3B,CAAC;AAwDF,iBAAS,eAAe,CAAC,EACvB,IAAI,EACJ,YAAY,EACZ,gBAAgB,EAChB,SAAa,EACb,KAAK,EACL,QAAgB,GACjB,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAqCrB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -38,11 +38,11 @@ function isEllipsisActive(element) {
|
|
|
38
38
|
function getConstrainedTextContainer(constrainedTextRef, lineClamp, text, centered) {
|
|
39
39
|
return (_jsx(ConstrainedTextContainer, { ref: constrainedTextRef, className: "sc-constrainedtext", lineClamp: lineClamp, centered: centered, children: text }));
|
|
40
40
|
}
|
|
41
|
-
function ConstrainedText({ text, tooltipStyle, tooltipPlacement, lineClamp = 1, centered = false, }) {
|
|
41
|
+
function ConstrainedText({ text, tooltipStyle, tooltipPlacement, lineClamp = 1, color, centered = false, }) {
|
|
42
42
|
const [displayToolTip, setDisplayToolTip] = useState(false);
|
|
43
43
|
const constrainedTextRef = useCallback((element) => {
|
|
44
44
|
element && text && setDisplayToolTip(isEllipsisActive(element));
|
|
45
45
|
}, [text]);
|
|
46
|
-
return (_jsx(BlockTooltip, { children: displayToolTip ? (_jsx(Tooltip, { overlay: text, overlayStyle: tooltipStyle, placement: tooltipPlacement, children: _jsx(Text, { children: getConstrainedTextContainer(constrainedTextRef, lineClamp, text, centered) }) })) : (_jsx(Text, { children: getConstrainedTextContainer(constrainedTextRef, lineClamp, text, centered) })) }));
|
|
46
|
+
return (_jsx(BlockTooltip, { children: displayToolTip ? (_jsx(Tooltip, { overlay: text, overlayStyle: tooltipStyle, placement: tooltipPlacement, children: _jsx(Text, { color: color, children: getConstrainedTextContainer(constrainedTextRef, lineClamp, text, centered) }) })) : (_jsx(Text, { color: color, children: getConstrainedTextContainer(constrainedTextRef, lineClamp, text, centered) })) }));
|
|
47
47
|
}
|
|
48
48
|
export { ConstrainedText };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const LONG_DATE_FORMATER: Intl.DateTimeFormat;
|
|
1
2
|
export declare const DATE_FORMATER: Intl.DateTimeFormat;
|
|
2
3
|
export declare const DAY_MONTH_FORMATER: Intl.DateTimeFormat;
|
|
3
4
|
export declare const TIME_SECOND_FORMATER: Intl.DateTimeFormat;
|
|
@@ -5,7 +6,7 @@ export declare const TIME_FORMATER: Intl.DateTimeFormat;
|
|
|
5
6
|
export declare const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND: Intl.DateTimeFormat;
|
|
6
7
|
export declare const DAY_MONTH_ABBREVIATED_HOUR_MINUTE: Intl.DateTimeFormat;
|
|
7
8
|
type FormattedDateTimeProps = {
|
|
8
|
-
format: 'date' | 'date-time' | 'date-time-second' | 'time' | 'time-second' | 'relative' | 'day-month-abbreviated-hour-minute' | 'day-month-abbreviated-hour-minute-second';
|
|
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';
|
|
9
10
|
value: Date;
|
|
10
11
|
};
|
|
11
12
|
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,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,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,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;IAEjB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAaF,eAAO,MAAM,iBAAiB,uBAG3B,sBAAsB,4CAqHxB,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getDateDaysDiff } from './dateDiffer';
|
|
3
3
|
import { Tooltip } from '../tooltip/Tooltip.component';
|
|
4
|
+
export const LONG_DATE_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
5
|
+
weekday: 'long',
|
|
6
|
+
year: 'numeric',
|
|
7
|
+
month: 'long',
|
|
8
|
+
day: 'numeric',
|
|
9
|
+
});
|
|
4
10
|
export const DATE_FORMATER = Intl.DateTimeFormat('fr-CA', {
|
|
5
11
|
year: 'numeric',
|
|
6
12
|
month: '2-digit',
|
|
@@ -83,6 +89,10 @@ export const FormattedDateTime = ({ format, value, }) => {
|
|
|
83
89
|
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE.format(value).replace(',', '') }));
|
|
84
90
|
case 'day-month-abbreviated-hour-minute-second':
|
|
85
91
|
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND.format(value).replace(',', '') }));
|
|
92
|
+
case 'long-date':
|
|
93
|
+
return _jsx(_Fragment, { children: LONG_DATE_FORMATER.format(value) });
|
|
94
|
+
case 'chart-date':
|
|
95
|
+
return _jsx(_Fragment, { children: DAY_MONTH_FORMATER.format(value).replace(/[ ,]/g, '') });
|
|
86
96
|
default:
|
|
87
97
|
return _jsx(_Fragment, {});
|
|
88
98
|
}
|
|
@@ -20,6 +20,8 @@ export type LineChartProps = (NonSymmetricalChartSerie | SymmetricalChartSerie)
|
|
|
20
20
|
title: string;
|
|
21
21
|
height: number;
|
|
22
22
|
startingTimeStamp: number;
|
|
23
|
+
interval: number;
|
|
24
|
+
duration: number;
|
|
23
25
|
unitRange?: {
|
|
24
26
|
threshold: number;
|
|
25
27
|
label: string;
|
|
@@ -28,6 +30,6 @@ export type LineChartProps = (NonSymmetricalChartSerie | SymmetricalChartSerie)
|
|
|
28
30
|
yAxisTitle?: string;
|
|
29
31
|
helpText?: string;
|
|
30
32
|
};
|
|
31
|
-
export declare function LineTimeSerieChart({ series, title, height, startingTimeStamp, unitRange, isLoading, yAxisType, yAxisTitle, helpText, ...rest }: LineChartProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare function LineTimeSerieChart({ series, title, height, startingTimeStamp, interval, duration, unitRange, isLoading, yAxisType, yAxisTitle, helpText, ...rest }: LineChartProps): import("react/jsx-runtime").JSX.Element;
|
|
32
34
|
export {};
|
|
33
35
|
//# 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":"AA0FA,MAAM,MAAM,KAAK,GAAG;IAElB,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAEhC,eAAe,EAAE,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XAxis, YAxis, CartesianGrid, } from 'recharts';
|
|
3
3
|
import { useMemo, useRef } from 'react';
|
|
4
4
|
import { useTheme } from 'styled-components';
|
|
5
|
-
import { useMetricsTimeSpan } from '../linetemporalchart/MetricTimespanProvider';
|
|
6
5
|
import { addMissingDataPoint } from '../linetemporalchart/ChartUtil';
|
|
7
6
|
import styled from 'styled-components';
|
|
8
7
|
import { fontSize, fontWeight } from '../../style/theme';
|
|
@@ -91,9 +90,8 @@ const CustomTooltip = ({ active, payload, label, unitLabel, }) => {
|
|
|
91
90
|
const isSymmetricalSeries = (series) => {
|
|
92
91
|
return 'above' in series && 'below' in series;
|
|
93
92
|
};
|
|
94
|
-
export function LineTimeSerieChart({ series, title, height, startingTimeStamp, unitRange, isLoading = false, yAxisType = 'default', yAxisTitle, helpText, ...rest }) {
|
|
93
|
+
export function LineTimeSerieChart({ series, title, height, startingTimeStamp, interval, duration, unitRange, isLoading = false, yAxisType = 'default', yAxisTitle, helpText, ...rest }) {
|
|
95
94
|
const theme = useTheme();
|
|
96
|
-
const { frequency, duration } = useMetricsTimeSpan();
|
|
97
95
|
const { getColor } = useChartLegend();
|
|
98
96
|
const chartRef = useRef(null);
|
|
99
97
|
const chartData = useMemo(() => {
|
|
@@ -102,17 +100,17 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, u
|
|
|
102
100
|
? {
|
|
103
101
|
above: series.above.map((line) => ({
|
|
104
102
|
...line,
|
|
105
|
-
data: addMissingDataPoint(line.data, startingTimeStamp, duration,
|
|
103
|
+
data: addMissingDataPoint(line.data, startingTimeStamp, duration, interval),
|
|
106
104
|
})),
|
|
107
105
|
// Convert positive values to negative values
|
|
108
106
|
below: series.below.map((line) => ({
|
|
109
107
|
...line,
|
|
110
|
-
data: addMissingDataPoint(line.data, startingTimeStamp, duration,
|
|
108
|
+
data: addMissingDataPoint(line.data, startingTimeStamp, duration, interval).map(([timestamp, value]) => [timestamp, value === null ? null : `-${Number(value)}`]),
|
|
111
109
|
})),
|
|
112
110
|
}
|
|
113
111
|
: series.map((line) => ({
|
|
114
112
|
...line,
|
|
115
|
-
data: addMissingDataPoint(line.data, startingTimeStamp, duration,
|
|
113
|
+
data: addMissingDataPoint(line.data, startingTimeStamp, duration, interval),
|
|
116
114
|
}));
|
|
117
115
|
// 2. Convert directly to Recharts format
|
|
118
116
|
// Initialize an object to hold data points by timestamp
|
|
@@ -136,7 +134,7 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, u
|
|
|
136
134
|
});
|
|
137
135
|
// Convert object to array for Recharts
|
|
138
136
|
return Object.values(dataPointsByTime).sort((a, b) => a.timestamp - b.timestamp);
|
|
139
|
-
}, [series, startingTimeStamp, duration,
|
|
137
|
+
}, [series, startingTimeStamp, duration, interval, yAxisType]);
|
|
140
138
|
// Calculate 5 perfectly evenly spaced ticks
|
|
141
139
|
const xAxisTicks = useMemo(() => {
|
|
142
140
|
if (!chartData || chartData.length === 0)
|
|
@@ -99,7 +99,7 @@ export const GentleEmphaseSecondaryText = styled(SecondaryText) `
|
|
|
99
99
|
: ''}
|
|
100
100
|
`;
|
|
101
101
|
export const Text = styled.span `
|
|
102
|
-
|
|
102
|
+
${(props) => props.color && `color: ${props.theme[props.color]};`}
|
|
103
103
|
${(props) => props.variant === 'Larger'
|
|
104
104
|
? `
|
|
105
105
|
font-size: 1.43rem;
|