Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 (stacked area) prevent crash when adjusting timeline while tooltip is visible #4303

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,15 @@ export class StackedAreaChart extends AbstractStackedChart {
const hoveredPointIndex = this.tooltipState.target?.index
if (hoveredPointIndex === undefined) return undefined

const xPoint = series[0].points[hoveredPointIndex]
if (xPoint === undefined) return undefined

return (
// disable pointer events to avoid interfering with enter/leave tracking of areas
<g className="hoverIndicator" style={{ pointerEvents: "none" }}>
{series.map((series) => {
const point = series.points[hoveredPointIndex]
if (point.fake || point.value === 0) return null
if (!point || point.fake || point.value === 0) return null
return (
<circle
key={series.seriesName}
Expand All @@ -536,13 +539,9 @@ export class StackedAreaChart extends AbstractStackedChart {
)
})}
<line
x1={horizontalAxis.place(
series[0].points[hoveredPointIndex].position
)}
x1={horizontalAxis.place(xPoint.position)}
y1={verticalAxis.range[0]}
x2={horizontalAxis.place(
series[0].points[hoveredPointIndex].position
)}
x2={horizontalAxis.place(xPoint.position)}
y2={verticalAxis.range[1]}
stroke="rgba(180,180,180,.4)"
/>
Expand All @@ -566,12 +565,14 @@ export class StackedAreaChart extends AbstractStackedChart {
const { series } = this
const hoveredPointIndex = target.index
const bottomSeriesPoint = series[0].points[hoveredPointIndex]
if (!bottomSeriesPoint) return undefined

const formatColumn = this.yColumns[0], // Assumes same type for all columns.
formattedTime = formatColumn.formatTime(bottomSeriesPoint.position),
{ unit, shortUnit } = formatColumn

const lastStackedPoint = last(series)!.points[hoveredPointIndex]
if (!lastStackedPoint) return undefined
const totalValue = lastStackedPoint.value + lastStackedPoint.valueOffset

const roundingNotice = formatColumn.roundsToSignificantFigures
Expand Down
Loading