Skip to content

Function: useChart() ​

ts
function useChart<F, View>(dashboard, spec): UseChartResult;

Defined in: packages/react/src/use-chart.ts:32

Add a chart to a dashboard for the lifetime of a component and follow its data and filter.

The chart is recreated (and its filter cleared) only when the spec's id, dimension, value or extra change as JSON. A change to view only redraws the renderer's view, and a change to renderer (by identity) mounts it again. Creation waits one microtask, so a StrictMode mount, unmount and mount adds the chart once.

Type Parameters ​

Type ParameterDefault type
F extends string-
Viewunknown

Parameters ​

ParameterType
dashboardDashboard<F> | null
specChartSpec<F, View>

Returns ​

UseChartResult

Released under the MIT License.