ECharts gallery
Copy practical declarative ECharts patterns for documentation pages.
The echarts shortcode renders an Apache ECharts options object with the
versioned runtime bundled by Oink. Hugo parses JSON or YAML at build time,
serializes the result into the page, and loads ECharts only on pages that use
the component.
Use ECharts for quantitative charts whose axes, encodings, tooltips, or series need more control than a diagram or table provides. Keep a nearby textual summary so the conclusion does not depend on color, pointer interaction, or JavaScript.
{{< echarts height="300px" >}}
xAxis:
type: category
data: [Draft, Review, Publish]
yAxis:
type: value
series:
- type: bar
data: [12, 9, 4]
{{< /echarts >}}The example shows 12 draft pages, nine pages in review, and four pages ready to publish.
The shortcode creates a unique chart container and stores the parsed options in
an application/json element. The page includes the local ECharts runtime and
Oink initializer once, even when it contains several charts.
If theme is not set, Oink initializes the chart for the current site color
mode and redraws it when the reader changes modes. A ResizeObserver resizes
the chart with its container. Setting an explicit ECharts theme opts out of
automatic site-theme switching for that chart.
| Parameter | Default | Behavior |
|---|---|---|
height |
400px |
Accepts a nonnegative number with px, rem, em, vh, vw, or % |
theme |
unset | Uses a named ECharts theme; when unset, follows the site’s light or dark color mode |
full |
false |
Set to true to remove Oink’s normal content-width clamp |
Invalid height values fail the Hugo build. The shortcode body must decode to an ECharts options object; malformed JSON or YAML also fails at build time instead of creating a blank chart silently.
$fn:name bridge, and its security boundary.Start with declarative JSON or YAML. Add JavaScript callbacks only when the ECharts option cannot be expressed as data.
dataset when several series use the same records.OINK documents its wrapper and delivery behavior; the full options schema
belongs to Apache ECharts. Use the
ECharts concepts handbook,
dataset guide, and
option reference for chart-specific
settings. The theme’s VENDOR.json records the exact runtime version and
license shipped by a release.
Copy practical declarative ECharts patterns for documentation pages.
Use reviewed formatter and styling functions when structured options are not enough.