# `ECharts`
[🔗](https://github.com/Mateus-M-Reis/echarts/blob/main/lib/echarts.ex#L1)

Apache [ECharts](https://echarts.apache.org) 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/2` renders a chart and
    `ECharts.Kino.push/2` updates it in place. `ECharts.Kino.subscribe/3`
    delivers browser events to a process
  * **Phoenix LiveView** — `ECharts.Phoenix.Component.echarts/1` renders a
    chart in a template and `ECharts.Phoenix.push_update/3` updates it
    without a round trip through the DOM differ
  * **Static HTML** — `ECharts.Phoenix.Component.static_echarts/2` renders
    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.

# `chart`

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

# `option`

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

# `new`

```elixir
@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`

```elixir
@spec option(chart()) :: option()
```

Returns the raw ECharts option map.

# `to_json`

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

Returns the payload as a JSON string.

# `to_map`

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

Returns the payload consumed by the JavaScript clients.

# `version`

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

Returns the vendored Apache ECharts version.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
