# ECharts gallery

> Copy practical declarative ECharts patterns for documentation pages.

---

LLMS index: [llms.txt](/llms.txt)

---

These examples use only structured YAML. They require no callback code and
therefore stay within the simplest ECharts authoring and review boundary. The
numbers are illustrative.

## Reuse a dataset {#reuse-a-dataset}

ECharts `dataset` keeps records separate from their visual encoding. Series can
refer to dimensions by name, which is easier to review than repeating parallel
arrays.

## Bar chart from a dataset {#bar-chart-from-a-dataset}

```go-html-template
{{< echarts height="320px" >}}
dataset:
  source:
    - [stage, minutes]
    - [Draft, 18]
    - [Review, 11]
    - [Publish, 4]
xAxis: { type: category }
yAxis: { type: value, name: Minutes }
series:
  - type: bar
    encode: { x: stage, y: minutes }
{{< /echarts >}}
```

The example shows the median duration falling from 18 minutes for drafting to
four minutes for publication.

<!-- prettier-ignore-start -->


<div id="td-echarts-d327a546ce5fd3a932280b944f0c9542-0" class="td-echarts td-max-width-on-larger-screens"
  data-td-echarts>
  <div data-td-echarts-canvas style="height: 320px"></div>
  <script type="application/json" data-td-echarts-options>{"dataset":{"source":[["stage","minutes"],["Draft",18],["Review",11],["Publish",4]]},"series":[{"encode":{"x":"stage","y":"minutes"},"type":"bar"}],"xAxis":{"type":"category"},"yAxis":{"name":"Minutes","type":"value"}}</script>
</div>


<!-- prettier-ignore-end -->

## Line and area comparison {#line-and-area-comparison}

Use a shared category axis when several series describe the same intervals. The
area fill emphasizes volume; the lines preserve the individual trends.

```go-html-template
{{< echarts height="340px" >}}
tooltip: { trigger: axis }
legend: { data: [English, Chinese] }
xAxis:
  type: category
  data: [Mon, Tue, Wed, Thu, Fri]
yAxis: { type: value, name: Pages }
series:
  - name: English
    type: line
    smooth: true
    areaStyle: { opacity: 0.12 }
    data: [5, 8, 7, 11, 13]
  - name: Chinese
    type: line
    smooth: true
    areaStyle: { opacity: 0.12 }
    data: [4, 6, 8, 9, 13]
{{< /echarts >}}
```

Both language queues reach 13 reviewed pages on Friday; the Chinese queue
catches up after starting one page lower.

<!-- prettier-ignore-start -->


<div id="td-echarts-d327a546ce5fd3a932280b944f0c9542-1" class="td-echarts td-max-width-on-larger-screens"
  data-td-echarts>
  <div data-td-echarts-canvas style="height: 340px"></div>
  <script type="application/json" data-td-echarts-options>{"legend":{"data":["English","Chinese"]},"series":[{"areaStyle":{"opacity":0.12},"data":[5,8,7,11,13],"name":"English","smooth":true,"type":"line"},{"areaStyle":{"opacity":0.12},"data":[4,6,8,9,13],"name":"Chinese","smooth":true,"type":"line"}],"tooltip":{"trigger":"axis"},"xAxis":{"data":["Mon","Tue","Wed","Thu","Fri"],"type":"category"},"yAxis":{"name":"Pages","type":"value"}}</script>
</div>


<!-- prettier-ignore-end -->

## Donut breakdown {#donut-breakdown}

A donut works for a small part-to-whole comparison. Keep the categories few,
show labels directly, and provide the totals in text.

```go-html-template
{{< echarts height="340px" >}}
tooltip: { trigger: item }
legend: { bottom: 0 }
series:
  - name: Documentation pages
    type: pie
    radius: [42%, 68%]
    avoidLabelOverlap: true
    label: { formatter: "{b}: {c}" }
    data:
      - { name: Guides, value: 28 }
      - { name: Reference, value: 17 }
      - { name: Tutorials, value: 11 }
      - { name: Concepts, value: 8 }
{{< /echarts >}}
```

The 64-page set contains 28 guides, 17 reference pages, 11 tutorials, and eight
concept pages.

<!-- prettier-ignore-start -->


<div id="td-echarts-d327a546ce5fd3a932280b944f0c9542-2" class="td-echarts td-max-width-on-larger-screens"
  data-td-echarts>
  <div data-td-echarts-canvas style="height: 340px"></div>
  <script type="application/json" data-td-echarts-options>{"legend":{"bottom":0},"series":[{"avoidLabelOverlap":true,"data":[{"name":"Guides","value":28},{"name":"Reference","value":17},{"name":"Tutorials","value":11},{"name":"Concepts","value":8}],"label":{"formatter":"{b}: {c}"},"name":"Documentation pages","radius":["42%","68%"],"type":"pie"}],"tooltip":{"trigger":"item"}}</script>
</div>


<!-- prettier-ignore-end -->

## Scatter plot with visual encoding {#scatter-plot-with-visual-encoding}

`visualMap` can encode a third dimension without callback code. The following
plot maps build size to point size and build status to color.

```go-html-template
{{< echarts height="360px" >}}
tooltip: { trigger: item }
xAxis: { type: value, name: Build seconds }
yAxis: { type: value, name: Pages }
visualMap:
  - type: continuous
    dimension: 2
    min: 10
    max: 50
    inRange: { symbolSize: [10, 32], color: ["#60a5fa", "#f97316"] }
    right: 0
    top: middle
series:
  - type: scatter
    encode: { x: 0, y: 1, tooltip: [0, 1, 2] }
    data:
      - [1.8, 24, 12]
      - [2.6, 41, 22]
      - [3.9, 67, 35]
      - [5.1, 92, 48]
{{< /echarts >}}
```

Larger sites take longer to build in this illustrative sample; point size and
color both encode the third value so color is not the only cue.

<!-- prettier-ignore-start -->


<div id="td-echarts-d327a546ce5fd3a932280b944f0c9542-3" class="td-echarts td-max-width-on-larger-screens"
  data-td-echarts>
  <div data-td-echarts-canvas style="height: 360px"></div>
  <script type="application/json" data-td-echarts-options>{"series":[{"data":[[1.8,24,12],[2.6,41,22],[3.9,67,35],[5.1,92,48]],"encode":{"tooltip":[0,1,2],"x":0,"y":1},"type":"scatter"}],"tooltip":{"trigger":"item"},"visualMap":[{"dimension":2,"inRange":{"color":["#60a5fa","#f97316"],"symbolSize":[10,32]},"max":50,"min":10,"right":0,"top":"middle","type":"continuous"}],"xAxis":{"name":"Build seconds","type":"value"},"yAxis":{"name":"Pages","type":"value"}}</script>
</div>


<!-- prettier-ignore-end -->

## Production notes {#production-notes}

Keep example data close to the chart only when it is small and editorial. For
larger or generated datasets, produce the options during the site's content
pipeline and review the resulting page source. Oink does not fetch chart data
from a remote endpoint automatically; adding a network request is an explicit
site integration and changes the local-first and privacy boundary.
