Reactive accessor for the container HTMLElement.
The instance is created when the element becomes available and disposed
when it is removed. Typically a signal setter ref from a <div>.
Configuration options. See CreateChartOptions.
{ instance } - a reactive accessor for the live EChartsType
instance. Null before the container mounts, during reinit, and after dispose.
Manages four concerns reactively:
container is available,
disposes on cleanup. Only renderer triggers a full reinit cycle.setTheme in place (ECharts 6+). No reinit.chart.group and calls connect in place.ResizeObserver. Toggles reactively
without touching the instance.SSR-safe - returns { instance: () => null } on the server.
// Basic usage - wire a div ref to createChart
const [container, setContainer] = createSignal<HTMLDivElement | null>(null);
const { instance } = createChart(container, { theme: 'dark', renderer: 'canvas' });
// Wire option reactivity with createChartEffect
createChartEffect(instance, option);
<div ref={setContainer} style={{ width: '100%', height: '400px' }} />
// Reactive theme switching - no reinit, uses setTheme() in place
const [theme, setTheme] = createSignal<string>("default");
const { instance } = createChart(container, { theme });
<button onClick={() => setTheme('dark')}>Dark</button>
Core primitive for creating and managing an ECharts instance lifecycle.