ECharts.Phoenix (echarts v0.1.1)

Copy Markdown View Source

Helpers for Phoenix LiveView.

See ECharts.Phoenix.Component for rendering and hook setup.

Summary

Functions

Pushes a chart update to a LiveView without going through the DOM differ.

Functions

push_update(socket, id, chart)

Pushes a chart update to a LiveView without going through the DOM differ.

The chart container must have the same id used here. The hook handles the "echarts:update" event and re-renders only matching containers.

def handle_event("refresh", _params, socket) do
  chart = build_chart()
  {:noreply, ECharts.Phoenix.push_update(socket, "sales", chart)}
end

This is the recommended path for large series, where serializing the option into a data attribute on every render would produce a large diff.