Skip to content

CRT-1071 Fix waterfall total/subtotal tooltip renderers#6489

Open
olegat wants to merge 3 commits intob13.2.0from
CRT-1071/waterfall_total_subtotal_externalDatum_tooltip_renderer
Open

CRT-1071 Fix waterfall total/subtotal tooltip renderers#6489
olegat wants to merge 3 commits intob13.2.0from
CRT-1071/waterfall_total_subtotal_externalDatum_tooltip_renderer

Conversation

@olegat
Copy link
Copy Markdown
Contributor

@olegat olegat commented Mar 23, 2026

olegat added 3 commits March 23, 2026 12:01
…erfall

The `ag-charts-types` library defines the `params.datum` value (of
`tooltip.renderer`) as a type that matches the `TDatum` of
`AgChartsOptions`. Total and Subtotal do have such a TDatum in the raw into
data, therefore we need to calculate one on-the-fly.

Examples tested:
-   https://ag-grid.com/charts/archive/13.2.0/gallery/horizontal-waterfall/
-   https://ag-grid.com/charts/archive/13.2.0/gallery/customised-waterfall/
@olegat olegat marked this pull request as ready for review March 23, 2026 12:10
@olegat olegat requested a review from alantreadway as a code owner March 23, 2026 12:10
Comment on lines +208 to 213
...total.toJson(),
[xKey]: total.axisLabel,
externalDatum: { ...data?.data.at(total.index) },
});
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [P1] Tooltip datum for totals/subtotals can carry incorrect or missing x-value context

For synthetic total/subtotal nodes, externalDatum is copied from data.at(total.index) and later only yKey is overridden. The displayed bar label comes from total.axisLabel, but that label is not written into externalDatum. As a result, custom tooltip renderers reading params.datum[xKey] may see a stale category (copied from another datum) or no category at all (e.g. when total.index points past the data array for end totals). This leaves total/subtotal tooltip renderer data inconsistent with the rendered bar.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Indeed, the tooltip.renderer does indeed provide datum[xKey]: Oct 31, which is incorrect, this should be datum[xKey]: 'Monthly Net'.

Screenshot 2026-03-23 at 12 22 52

We could update the code to set data[xKey] to 'Monthly Net'. But if we do that, then this will create another problem where now we're violating the declared type of data[xKey], which is meant to be a Date not a string.

The developer could in theory do something like this in their tooltip renderer and run into the exact same problem:

tooltip.render: (params) => {
  const xKey: string = params.xKey;
  const date: Date = params.datum[xKey];
  const timeString: string = date.toTimeString(); // error - .toTimeString() does not exist on string types
}

@github-actions
Copy link
Copy Markdown
Contributor

❌ Codex review complete; 1 issue found (P0: 0 | P1: 1 | P2: 0 | P3: 0)

View full review

CRT-1071 Fix waterfall total/subtotal tooltip renderers

PR: #6489
Author: olegat | Base: b13.2.0 ← Head: CRT-1071/waterfall_total_subtotal_externalDatum_tooltip_renderer
Diff: 1 file changed, +36 -4

Summary

This PR introduces a dedicated externalDatum payload for waterfall total/subtotal synthetic nodes so callbacks receive user-facing data, and it populates yKey display values for those synthetic tooltip datums. It also routes tooltip datum lookup through externalDatum for total/subtotal items.

Findings

P0: 0 | P1: 1 | P2: 0 | P3: 0

1 inline comments posted.

Verdict

Assessment: incorrect
Confidence: 0.87

The patch improves total/subtotal tooltip handling, but it still produces inconsistent callback datum shape for x-axis context on synthetic bars, which can break or mislead custom tooltip renderers.

Required Actions:

  • Construct externalDatum for total/subtotal nodes with the rendered x-axis label ([xKey]: total.axisLabel) in addition to the computed y value, rather than relying on data.at(total.index) for x-context.

@github-actions
Copy link
Copy Markdown
Contributor

Snapshots automatically updated, please review before merge:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants