@scality/core-ui 0.170.0 → 0.172.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/uuid.js +11 -0
- package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
- package/dist/components/barchartv2/Barchart.component.js +4 -4
- package/dist/components/barchartv2/BarchartTooltip.d.ts +11 -0
- package/dist/components/barchartv2/BarchartTooltip.d.ts.map +1 -0
- package/dist/components/barchartv2/BarchartTooltip.js +27 -0
- package/dist/components/chartlegend/ChartLegend.d.ts +3 -1
- package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegend.js +2 -2
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts +3 -1
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -1
- package/dist/components/chartlegend/ChartLegendWrapper.js +43 -9
- package/dist/components/charttooltip/ChartTooltip.d.ts +13 -0
- package/dist/components/charttooltip/ChartTooltip.d.ts.map +1 -0
- package/dist/components/charttooltip/ChartTooltip.js +49 -0
- package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts +4 -0
- package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts.map +1 -1
- package/dist/components/globalhealthbar/GlobalHealthBar.component.js +4 -0
- package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts +10 -0
- package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts.map +1 -0
- package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.js +78 -0
- package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts +18 -0
- package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts.map +1 -0
- package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.js +95 -0
- package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts +7 -0
- package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts.map +1 -0
- package/dist/components/globalhealthbar/components/HealthBarXAxis.js +25 -0
- package/dist/components/globalhealthbar/healthBarUtils.d.ts +77 -0
- package/dist/components/globalhealthbar/healthBarUtils.d.ts.map +1 -0
- package/dist/components/globalhealthbar/healthBarUtils.js +196 -0
- package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts +2 -0
- package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts.map +1 -0
- package/dist/components/globalhealthbar/healthBarUtils.spec.js +391 -0
- package/dist/components/globalhealthbar/useHealthBarData.d.ts +18 -0
- package/dist/components/globalhealthbar/useHealthBarData.d.ts.map +1 -0
- package/dist/components/globalhealthbar/useHealthBarData.js +46 -0
- package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts +2 -0
- package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts.map +1 -0
- package/dist/components/globalhealthbar/useHealthBarData.spec.js +207 -0
- package/dist/components/icon/Icon.component.d.ts +2 -0
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +2 -0
- package/dist/components/linetemporalchart/ChartUtil.d.ts.map +1 -1
- package/dist/components/linetemporalchart/ChartUtil.js +12 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +8 -5
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +95 -100
- package/dist/components/sparkline/sparkline.component.d.ts +16 -0
- package/dist/components/sparkline/sparkline.component.d.ts.map +1 -0
- package/dist/components/sparkline/sparkline.component.js +20 -0
- package/dist/components/text/Text.component.d.ts +2 -1
- package/dist/components/text/Text.component.d.ts.map +1 -1
- package/dist/components/text/Text.component.js +6 -1
- package/dist/next.d.ts +4 -2
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +4 -2
- package/package.json +4 -2
- package/src/lib/components/barchartv2/Barchart.component.tsx +5 -4
- package/src/lib/components/barchartv2/{ChartTooltip.test.tsx → BarchartTooltip.test.tsx} +35 -12
- package/src/lib/components/barchartv2/BarchartTooltip.tsx +89 -0
- package/src/lib/components/chartlegend/ChartLegend.tsx +4 -2
- package/src/lib/components/chartlegend/ChartLegendWrapper.test.tsx +197 -0
- package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +65 -9
- package/src/lib/components/charttooltip/ChartTooltip.tsx +83 -0
- package/src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx +4 -1
- package/src/lib/components/globalhealthbar/GlobalHealthBarRecharts.component.tsx +203 -0
- package/src/lib/components/globalhealthbar/components/GlobalHealthBarTooltip.tsx +173 -0
- package/src/lib/components/globalhealthbar/components/HealthBarXAxis.tsx +94 -0
- package/src/lib/components/globalhealthbar/healthBarUtils.spec.ts +701 -0
- package/src/lib/components/globalhealthbar/healthBarUtils.ts +311 -0
- package/src/lib/components/globalhealthbar/useHealthBarData.spec.tsx +487 -0
- package/src/lib/components/globalhealthbar/useHealthBarData.ts +74 -0
- package/src/lib/components/icon/Icon.component.tsx +2 -0
- package/src/lib/components/linetemporalchart/ChartUtil.ts +26 -0
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +272 -229
- package/src/lib/components/sparkline/sparkline.component.tsx +54 -0
- package/src/lib/components/text/Text.component.tsx +15 -2
- package/src/lib/next.ts +12 -2
- package/stories/BarChart/barchart.stories.tsx +7 -1
- package/stories/GlobalHealthBar/globalhealthbarRecharts.stories.tsx +145 -0
- package/stories/GlobalHealthBar/globalheathbarrecharts.guideline.mdx +5 -0
- package/stories/InlineInput/InlineInput.stories.tsx +7 -1
- package/stories/globalhealthbar.stories.tsx +25 -5
- package/stories/linetimeseriechart.stories.tsx +217 -1
- package/stories/sparkline.stories.tsx +168 -0
- package/dist/components/barchartv2/ChartTooltip.d.ts +0 -14
- package/dist/components/barchartv2/ChartTooltip.d.ts.map +0 -1
- package/dist/components/barchartv2/ChartTooltip.js +0 -41
- package/src/lib/components/barchartv2/ChartTooltip.tsx +0 -106
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { XAxis } from 'recharts';
|
|
2
|
+
import { useTheme } from 'styled-components';
|
|
3
|
+
import { fontSize } from '../../../style/theme';
|
|
4
|
+
import {
|
|
5
|
+
getTicks,
|
|
6
|
+
calculateLabelVisibility,
|
|
7
|
+
TIME_CONSTANTS,
|
|
8
|
+
getEdgeMargin,
|
|
9
|
+
} from '../healthBarUtils';
|
|
10
|
+
import { FormattedDateTime } from '../../date/FormattedDateTime';
|
|
11
|
+
|
|
12
|
+
interface HealthBarXAxisProps {
|
|
13
|
+
startTimestamp: number;
|
|
14
|
+
endTimestamp: number;
|
|
15
|
+
}
|
|
16
|
+
const CustomTick = ({
|
|
17
|
+
tickProps,
|
|
18
|
+
startTimestamp,
|
|
19
|
+
endTimestamp,
|
|
20
|
+
}: {
|
|
21
|
+
tickProps: any;
|
|
22
|
+
startTimestamp: number;
|
|
23
|
+
endTimestamp: number;
|
|
24
|
+
}) => {
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
const { y, payload, width, index, visibleTicksCount } = tickProps;
|
|
27
|
+
const span = endTimestamp - startTimestamp;
|
|
28
|
+
const is7DaySpan = span === 7 * TIME_CONSTANTS.ONE_DAY;
|
|
29
|
+
const isDaySpan = span === TIME_CONSTANTS.ONE_DAY;
|
|
30
|
+
|
|
31
|
+
const shouldShowLabel = calculateLabelVisibility(
|
|
32
|
+
width,
|
|
33
|
+
visibleTicksCount,
|
|
34
|
+
span,
|
|
35
|
+
index,
|
|
36
|
+
endTimestamp,
|
|
37
|
+
);
|
|
38
|
+
const edgeMargin = getEdgeMargin(index, visibleTicksCount, isDaySpan);
|
|
39
|
+
return (
|
|
40
|
+
// use coordinate to center the text
|
|
41
|
+
shouldShowLabel && (
|
|
42
|
+
<g transform={`translate(${payload.coordinate},${y})`}>
|
|
43
|
+
<text
|
|
44
|
+
textAnchor="middle"
|
|
45
|
+
dy={10}
|
|
46
|
+
dx={edgeMargin}
|
|
47
|
+
fontSize={fontSize.smaller}
|
|
48
|
+
fill={theme.textSecondary}
|
|
49
|
+
>
|
|
50
|
+
{is7DaySpan || isDaySpan ? (
|
|
51
|
+
<FormattedDateTime
|
|
52
|
+
format="day-month-abbreviated-hour-minute"
|
|
53
|
+
value={new Date(payload.value)}
|
|
54
|
+
/>
|
|
55
|
+
) : (
|
|
56
|
+
<FormattedDateTime format="time" value={new Date(payload.value)} />
|
|
57
|
+
)}
|
|
58
|
+
</text>
|
|
59
|
+
</g>
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const HealthBarXAxis = ({
|
|
65
|
+
startTimestamp,
|
|
66
|
+
endTimestamp,
|
|
67
|
+
}: HealthBarXAxisProps) => {
|
|
68
|
+
const theme = useTheme();
|
|
69
|
+
const ticks = getTicks(startTimestamp, endTimestamp);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<XAxis
|
|
73
|
+
allowDataOverflow={true}
|
|
74
|
+
dataKey="start"
|
|
75
|
+
type="number"
|
|
76
|
+
domain={[startTimestamp, endTimestamp]}
|
|
77
|
+
tickSize={5}
|
|
78
|
+
minTickGap={10}
|
|
79
|
+
interval={0}
|
|
80
|
+
tick={(props: any) => {
|
|
81
|
+
return (
|
|
82
|
+
<CustomTick
|
|
83
|
+
tickProps={props}
|
|
84
|
+
startTimestamp={startTimestamp}
|
|
85
|
+
endTimestamp={endTimestamp}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}}
|
|
89
|
+
ticks={ticks}
|
|
90
|
+
tickLine={{ stroke: theme.textSecondary }}
|
|
91
|
+
axisLine={false}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
};
|