Chart Integration
getChartData() turns the current pivot view into dataSource + series for <oge-chart>: one argument per visible row line, one series per column line × measure. Expanding, collapsing, filtering or re-pivoting fires resultChange, so a linked chart follows the grid; a clicked row narrows the chart to that row.
getChartData resultChange toChartSeries selection
expand state cell click selection bar / stacked / line
Expand a region, click a value cell to chart that row only (click a grand-total cell to reset).
Amount by region
| Argument | 2022 | 2023 | 2024 | 2025 |
|---|---|---|---|---|
| Americas | 136,400 | 188,419 | 135,938 | 188,881 |
| Asia | 125,356 | 125,818 | 126,280 | 125,818 |
| Europe | 147,944 | 260,363 | 154,282 | 257,201 |
import { ChangeDetectionStrategy, Component, signal, viewChild } from '@angular/core';
import { OgePivotField, OgePivotGrid } from '@oge-ui/pivot';
import { OgeChart } from '@oge-ui/charts';
import type { OgePivotChartData, OgePivotCellClickEvent } from '@oge-ui/pivot';
@Component({
selector: 'demo-root',
imports: [OgePivotField, OgePivotGrid, OgeChart],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<!-- the pivot does not depend on the charts package: the app binds the two -->
<oge-pivot-grid #pivot [data]="sales"
(resultChange)="refresh()" (cellClick)="select($event)">
<oge-pivot-field dataField="region" area="row" />
<oge-pivot-field dataField="country" area="row" />
<oge-pivot-field dataField="date" caption="Year" area="column" groupInterval="year" />
<oge-pivot-field dataField="amount" caption="Amount" area="data" summaryType="sum" />
</oge-pivot-grid>
<oge-chart [dataSource]="chart().dataSource" [series]="chart().series" style="height: 320px" />
`,
})
export class Demo {
protected readonly sales = [
{ region: 'Europe', country: 'Germany', date: '2025-03-14', amount: 1249 },
{ region: 'Europe', country: 'France', date: '2026-05-02', amount: 890 },
{ region: 'Asia', country: 'Japan', date: '2025-11-19', amount: 2140 },
{ region: 'Americas', country: 'USA', date: '2026-01-08', amount: 1730 },
];
private readonly pivot = viewChild.required(OgePivotGrid);
private readonly selected = signal<number[] | undefined>(undefined);
protected readonly chart = signal<OgePivotChartData<'bar'>>({ dataSource: [], series: [] });
// rows × measures of the current view: expand a region and the chart follows
protected refresh(): void {
this.chart.set(
this.pivot().getChartData({ type: 'bar', argumentIndexes: this.selected() }),
);
}
// a clicked row narrows the chart to it; click the grand total to reset
protected select(event: OgePivotCellClickEvent): void {
const rows = this.pivot().getResult().rowRoot;
const flat = rows.flatMap(function walk(node): typeof rows {
return [node, ...node.children.flatMap(walk)];
});
const line = flat.find(
(node) => JSON.stringify(node.path) === JSON.stringify(event.rowPath),
);
this.selected.set(line && !line.isGrandTotal ? [line.leafIndex] : undefined);
this.refresh();
}
}Notes
- Options:
argumentAxis('row'/'column'),measures,includeTotals/includeGrandTotals,argumentIndexes/seriesIndexes(a selection),typeandpathSeparator. - The adapter is
toChartSeries(result)in@oge-ui/pivot-engine— plain data, no chart import — so the commercial pivot packages keep no dependency on@oge-ui/charts. - Calculated measures (see Calculated Fields) chart like any other measure.