# ECharts gallery

```elixir
Mix.install([
  {:kino, "~> 0.19"},
  {:echarts, path: Path.expand("..", __DIR__)}
])

Code.require_file(Path.join(__DIR__, "support/chart_gallery.ex"))

# Match Livebook's default light canvas; Tema can switch to dark.
render_chart = fn name -> ChartGallery.kino(name, theme: :light) end
```

## Sobre

Every built-in ECharts 2D and 3D/GL chart family, rendered one cell at a time.
The setup cell installs the package from this checkout and loads the fixtures.

## Tema

Run this cell once. Choose **Claro** or **Escuro**, then re-evaluate a chart
cell. Each chart is independent, so you can compare both themes side by side.

```elixir
theme_input =
  Kino.Input.select("Tema", [{"light", "Claro"}, {"dark", "Escuro"}], default: "light")

render_chart = fn name ->
  ChartGallery.kino(name, theme: Kino.Input.read(theme_input))
end

theme_input
```

## Index

```elixir
ChartGallery.charts()
|> Enum.map(fn chart ->
  %{"category" => chart.category, "chart" => chart.name, "height" => chart.height}
end)
|> Kino.DataTable.new()
```

## Line

**Cartesian** — Smooth line with an area fill.

```elixir
render_chart.("Line")
```

## Bar

**Cartesian** — Grouped bars with rounded tops.

```elixir
render_chart.("Bar")
```

## Scatter

**Cartesian** — Two-dimensional points.

```elixir
render_chart.("Scatter")
```

## Effect scatter

**Cartesian** — Scatter with a ripple effect.

```elixir
render_chart.("Effect scatter")
```

## Heatmap

**Cartesian** — Matrix of values on two category axes.

```elixir
render_chart.("Heatmap")
```

## Pictorial bar

**Cartesian** — Bars drawn with repeated symbols.

```elixir
render_chart.("Pictorial bar")
```

## Lines

**Cartesian** — Trajectories on a cartesian plane.

```elixir
render_chart.("Lines")
```

## Theme river

**Cartesian** — Stacked streams over time.

```elixir
render_chart.("Theme river")
```

## Candlestick

**Financial** — OHLC candles with a moving average.

```elixir
render_chart.("Candlestick")
```

## Boxplot

**Financial** — Distribution summaries for four groups.

```elixir
render_chart.("Boxplot")
```

## Calendar heatmap

**Financial** — Daily values on a calendar.

```elixir
render_chart.("Calendar heatmap")
```

## Pie

**Circular** — Donut chart with a legend.

```elixir
render_chart.("Pie")
```

## Radar

**Circular** — Multivariate comparison.

```elixir
render_chart.("Radar")
```

## Gauge

**Circular** — Single-value gauge.

```elixir
render_chart.("Gauge")
```

## Funnel

**Circular** — Conversion funnel.

```elixir
render_chart.("Funnel")
```

## Chord

**Circular** — Directed flows between categories.

```elixir
render_chart.("Chord")
```

## Tree

**Hierarchy and flow** — Collapsible tree with curved edges.

```elixir
render_chart.("Tree")
```

## Treemap

**Hierarchy and flow** — Nested rectangles sized by value.

```elixir
render_chart.("Treemap")
```

## Sunburst

**Hierarchy and flow** — Radial hierarchy.

```elixir
render_chart.("Sunburst")
```

## Graph

**Hierarchy and flow** — Force-directed network.

```elixir
render_chart.("Graph")
```

## Sankey

**Hierarchy and flow** — Weighted flows between nodes.

```elixir
render_chart.("Sankey")
```

## Parallel

**Hierarchy and flow** — Parallel coordinates for several rows.

```elixir
render_chart.("Parallel")
```

## Map

**Geo and matrix** — GeoJSON map registered at runtime.

```elixir
render_chart.("Map")
```

## Matrix

**Geo and matrix** — ECharts 6 matrix coordinate system.

```elixir
render_chart.("Matrix")
```

## 3D bar

**3D** — Bars on a WebGL grid, powered by echarts-gl.

```elixir
render_chart.("3D bar")
```

## 3D scatter

**3D** — WebGL points in a three-dimensional grid.

```elixir
render_chart.("3D scatter")
```

## 3D line

**3D** — A polyline traced through a 3D grid.

```elixir
render_chart.("3D line")
```

## 3D surface

**3D** — A parametric surface rendered with echarts-gl.

```elixir
render_chart.("3D surface")
```

## Globe

**3D** — A WebGL globe with 3D scatter points.

```elixir
render_chart.("Globe")
```

## 3D map

**3D** — GeoJSON regions extruded by the WebGL renderer.

```elixir
render_chart.("3D map")
```

## 3D lines

**3D** — Flight-style trajectories over a 3D map.

```elixir
render_chart.("3D lines")
```

## 3D polygons

**3D** — Polygon regions drawn on the 3D geo coordinate system.

```elixir
render_chart.("3D polygons")
```

## Scatter GL

**3D** — Large point cloud rendered on the GPU.

```elixir
render_chart.("Scatter GL")
```

## Graph GL

**3D** — Force-directed network rendered with WebGL.

```elixir
render_chart.("Graph GL")
```

## Lines GL

**3D** — GPU-rendered polylines on a geo coordinate system.

```elixir
render_chart.("Lines GL")
```

## Flow GL

**3D** — Vector field on a cartesian plane.

```elixir
render_chart.("Flow GL")
```

## Word cloud

**Extensions** — Weighted words laid out by `echarts-wordcloud`.

```elixir
render_chart.("Word cloud")
```

## Liquid fill

**Extensions** — Animated liquid gauge from `echarts-liquidfill`.

```elixir
render_chart.("Liquid fill")
```

## Custom

**Extensibility** — Custom series rendered by a JavaScript callback.

```elixir
render_chart.("Custom")
```

## Notes

* All built-in 2D series are covered: line, bar, pie, scatter, effectScatter,
  radar, candlestick, boxplot, heatmap, map, tree, treemap, sunburst, graph,
  gauge, funnel, parallel, sankey, pictorialBar, themeRiver, lines, calendar,
  chord, matrix and custom.
* All echarts-gl chart types are covered: bar3D, scatter3D, line3D, surface,
  globe, map3D, lines3D, polygons3D, scatterGL, graphGL and flowGL.
* `custom` series use the `:functions` option; the option stores a
  `%{"$function" => "name"}` marker and the client compiles the JavaScript.
* 3D charts set `gl: true`; the client then loads the bundled `echarts-gl`
  extension only when needed.
* Each chart is its own cell, so a failure in one example does not take down
  the rest of the gallery.
