@scality/core-ui 0.161.0 → 0.163.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/README.md +15 -15
- package/dist/components/accordion/Accordion.component.d.ts +0 -1
- package/dist/components/accordion/Accordion.component.d.ts.map +1 -1
- package/dist/components/barchartv2/Barchart.component.d.ts +53 -0
- package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -0
- package/dist/components/barchartv2/Barchart.component.js +86 -0
- package/dist/components/barchartv2/utils.d.ts +118 -0
- package/dist/components/barchartv2/utils.d.ts.map +1 -0
- package/dist/components/barchartv2/utils.js +337 -0
- package/dist/components/buttonv2/Buttonv2.component.d.ts +1 -1
- package/dist/components/buttonv2/Buttonv2.component.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegend.d.ts +8 -0
- package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -0
- package/dist/components/chartlegend/ChartLegend.js +65 -0
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts +17 -0
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -0
- package/dist/components/chartlegend/ChartLegendWrapper.js +50 -0
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts +2 -1
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
- package/dist/components/constrainedtext/Constrainedtext.component.js +5 -4
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts +0 -1
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.d.ts +4 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +24 -1
- package/dist/components/date/FormattedDateTime.spec.js +12 -0
- package/dist/components/emptytable/Emptytable.component.d.ts +0 -1
- package/dist/components/emptytable/Emptytable.component.d.ts.map +1 -1
- package/dist/components/emptytable/Emptytable.component.js +1 -0
- package/dist/components/error-pages/ErrorPage401.component.d.ts +0 -1
- package/dist/components/error-pages/ErrorPage401.component.d.ts.map +1 -1
- package/dist/components/error-pages/ErrorPage404.component.d.ts +0 -1
- package/dist/components/error-pages/ErrorPage404.component.d.ts.map +1 -1
- package/dist/components/error-pages/ErrorPage500.component.d.ts +0 -1
- package/dist/components/error-pages/ErrorPage500.component.d.ts.map +1 -1
- package/dist/components/error-pages/ErrorPageAuth.component.d.ts.map +1 -1
- package/dist/components/form/Form.component.d.ts +2 -2
- package/dist/components/form/Form.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.d.ts +5 -5
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +33 -31
- package/dist/components/infomessage/InfoMessage.component.d.ts +0 -1
- package/dist/components/infomessage/InfoMessage.component.d.ts.map +1 -1
- package/dist/components/lateralnavbarlayout/LateralNavbarLayout.component.d.ts.map +1 -1
- package/dist/components/layout/Layout.component.d.ts.map +1 -1
- package/dist/components/layout/v2/panels.d.ts.map +1 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +33 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +249 -0
- package/dist/components/modal/Modal.component.js +2 -2
- package/dist/components/navbar/Navbar.component.js +2 -2
- package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.d.ts +0 -1
- package/dist/components/scrollbarwrapper/ScrollbarWrapper.component.d.ts.map +1 -1
- package/dist/components/searchinput/SearchInput.component.d.ts +1 -2
- package/dist/components/searchinput/SearchInput.component.d.ts.map +1 -1
- package/dist/components/selectv2/Selectv2.component.d.ts +5 -5
- package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -1
- package/dist/components/selectv2/Selectv2.component.js +11 -6
- package/dist/components/statuswrapper/Statuswrapper.component.d.ts +0 -1
- package/dist/components/statuswrapper/Statuswrapper.component.d.ts.map +1 -1
- package/dist/components/steppers/Stepper.component.d.ts.map +1 -1
- package/dist/components/steppers/Stepper.component.js +9 -8
- package/dist/components/tablev2/Search.js +2 -2
- package/dist/components/tablev2/SingleSelectableContent.d.ts +1 -2
- package/dist/components/tablev2/SingleSelectableContent.d.ts.map +1 -1
- package/dist/components/tablev2/TableCommon.d.ts +2 -2
- package/dist/components/tablev2/TableCommon.d.ts.map +1 -1
- package/dist/components/tablev2/TableSync.d.ts +8 -0
- package/dist/components/tablev2/TableSync.d.ts.map +1 -0
- package/dist/components/tablev2/TableSync.js +11 -0
- package/dist/components/tablev2/Tablev2.component.d.ts +2 -1
- package/dist/components/tablev2/Tablev2.component.d.ts.map +1 -1
- package/dist/components/tablev2/Tablev2.component.js +10 -9
- package/dist/components/tabsv2/ScrollButton.d.ts +1 -2
- package/dist/components/tabsv2/ScrollButton.d.ts.map +1 -1
- package/dist/components/tabsv2/ScrollButton.js +2 -2
- package/dist/components/tabsv2/Tabsv2.component.d.ts +2 -2
- package/dist/components/tabsv2/Tabsv2.component.d.ts.map +1 -1
- package/dist/components/tabsv2/Tabsv2.component.js +2 -2
- package/dist/components/text/Text.component.d.ts +0 -1
- package/dist/components/text/Text.component.d.ts.map +1 -1
- package/dist/components/textarea/TextArea.component.d.ts +3 -3
- package/dist/components/textarea/TextArea.component.d.ts.map +1 -1
- package/dist/components/textbadge/TextBadge.component.d.ts +0 -1
- package/dist/components/textbadge/TextBadge.component.d.ts.map +1 -1
- package/dist/components/toast/Toast.component.d.ts +1 -1
- package/dist/components/toast/Toast.component.d.ts.map +1 -1
- package/dist/components/toast/ToastProvider.d.ts.map +1 -1
- package/dist/components/toast/ToastProvider.js +4 -5
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts +1 -2
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +1 -1
- package/dist/components/vegachartv2/SyncedCursorCharts.js +3 -5
- package/dist/components/vegachartv2/VegaChartV2.component.d.ts +1 -2
- package/dist/components/vegachartv2/VegaChartV2.component.d.ts.map +1 -1
- package/dist/components/vegachartv2/VegaChartV2.component.js +2 -2
- package/dist/icons/branding.d.ts.map +1 -1
- package/dist/icons/scality-loading.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/next.d.ts +2 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +2 -0
- package/dist/style/theme.d.ts +20 -0
- package/dist/style/theme.d.ts.map +1 -1
- package/dist/style/theme.js +46 -1
- package/package.json +7 -4
- package/setupTests.js +6 -0
- package/src/lib/components/accordion/Accordion.component.tsx +1 -1
- package/src/lib/components/accordion/Accordion.test.tsx +7 -15
- package/src/lib/components/barchartv2/Barchart.component.test.tsx +364 -0
- package/src/lib/components/barchartv2/Barchart.component.tsx +321 -0
- package/src/lib/components/barchartv2/utils.test.ts +899 -0
- package/src/lib/components/barchartv2/utils.ts +534 -0
- package/src/lib/components/buttonv2/Buttonv2.component.tsx +1 -1
- package/src/lib/components/chartlegend/ChartLegend.tsx +113 -0
- package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +85 -0
- package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +22 -3
- package/src/lib/components/coreuithemeprovider/CoreUiThemeProvider.tsx +0 -1
- package/src/lib/components/date/FormattedDateTime.spec.tsx +24 -0
- package/src/lib/components/date/FormattedDateTime.tsx +42 -2
- package/src/lib/components/emptytable/Emptytable.component.tsx +1 -1
- package/src/lib/components/error-pages/ErrorPage401.component.tsx +0 -1
- package/src/lib/components/error-pages/ErrorPage404.component.tsx +0 -1
- package/src/lib/components/error-pages/ErrorPage500.component.tsx +0 -1
- package/src/lib/components/error-pages/ErrorPageAuth.component.tsx +0 -1
- package/src/lib/components/form/Form.component.tsx +1 -1
- package/src/lib/components/healthselectorv2/HealthSelector.component.test.tsx +3 -3
- package/src/lib/components/icon/Icon.component.tsx +48 -60
- package/src/lib/components/infomessage/InfoMessage.component.tsx +0 -1
- package/src/lib/components/inlineinput/InlineInput.test.tsx +22 -19
- package/src/lib/components/inputlist/InputList.test.tsx +21 -19
- package/src/lib/components/lateralnavbarlayout/LateralNavbarLayout.component.tsx +0 -1
- package/src/lib/components/layout/Layout.component.tsx +0 -1
- package/src/lib/components/layout/v2/panels.tsx +1 -1
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +502 -0
- package/src/lib/components/modal/Modal.component.tsx +2 -2
- package/src/lib/components/navbar/Navbar.component.tsx +2 -2
- package/src/lib/components/scrollbarwrapper/ScrollbarWrapper.component.tsx +0 -1
- package/src/lib/components/searchinput/SearchInput.component.tsx +0 -1
- package/src/lib/components/searchinput/SearchInput.test.tsx +3 -7
- package/src/lib/components/selectv2/Selectv2.component.tsx +24 -14
- package/src/lib/components/selectv2/selectv2.test.tsx +62 -57
- package/src/lib/components/sidebar/Sidebar.component.tsx +1 -1
- package/src/lib/components/statuswrapper/Statuswrapper.component.tsx +0 -1
- package/src/lib/components/steppers/Stepper.component.tsx +10 -8
- package/src/lib/components/tablev2/Search.tsx +2 -2
- package/src/lib/components/tablev2/SingleSelectableContent.tsx +2 -2
- package/src/lib/components/tablev2/TableCommon.tsx +1 -1
- package/src/lib/components/tablev2/TableSync.test.tsx +28 -0
- package/src/lib/components/tablev2/TableSync.tsx +36 -0
- package/src/lib/components/tablev2/Tablev2.component.tsx +11 -9
- package/src/lib/components/tablev2/Tablev2.test.tsx +36 -37
- package/src/lib/components/tabsv2/ScrollButton.tsx +2 -2
- package/src/lib/components/tabsv2/Tabsv2.component.tsx +6 -6
- package/src/lib/components/text/Text.component.tsx +4 -5
- package/src/lib/components/textarea/TextArea.component.tsx +3 -2
- package/src/lib/components/textbadge/TextBadge.component.tsx +0 -1
- package/src/lib/components/toast/Toast.component.tsx +1 -1
- package/src/lib/components/toast/ToastProvider.tsx +17 -7
- package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +5 -7
- package/src/lib/components/vegachartv2/VegaChartV2.component.tsx +2 -2
- package/src/lib/icons/branding.tsx +0 -2
- package/src/lib/icons/scality-loading.tsx +0 -2
- package/src/lib/index.ts +1 -0
- package/src/lib/next.ts +6 -0
- package/src/lib/style/theme.ts +53 -1
- package/stories/BarChart/barchart.stories.tsx +822 -0
- package/stories/areachart.stories.tsx +0 -1
- package/stories/format.mdx +4 -2
- package/stories/linetimeseriechart.stories.tsx +485 -0
- package/stories/tablev2.stories.tsx +41 -0
- package/tsconfig.json +5 -2
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Bar,
|
|
4
|
+
BarChart,
|
|
5
|
+
CartesianGrid,
|
|
6
|
+
ReferenceLine,
|
|
7
|
+
ResponsiveContainer,
|
|
8
|
+
Tooltip,
|
|
9
|
+
TooltipContentProps,
|
|
10
|
+
XAxis,
|
|
11
|
+
YAxis,
|
|
12
|
+
} from 'recharts';
|
|
13
|
+
import styled, { useTheme } from 'styled-components';
|
|
14
|
+
import { spacing, Stack, Wrap } from '../../spacing';
|
|
15
|
+
import { chartColors, ChartColors, fontSize } from '../../style/theme';
|
|
16
|
+
import { Box } from '../box/Box';
|
|
17
|
+
import { ConstrainedText } from '../constrainedtext/Constrainedtext.component';
|
|
18
|
+
import { IconHelp } from '../iconhelper/IconHelper';
|
|
19
|
+
import { Loader } from '../loader/Loader.component';
|
|
20
|
+
import { Text } from '../text/Text.component';
|
|
21
|
+
import { renderTooltipContent, UnitRange, useChartData } from './utils';
|
|
22
|
+
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
23
|
+
|
|
24
|
+
const CHART_CONSTANTS = {
|
|
25
|
+
TICK_WIDTH_OFFSET: 5,
|
|
26
|
+
BAR_SIZE: 12,
|
|
27
|
+
MIN_POINT_SIZE: 1,
|
|
28
|
+
DEFAULT_HEIGHT: 200,
|
|
29
|
+
CHART_MARGIN: {
|
|
30
|
+
left: 0,
|
|
31
|
+
right: 0,
|
|
32
|
+
top: 0,
|
|
33
|
+
bottom: 0,
|
|
34
|
+
},
|
|
35
|
+
} as const;
|
|
36
|
+
|
|
37
|
+
/* ---------------------------------- TYPE ---------------------------------- */
|
|
38
|
+
|
|
39
|
+
export type TimeType = {
|
|
40
|
+
type: 'time';
|
|
41
|
+
timeRange: {
|
|
42
|
+
startDate: Date;
|
|
43
|
+
endDate: Date;
|
|
44
|
+
interval: number;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type Point = {
|
|
48
|
+
key: string | number;
|
|
49
|
+
values: { label: string; value: number }[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type BarchartBars = readonly {
|
|
53
|
+
readonly label: string;
|
|
54
|
+
/**
|
|
55
|
+
* When using a time type, the data should be an array of [Date, value]
|
|
56
|
+
* so use Date instead of timestamp for transformation data in format fn
|
|
57
|
+
*/
|
|
58
|
+
readonly data: readonly (readonly [string | Date, number | string])[];
|
|
59
|
+
}[];
|
|
60
|
+
|
|
61
|
+
export type BarchartTooltipFn<T extends BarchartBars> = (currentPoint: {
|
|
62
|
+
category: string | number;
|
|
63
|
+
values: { label: T[number]['label']; value: number; isHovered: boolean }[];
|
|
64
|
+
}) => React.ReactNode;
|
|
65
|
+
|
|
66
|
+
export type BarchartSortFn<T extends BarchartBars> = (
|
|
67
|
+
pointA: Record<T[number]['label'], number> & { category: string | number },
|
|
68
|
+
pointB: Record<T[number]['label'], number> & { category: string | number },
|
|
69
|
+
) => 1 | -1 | 0;
|
|
70
|
+
|
|
71
|
+
export type BarchartProps<T extends BarchartBars> = {
|
|
72
|
+
type: 'category' | TimeType;
|
|
73
|
+
bars: T;
|
|
74
|
+
tooltip?: BarchartTooltipFn<T>;
|
|
75
|
+
defaultSort?: BarchartSortFn<T>;
|
|
76
|
+
unitRange?: UnitRange;
|
|
77
|
+
helpTooltip?: string;
|
|
78
|
+
stacked?: boolean;
|
|
79
|
+
title?: string;
|
|
80
|
+
secondaryTitle?: string;
|
|
81
|
+
rightTitle?: React.ReactNode;
|
|
82
|
+
height?: number;
|
|
83
|
+
isLoading?: boolean;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
interface CustomTickProps {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
payload: {
|
|
90
|
+
value: string | number;
|
|
91
|
+
};
|
|
92
|
+
visibleTicksCount: number;
|
|
93
|
+
width: number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* ---------------------------------- COMPONENTS ---------------------------------- */
|
|
97
|
+
|
|
98
|
+
const CustomTick = ({
|
|
99
|
+
x,
|
|
100
|
+
y,
|
|
101
|
+
payload,
|
|
102
|
+
visibleTicksCount,
|
|
103
|
+
width,
|
|
104
|
+
}: CustomTickProps) => {
|
|
105
|
+
const theme = useTheme();
|
|
106
|
+
const tickWidth =
|
|
107
|
+
width / visibleTicksCount - CHART_CONSTANTS.TICK_WIDTH_OFFSET;
|
|
108
|
+
const centerX = x - tickWidth / 2;
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<foreignObject
|
|
112
|
+
x={centerX}
|
|
113
|
+
y={y}
|
|
114
|
+
width={tickWidth}
|
|
115
|
+
color={theme.textSecondary}
|
|
116
|
+
overflow="visible"
|
|
117
|
+
>
|
|
118
|
+
<ConstrainedText
|
|
119
|
+
text={
|
|
120
|
+
<Text variant="Smaller" color="textSecondary">
|
|
121
|
+
{String(payload.value)}
|
|
122
|
+
</Text>
|
|
123
|
+
}
|
|
124
|
+
centered
|
|
125
|
+
tooltipStyle={{
|
|
126
|
+
backgroundColor: theme.backgroundLevel1,
|
|
127
|
+
padding: spacing.r10,
|
|
128
|
+
borderRadius: spacing.r8,
|
|
129
|
+
border: `1px solid ${theme.border}`,
|
|
130
|
+
position: 'absolute',
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
</foreignObject>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const StyledResponsiveContainer = styled(ResponsiveContainer)`
|
|
138
|
+
// Avoid tooltip over constrained text to be cut off
|
|
139
|
+
& .recharts-surface {
|
|
140
|
+
overflow: visible;
|
|
141
|
+
}
|
|
142
|
+
`;
|
|
143
|
+
|
|
144
|
+
const ChartHeader = ({
|
|
145
|
+
title,
|
|
146
|
+
secondaryTitle,
|
|
147
|
+
helpTooltip,
|
|
148
|
+
rightTitle,
|
|
149
|
+
}: {
|
|
150
|
+
title?: string;
|
|
151
|
+
secondaryTitle?: string;
|
|
152
|
+
helpTooltip?: string;
|
|
153
|
+
rightTitle?: React.ReactNode;
|
|
154
|
+
}) => {
|
|
155
|
+
return (
|
|
156
|
+
<Wrap>
|
|
157
|
+
<Stack gap="r4">
|
|
158
|
+
<Text variant="ChartTitle">{title}</Text>
|
|
159
|
+
{helpTooltip && (
|
|
160
|
+
<IconHelp tooltipMessage={helpTooltip} title={helpTooltip} />
|
|
161
|
+
)}
|
|
162
|
+
|
|
163
|
+
{secondaryTitle && (
|
|
164
|
+
<Text
|
|
165
|
+
color="textSecondary"
|
|
166
|
+
style={{
|
|
167
|
+
marginLeft: spacing.r8,
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
{secondaryTitle}
|
|
171
|
+
</Text>
|
|
172
|
+
)}
|
|
173
|
+
</Stack>
|
|
174
|
+
|
|
175
|
+
{rightTitle && <Text>{rightTitle}</Text>}
|
|
176
|
+
</Wrap>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const Loading = ({ height }: { height: number }) => {
|
|
181
|
+
return (
|
|
182
|
+
<Box
|
|
183
|
+
height={height}
|
|
184
|
+
style={{
|
|
185
|
+
alignItems: 'center',
|
|
186
|
+
justifyContent: 'center',
|
|
187
|
+
display: 'flex',
|
|
188
|
+
}}
|
|
189
|
+
>
|
|
190
|
+
<Loader size="larger" children={<Text>Loading Chart Data...</Text>} />
|
|
191
|
+
</Box>
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/* ---------------------------------- MAIN COMPONENT ---------------------------------- */
|
|
196
|
+
|
|
197
|
+
export const Barchart = <T extends BarchartBars>(props: BarchartProps<T>) => {
|
|
198
|
+
const theme = useTheme();
|
|
199
|
+
const { getColor } = useChartLegend();
|
|
200
|
+
const [hoveredValue, setHoveredValue] = useState<string | undefined>();
|
|
201
|
+
|
|
202
|
+
const {
|
|
203
|
+
height = CHART_CONSTANTS.DEFAULT_HEIGHT,
|
|
204
|
+
bars,
|
|
205
|
+
type = 'category',
|
|
206
|
+
unitRange,
|
|
207
|
+
stacked,
|
|
208
|
+
defaultSort,
|
|
209
|
+
tooltip,
|
|
210
|
+
title,
|
|
211
|
+
secondaryTitle,
|
|
212
|
+
helpTooltip,
|
|
213
|
+
rightTitle,
|
|
214
|
+
isLoading,
|
|
215
|
+
} = props;
|
|
216
|
+
|
|
217
|
+
// Create colorSet from ChartLegendWrapper
|
|
218
|
+
const colorSet = bars.reduce(
|
|
219
|
+
(acc, bar) => {
|
|
220
|
+
const color = getColor(bar.label);
|
|
221
|
+
if (color) {
|
|
222
|
+
acc[bar.label] = color;
|
|
223
|
+
}
|
|
224
|
+
return acc;
|
|
225
|
+
},
|
|
226
|
+
{} as Record<string, ChartColors | string>,
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
const { rechartsBars, unitLabel, roundReferenceValue, rechartsData } =
|
|
230
|
+
useChartData(bars, type, colorSet, stacked, defaultSort, unitRange);
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<Stack direction="vertical" gap="r8">
|
|
234
|
+
<ChartHeader
|
|
235
|
+
title={title}
|
|
236
|
+
secondaryTitle={secondaryTitle}
|
|
237
|
+
helpTooltip={helpTooltip}
|
|
238
|
+
rightTitle={rightTitle}
|
|
239
|
+
/>
|
|
240
|
+
{isLoading ? (
|
|
241
|
+
<Loading height={height} />
|
|
242
|
+
) : (
|
|
243
|
+
<StyledResponsiveContainer width="100%" height={height}>
|
|
244
|
+
<BarChart
|
|
245
|
+
data={rechartsData}
|
|
246
|
+
accessibilityLayer
|
|
247
|
+
barSize={CHART_CONSTANTS.BAR_SIZE}
|
|
248
|
+
height={height}
|
|
249
|
+
margin={CHART_CONSTANTS.CHART_MARGIN}
|
|
250
|
+
>
|
|
251
|
+
<CartesianGrid
|
|
252
|
+
vertical={false}
|
|
253
|
+
horizontal={false}
|
|
254
|
+
fill={theme.backgroundLevel1}
|
|
255
|
+
/>
|
|
256
|
+
{rechartsBars.map((bar) => {
|
|
257
|
+
const { fill, dataKey, stackId } = bar;
|
|
258
|
+
return (
|
|
259
|
+
<Bar
|
|
260
|
+
key={dataKey}
|
|
261
|
+
dataKey={dataKey}
|
|
262
|
+
fill={chartColors[fill] || fill}
|
|
263
|
+
minPointSize={CHART_CONSTANTS.MIN_POINT_SIZE}
|
|
264
|
+
stackId={stackId}
|
|
265
|
+
onMouseOver={() => setHoveredValue(dataKey)}
|
|
266
|
+
onMouseLeave={() => setHoveredValue(undefined)}
|
|
267
|
+
/>
|
|
268
|
+
);
|
|
269
|
+
})}
|
|
270
|
+
|
|
271
|
+
<YAxis
|
|
272
|
+
tickCount={1}
|
|
273
|
+
unit={` ${unitLabel}`}
|
|
274
|
+
domain={[0, roundReferenceValue]}
|
|
275
|
+
tickFormatter={
|
|
276
|
+
(value) =>
|
|
277
|
+
new Intl.NumberFormat('fr-FR').format(value.toFixed(0)) // Add a space as thousand separator
|
|
278
|
+
}
|
|
279
|
+
axisLine={false}
|
|
280
|
+
tick={{
|
|
281
|
+
fill: theme.textSecondary,
|
|
282
|
+
fontSize: fontSize.smaller,
|
|
283
|
+
}}
|
|
284
|
+
tickLine={false}
|
|
285
|
+
label={{
|
|
286
|
+
fill: theme.textSecondary,
|
|
287
|
+
}}
|
|
288
|
+
orientation="right"
|
|
289
|
+
/>
|
|
290
|
+
|
|
291
|
+
<ReferenceLine
|
|
292
|
+
y={roundReferenceValue}
|
|
293
|
+
fill={theme.border}
|
|
294
|
+
strokeWidth={0.5} // Reduce stroke width to make it less visible
|
|
295
|
+
/>
|
|
296
|
+
<XAxis
|
|
297
|
+
dataKey="category"
|
|
298
|
+
tick={(props) => <CustomTick {...props} />}
|
|
299
|
+
type="category"
|
|
300
|
+
interval={0}
|
|
301
|
+
allowDataOverflow={true}
|
|
302
|
+
tickLine={{
|
|
303
|
+
stroke: theme.textSecondary,
|
|
304
|
+
}}
|
|
305
|
+
axisLine={{
|
|
306
|
+
stroke: theme.textSecondary,
|
|
307
|
+
}}
|
|
308
|
+
/>
|
|
309
|
+
|
|
310
|
+
<Tooltip
|
|
311
|
+
content={(props: TooltipContentProps<number, string>) =>
|
|
312
|
+
renderTooltipContent(props, tooltip, hoveredValue)
|
|
313
|
+
}
|
|
314
|
+
cursor={false}
|
|
315
|
+
/>
|
|
316
|
+
</BarChart>
|
|
317
|
+
</StyledResponsiveContainer>
|
|
318
|
+
)}
|
|
319
|
+
</Stack>
|
|
320
|
+
);
|
|
321
|
+
};
|