Documentation

@kanunilabs/datagrid-react-enterprise


@kanunilabs/datagrid-react-enterprise / ChartRenderContext

Interface: ChartRenderContext

Properties

blankLabel

blankLabel: string

What a blank category is called, in the grid's language.


colors

colors: string[]

Per-series colours, already resolved — index-aligned with model.series.


focusedCategory?

optional focusedCategory?: number

The category the keyboard is on (P-A11Y-01), as an index in the model drawn, while the chart has focus. Outline its marks; undefined otherwise.


format

format: ChartFormat

The reader's presentation choices. Renderers draw the axis titles and the data labels; the title and the legend are the panel's.


formatAxisLabel?

optional formatAxisLabel?: (request) => string

The app's axis label formatter (charting.axisLabelFormatter, §E.4 #56), ready to call; undefined when there is none. Hand it a tick's raw value and the text you would print, and draw what it returns — a renderer of your own takes part the same way.

Parameters

request

ChartAxisLabelRequest

Returns

string


hidden

hidden: ReadonlySet<number>

Series the user hid via the legend; renderers must skip these.


locale

locale: string

BCP-47 tag for number formatting.


onCategoryClick?

optional onCategoryClick?: (category, index, additive?) => void

Set when cross-filtering is enabled; a click on a category calls it with the category's index in the model drawn. Pass additive for a Ctrl/Cmd-click (event.ctrlKey || event.metaKey): it adds the category to a selection of several, or takes it out (§E.1 #7).

Parameters

category

string

index

number

additive?

boolean

Returns

void


rightAxis

rightAxis: ReadonlySet<number>

Series indices that belong on a SECOND, right-hand value axis.

Revenue summed over a million rows is ~2×10⁸; units summed over the same rows is ~2×10⁶. Plotted against one axis the second series is a hundredth of the first and draws as a flat line on the baseline — present in the legend, invisible in the chart. The panel decides the split; renderers just honour it.


selectedCategories?

optional selectedCategories?: ReadonlySet<number>

While several categories are picked with Ctrl/Cmd-click: their indices in the model drawn. Draw these at full strength and the other categories faint — the chart keeps every category on screen while picking, so this is what says which ones the grid shows. Undefined otherwise.


size

size: { height: number; width: number; } | null

Explicit canvas size in px, or null to fill the container.

Filling is the default and uses recharts' ResponsiveContainer, which sizes itself from a ResizeObserver — so it draws NOTHING until one fires. An element that starts display: none (a chart in a collapsed accordion or an inactive tab) therefore renders empty until it is shown. Passing a size skips the observer entirely, which is what a fixed-height dock wants.


stacking

stacking: ChartStacking

Grouped (beside), stacked, or stacked as shares of 100 — offered by the panel for types whose def is stackable. Renderers that cannot stack ignore it. When it is not grouped the panel leaves rightAxis empty: a stack has one baseline, so its series cannot be split across two axes.

Methods

formatColumnValue()

formatColumnValue(columnId, value): string

A raw value of a column as that column prints it — a scatter's x, y and size.

Parameters

columnId

string

value

number

Returns

string


formatSeriesValue()

formatSeriesValue(seriesIndex, value): string

Series i's value as its column prints it — the column's own formatter for sum/avg/min/max (formatChartValue). Tooltips and data labels use it.

Parameters

seriesIndex

number

value

number

Returns

string


formatValue()

formatValue(value): string

Parameters

value

number

Returns

string


onToggleSeries()

onToggleSeries(index): void

Parameters

index

number

Returns

void