Skip to content

Commit

Permalink
✨ add x-axis label to tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Mar 5, 2025
1 parent d26fa4c commit 93c83ef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,9 @@ export class LineChart
{ unit, shortUnit } = formatColumn,
{ isRelativeMode, startTime } = this.manager

const title = formattedTime
const titleAnnotation = this.xAxis.label ? `(${this.xAxis.label})` : ""

const columns = [formatColumn]
if (hasColorScale) columns.push(colorColumn)

Expand Down Expand Up @@ -706,7 +709,8 @@ export class LineChart
offsetXDirection="left"
offsetX={20}
offsetY={-16}
title={formattedTime}
title={title}
titleAnnotation={titleAnnotation}
subtitle={subtitle}
subtitleFormat={subtitleFormat}
footer={footer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,9 @@ export class StackedAreaChart extends AbstractStackedChart {
formattedTime = formatColumn.formatTime(bottomSeriesPoint.position),
{ unit, shortUnit } = formatColumn

const title = formattedTime
const titleAnnotation = this.xAxis.label ? `(${this.xAxis.label})` : ""

const lastStackedPoint = last(series)!.points[hoveredPointIndex]
if (!lastStackedPoint) return undefined
const totalValue = lastStackedPoint.value + lastStackedPoint.valueOffset
Expand All @@ -594,7 +597,8 @@ export class StackedAreaChart extends AbstractStackedChart {
offsetX={20}
offsetXDirection="left"
style={{ maxWidth: "50%" }}
title={formattedTime}
title={title}
titleAnnotation={titleAnnotation}
subtitle={unit !== shortUnit ? unit : undefined}
subtitleFormat="unit"
footer={footer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ export class StackedBarChart
hoverTime = hoveredTick.time
} else return

const title = formatColumn.formatTime(hoverTime)
const titleAnnotation = this.xAxis.label ? `(${this.xAxis.label})` : ""

const { unit, shortUnit } = formatColumn

const totalValue = sum(
Expand Down Expand Up @@ -393,7 +396,8 @@ export class StackedBarChart
style={{ maxWidth: "500px" }}
offsetX={20}
offsetY={-16}
title={formatColumn.formatTime(hoverTime)}
title={title}
titleAnnotation={titleAnnotation}
subtitle={unit !== shortUnit ? unit : undefined}
subtitleFormat="unit"
footer={footer}
Expand Down

0 comments on commit 93c83ef

Please sign in to comment.