ECharts instance accessor, typically from createChart or useChart
Accessor returning the ActionPayload to dispatch. Re-evaluated whenever its reactive dependencies change.
Optionalopt: DispatchOptOptional dispatch options passed to every dispatchAction call.
Unlike dispatch which is imperative ("fire this action now"),
createAction is declarative - "keep this action in sync with this state".
Built-in guards make it safe to call at any time:
instance and action are tracked dependenciesThe first run is deferred intentionally, dispatching before the chart
has rendered its first frame causes actions like highlight and showTip
to silently no-op since the model isn't ready yet.
// Highlight follows a hovered table row - both states in one accessor
const [hoveredRow, setHoveredRow] = createSignal<number | null>(null);
createAction(instance, () =>
hoveredRow() !== null
? seActions.highlight({ seriesIndex: 0, dataIndex: hoveredRow()! })
: seActions.downplay({})
);
// ...
// Table rows update the signal - chart reacts automatically
<tr onMouseEnter={() => setHoveredRow(i)} onMouseLeave={() => setHoveredRow(null)}>
Reactive
dispatchActionbinding, fires whenever the action accessor returns a new payload. Conceptually identical tocreateEffectbut purpose-built for actions: instead of running an arbitrary side effect, it callschart.dispatchAction.