ExeQute.EChart
(exe_qute v0.1.1)
Copy Markdown
Live Apache ECharts widget for Livebook.
Work in progress
This module is functional but not yet fully polished. The API and behaviour may change in future releases.
Wraps Apache ECharts via Kino.JS.Live. ECharts options are passed as Elixir
maps and serialised to JSON; the JavaScript side calls setOption on every
update. The goal is a lower-overhead alternative to VegaLite for high-frequency
streaming data — ECharts handles incremental series updates without rebuilding
the entire chart.
Static usage
options = %{
"xAxis" => %{"type" => "category", "data" => ["EUR/USD", "USD/JPY"]},
"yAxis" => %{"type" => "value"},
"series" => [%{"name" => "lp1", "type" => "bar", "data" => [1.05, 1.08]}]
}
chart = ExeQute.EChart.new(options: options)Live usage
chart = ExeQute.EChart.new()
ExeQute.EChart.render(chart, initial_options)
ExeQute.EChart.push(chart, updated_options)Chart cell helpers
update_buffer/3, options_from_buffer/2, and buffer_to_rows/2 are used
by the generated code of ExeQute.ChartCell but are public so they can be
called directly when building custom subscription callbacks.
Summary
Functions
Converts a buffer to a flat list of row maps for Kino.DataTable.
Creates a new EChart widget.
Builds a full ECharts option map from the current buffer and config.
Pushes an incremental update.
Replaces the chart entirely with options.
Updates the internal row buffer with newly arrived rows.
Functions
Converts a buffer to a flat list of row maps for Kino.DataTable.
@spec new(keyword()) :: Kino.JS.Live.t()
Creates a new EChart widget.
Options
:options- initial ECharts option map (default:%{}):height- chart height in pixels (default:400)
Builds a full ECharts option map from the current buffer and config.
@spec push(Kino.JS.Live.t(), map()) :: :ok
Pushes an incremental update.
Calls setOption(options, { replaceMerge: ['series'] }) — series are
replaced by the new list while axes, legend, and tooltip are preserved.
Suitable for streaming data updates.
@spec render(Kino.JS.Live.t(), map()) :: :ok
Replaces the chart entirely with options.
Calls setOption(options, { notMerge: true }) — all existing components
are discarded. Use this for structural changes (switching chart type, etc.).
Updates the internal row buffer with newly arrived rows.
cfg is the config map read from ETS (atom keys). Returns the updated
buffer. The buffer format is {list, map}:
list— newest-first list of rows, used for temporal/quantitative x axesmap— keyed byx_valueor{x_value, color_value}, used for nominal axes