Skip to content

Function: createChart() ​

ts
function createChart(el, figure?, options?): Chart;

Create a chart in el (plan §7.2). A chart already in el is destroyed first. The chart draws on the next microtask; await chart.ready (or any update call) to know when the frame is on screen.

Parameters ​

ParameterType
elHTMLElement
figureFigureInput
optionsChartOptions

Returns ​

Chart

Example ​

ts
const chart = createChart(el, { data: [{ x: [1, 2, 3], y: [4, 1, 7], mode: 'markers' }] });
await chart.restyle({ 'marker.color': 'crimson' });

Released under the MIT License.