Skip to content

Commit

Permalink
chore: More defensive coding in charts (#3148)
Browse files Browse the repository at this point in the history
  • Loading branch information
gethinwebster authored Dec 18, 2024
1 parent 044843b commit e9fab18
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mixed-line-bar-chart/chart-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export default function ChartContainer<T extends ChartDataTypes>({
// TODO: make a uniform verticalMarkerX state to fit all use-cases.
const highlightedX = useMemo(() => {
if (highlightedGroupIndex !== null) {
return barGroups[highlightedGroupIndex].x;
return barGroups[highlightedGroupIndex]?.x;
}
if (verticalMarkerX !== null) {
return verticalMarkerX.label;
Expand Down Expand Up @@ -420,7 +420,7 @@ export default function ChartContainer<T extends ChartDataTypes>({
if (verticalMarkerX !== null) {
verticalLineX = verticalMarkerX.scaledX;
} else if (isGroupNavigation && highlightedGroupIndex !== null) {
const x = xAxisProps.scale.d3Scale(barGroups[highlightedGroupIndex].x as any) ?? null;
const x = xAxisProps.scale.d3Scale(barGroups[highlightedGroupIndex]?.x as any) ?? null;
if (x !== null) {
verticalLineX = xOffset + x;
}
Expand Down

0 comments on commit e9fab18

Please sign in to comment.