Skip to content

Commit 9e328cc

Browse files
committed
add the data points onto line chart in metric summary with tooltips
Signed-off-by: dalthecow <[email protected]>
1 parent b1b1b78 commit 9e328cc

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/ui/lib/components/Charts/MetricLine/MetricLine.component.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { useTheme } from '@mui/material';
1+
import { Typography, useTheme } from '@mui/material';
22
import { ResponsiveLine } from '@nivo/line';
3+
import { BasicTooltip } from '@nivo/tooltip';
34
import React, { FC } from 'react';
45

56
import { useColor } from '@/lib/hooks/useColor';
7+
import { formatNumber } from '@/lib/utils/helpers';
68

79
import { MetricLineProps } from '.';
810
import CustomAxes from './components/CustomAxes';
@@ -50,10 +52,33 @@ export const Component: FC<MetricLineProps> = ({
5052
};
5153
}
5254

55+
const getUnits = (seriesId: string) => {
56+
switch (seriesId) {
57+
case 'timePerRequest':
58+
return 's';
59+
case 'throughput':
60+
return 'tok/s';
61+
default:
62+
return 'ms';
63+
}
64+
};
65+
5366
return (
5467
<ResponsiveLine
5568
curve="monotoneX"
5669
data={data}
70+
tooltip={(point) => (
71+
<BasicTooltip
72+
id={
73+
<Typography variant="body2">
74+
{`${formatNumber(Number(point.point.data.x))} rps, ${formatNumber(Number(point.point.data.y))} ${getUnits(`${point.point.serieId}`)}`}
75+
</Typography>
76+
}
77+
color={point.point.color}
78+
enableChip={true}
79+
/>
80+
)}
81+
pointSize={10}
5782
colors={[selectedColor]}
5883
margin={{ top: 20, right: 10, bottom: 20, left: 35.5 }}
5984
xScale={{ type: 'linear', min: minX }}
@@ -92,7 +117,6 @@ export const Component: FC<MetricLineProps> = ({
92117
}}
93118
enableGridX={false}
94119
enableGridY={false}
95-
pointSize={0}
96120
useMesh={true}
97121
layers={[
98122
CustomAxes,
@@ -115,6 +139,9 @@ export const Component: FC<MetricLineProps> = ({
115139
),
116140
'axes',
117141
'lines',
142+
'points',
143+
'markers',
144+
'mesh',
118145
]}
119146
theme={lineTheme}
120147
/>

src/ui/lib/components/MetricsSummary/MetricsSummary.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const Component = () => {
102102
return (
103103
<>
104104
<BlockHeader label="Metrics Summary" />
105-
<MetricsSummaryContainer container>
105+
<MetricsSummaryContainer sx={{ overflow: 'visible' }} container>
106106
<HeaderLeftCell item xs={9}>
107107
<Box display="flex" flexDirection="row" justifyContent="space-between">
108108
<Typography variant="h6" color="surface.onSurface" mb={2}>

0 commit comments

Comments
 (0)