ECharts (echarts v0.1.1)

Copy Markdown View Source

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

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

chart()

@type chart() :: ECharts.Chart.t()

option()

@type option() :: ECharts.Chart.option()

Functions

new(option, opts \\ [])

@spec new(option(), keyword()) :: chart()

Builds a chart from a raw ECharts option map.

See ECharts.Chart.new/2 for the accepted options and examples.

option(chart)

@spec option(chart()) :: option()

Returns the raw ECharts option map.

to_json(chart)

@spec to_json(chart()) :: String.t()

Returns the payload as a JSON string.

to_map(chart)

@spec to_map(chart()) :: map()

Returns the payload consumed by the JavaScript clients.

version()

@spec version() :: String.t()

Returns the vendored Apache ECharts version.