Apache ECharts charts for Elixir.
ECharts renders raw ECharts option maps. That keeps the full ECharts
surface available — candlesticks, dataZoom, financial tooltips, multiple
grids, maps, 3D and any series type ECharts supports — without a
grammar-of-graphics layer in between.
The ECharts 6 bundle is vendored, so charts work offline and do not depend on a CDN.
Integrations
- Livebook —
ECharts.Kino.new/2renders a chart andECharts.Kino.push/2updates it in place.ECharts.Kino.subscribe/3delivers browser events to a process - Phoenix LiveView —
ECharts.Phoenix.Component.echarts/1renders a chart in a template andECharts.Phoenix.push_update/3updates it without a round trip through the DOM differ - Static HTML —
ECharts.Phoenix.Component.static_echarts/2renders a chart in a controller-rendered page
Usage
chart =
ECharts.new(%{
xAxis: %{type: "category", data: ["Mon", "Tue", "Wed"]},
yAxis: %{type: "value"},
series: [%{type: "line", data: [120, 200, 150]}]
})
ECharts.Kino.render(chart)For one-call charts from tabular data, see ECharts.Express:
ECharts.Express.line(data, x: "date", y: "close", title: "Close")
|> ECharts.Kino.render()Options are sent to the browser as JSON, so values must be JSON-encodable. Atom keys are accepted and become strings.
Assets are public in every integration. Never put secrets (API keys, account balances you would not show on screen) in the option map.
Summary
Functions
Builds a chart from a raw ECharts option map.
Returns the raw ECharts option map.
Returns the payload as a JSON string.
Returns the payload consumed by the JavaScript clients.
Returns the vendored Apache ECharts version.
Types
@type chart() :: ECharts.Chart.t()
@type option() :: ECharts.Chart.option()
Functions
Builds a chart from a raw ECharts option map.
See ECharts.Chart.new/2 for the accepted options and examples.
Returns the raw ECharts option map.
Returns the payload as a JSON string.
Returns the payload consumed by the JavaScript clients.
@spec version() :: String.t()
Returns the vendored Apache ECharts version.