Chapter 03 · Dreambase ECharts
Subchapter 3.14
references/core-components.mdMarkdown3 KBView on GitHub
{
"color": ["#5470c6", "#91cc75", "..."],
"backgroundColor": "rgba(0,0,0,0)",
"darkMode": "auto",
"animation": true,
"useUTC": false,
"textStyle": { "fontFamily": "sans-serif", "fontSize": 12 }
}color — default palette, applied to series in order.animation — disable for live/streaming charts.useUTC — interpret times as UTC vs local."auto" (default), true, false."auto" — ECharts inspects backgroundColor and flips internal defaults (axis label color, splitLine color, etc.) so text stays readable on dark canvases. If you set backgroundColor to a dark color, you usually don’t need to set darkMode explicitly.true / false — force the mode regardless of background. Useful when:
"auto".{ "type": "value" | "category" | "time" | "log",
"name": "Revenue", "nameLocation": "middle", "nameGap": 30,
"min": 0, "max": "dataMax", "scale": true,
"axisLabel": { "formatter": "{value} USD", "rotate": 0 },
"axisLine": { "show": true }, "splitLine": { "show": true } }Multi-axis: pass an array of two axis objects. Series picks one via yAxisIndex: 1.
{ "trigger": "axis" | "item",
"axisPointer": { "type": "cross" | "shadow" | "line" },
"formatter": "{b}: {c}",
"valueFormatter": "(v) => v.toFixed(2)" }For multi-series, prefer trigger: 'axis'. For pie/scatter, trigger: 'item'.
formatter accepts template strings ({a} series, {b} name, {c} value,
{d} percent) or a JS function string; the renderer must eval function strings
under its safety policy, so prefer templates or valueFormatter.
{ "data": ["A","B"], "top": "5%", "left": "center", "orient": "horizontal",
"selected": { "B": false } }{ "left": "10%", "right": "5%", "top": 60, "bottom": 50, "containLabel": true }Set containLabel: true whenever axis labels rotate or get long — otherwise
labels clip at the canvas edge.
Two flavors, often used together:
{ "dataZoom": [
{ "type": "inside", "start": 0, "end": 100 },
{ "type": "slider", "start": 0, "end": 100, "bottom": 10 }
] }Continuous:
{ "type": "continuous", "min": 0, "max": 100,
"inRange": { "color": ["#50a3ba","#eac736","#d94e5d"] } }Required for heatmap and useful for any series that colors by value.
Piecewise buckets and diverging palettes: patterns/color-themes-and-visualmap.md.
{ "dataset": { "source": [["product","2024","2025"],["Tea",43.3,85.8],["Coffee",83.1,73.4]] },
"series": [{ "type": "bar" }, { "type": "bar" }] }With dataset, series map columns automatically; use encode to pick columns
explicitly. Use this whenever data exceeds ~200 inline points.
{ "title": { "text": "Revenue by quarter", "subtext": "FY 2025", "left": "center" } }{ "toolbox": { "feature": { "saveAsImage": {}, "dataZoom": {}, "restore": {}, "magicType": { "type": ["line","bar"] } } } }