Skip to content

Commit 06a482b

Browse files
committed
fix: chart legend tooltip values may not have unit
1 parent 4735698 commit 06a482b

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

plugins/plugin-codeflare/src/components/Chart.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ class MyTooltipLabel extends React.PureComponent<ChartLabelProps> {
4646
}
4747
}
4848

49-
class MyTooltipLegendLabel extends React.PureComponent<ChartLegendLabelProps> {
49+
class MyTooltipLegendLabel extends React.PureComponent<
50+
ChartLegendLabelProps & { styleOverride?: ChartLegendLabelProps["style"] }
51+
> {
5052
public render() {
5153
const dx =
5254
typeof this.props.dx === "number"
@@ -58,7 +60,7 @@ class MyTooltipLegendLabel extends React.PureComponent<ChartLegendLabelProps> {
5860
<ChartLegendTooltipLabel
5961
{...this.props}
6062
dx={((dx || 0) * BaseChart.legendLabelStyle.fontSize) / 14}
61-
style={BaseChart.legendLabelStyle}
63+
style={this.props.styleOverride || BaseChart.legendLabelStyle}
6264
legendLabelComponent={<MyTooltipLabel />}
6365
/>
6466
)
@@ -71,7 +73,7 @@ class MyTooltipContent extends React.PureComponent<ChartLegendTooltipContentProp
7173
<ChartLegendTooltipContent
7274
{...this.props}
7375
labelComponent={<MyTooltipLegendLabel />}
74-
titleComponent={<ChartLabel style={BaseChart.legendTitleStyle} />}
76+
titleComponent={<MyTooltipLegendLabel styleOverride={BaseChart.legendTitleStyle} />}
7577
/>
7678
)
7779
}
@@ -353,10 +355,10 @@ export default class BaseChart extends React.PureComponent<Props> {
353355

354356
/** @return the `legendData` model for `<ChartLegendTooltip/>` */
355357
private getLegendData(chart: BaseChartProps): ChartLegendTooltipProps["legendData"] {
356-
return chart.series.map(({ data, stroke, fill }) => ({
358+
return chart.series.map(({ data, stroke, fill, impl }) => ({
357359
childName: data[0].name,
358360
name: data[0].name?.replace(/^\S+\s*/, ""),
359-
symbol: { fill: fill || stroke },
361+
symbol: { fill: fill || stroke, type: impl === "ChartDashedLine" ? "dash" : undefined },
360362
}))
361363
}
362364

@@ -389,6 +391,8 @@ export default class BaseChart extends React.PureComponent<Props> {
389391
domain={chart.domain}
390392
containerComponent={
391393
<CursorVoronoiContainer
394+
mouseFollowTooltips
395+
voronoiDimension="x"
392396
labels={this.getTooltipLabels.bind(this, formatMap)}
393397
labelComponent={
394398
<ChartLegendTooltip
@@ -399,8 +403,6 @@ export default class BaseChart extends React.PureComponent<Props> {
399403
title={(datum: any) => `${new Date(datum.x + this.props.timeRange.min).toLocaleString()}`}
400404
/>
401405
}
402-
mouseFollowTooltips
403-
voronoiPadding={20}
404406
/>
405407
}
406408
>

plugins/plugin-codeflare/src/components/GPUChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ export default class GPUChart extends React.PureComponent<Props, State> {
4343
private static charts(props: Props): BaseChartProps[] {
4444
return Object.entries(props.logs).map(([node, lines]) => {
4545
const d1 = lines.map((line) => ({
46-
name: BaseChart.nodeNameLabel(node) + " GPU",
46+
name: BaseChart.nodeNameLabel(node) + " GPU Utilization",
4747
x: line.timestamp - props.timeRange.min,
4848
y: line.utilizationGPU,
4949
}))
5050

5151
const d2 = lines.map((line) => ({
52-
name: BaseChart.nodeNameLabel(node) + " Memory",
52+
name: BaseChart.nodeNameLabel(node) + " GPU Memory",
5353
x: line.timestamp - props.timeRange.min,
5454
y: line.utilizationMemory,
5555
}))

0 commit comments

Comments
 (0)