蓝色天空.知识 · 实践 · 创造
我的收藏
ECharts 教程目录 12章
ECharts / LEARN BY DOING

ECharts 样式:主题、调色盘与高亮状态

保留主题加载、JSON注册、全局/系列色板及显式样式,并核对6.x默认主题差异。

学完这一章,你能够

  • 保留主题加载、JSON注册、全局/系列色板及显式样式,并核对6.x默认主题差异。
  • 保留主题加载、JSON注册、全局/系列色板及显式样式,并核对6.x默认主题差异。

主题与加载顺序

主题在初始化时选择,dark可用于内置深色对照;6.x默认主题、图例位置及历史light路径发生变化,不能假定旧界面与新默认外观完全相同。需要保持旧风格时按官方迁移主题处理。

主题编辑器可生成JS或JSON。JS主题必须先注册再init;JSON需要先fetch并检查响应,然后registerTheme。本例使用本站自有主题文件分别演示两种路线;外部wonderland原脚本不执行,原资源状态另存。

历史主题编辑器的选色界面,位置对应主题生成与注册说明;原文件缺失待补。

色板和显式覆盖

option.color是全局色板;系列自己的color可覆写该系列的自动取色规则。部分系列按系列取色,另一些按数据项取色,不能由一串颜色推断每根柱都会不同。

itemStyle作用于图形,lineStyle用于线,areaStyle用于面积,label用于文字。更具体的数据项样式通常覆盖上级配置;本例单独显示色板和直接样式,再检查实际图元颜色及线宽。

普通、高亮、模糊及选择

emphasis可指定高亮时itemStyle和label,默认效果会受库版本与系列影响。现代状态使用emphasis/blur/select,旧normal或历史highlight/downplay样式对象需说明迁移。

真正触发高亮后再核对颜色和标签;设置emphasis不等于鼠标已经命中。主题截图若缺失仍保留原锚点,不用一张随意图片替换成原图成功。

配置与生命周期参考

API/字段输入与用途返回/条件
echarts.init(dom,theme,opts)有尺寸的DOM、主题和renderer等ECharts实例;主题先注册,渲染器先引入
setOption(option,opts)普通或复合选项void;默认合并,notMerge/replaceMerge按目标设置
getOption()读取合并状态配置对象;含默认值,不宜随意整体写回
resize(opts)width/height等对象void;不是resize(宽,高)两个数
on / off事件名、可选query及handler按事件接口注册/解绑,同函数引用
dispatchAction(payload)动作type及目标字段动作及事件不是鼠标回调一一映射
showLoading / hideLoading加载状态及可选配置网络成功失败取消都须对应处理
dispose / isDisposed释放与状态销毁后不能被旧异步结果更新
getInstanceByDom已初始化容器实例或undefined
convertToPixel / convertFromPixel坐标查询与数值需匹配实际坐标系和系列
title / tooltip / legend标题、细节、系列选择名称及所属系列对应
xAxis / yAxis / series轴与数据系列类型、单位、索引均明确

本章字段及全部分支

字段职责条件
init theme默认/dark/已注册名称6.x默认与历史light不等同
registerTheme名称及主题对象JS或fetch JSON先注册
option.color全局自动色板不保证每项都不同
series.color当前系列色板覆盖相应自动取色
itemStyle / lineStyle / areaStyle / label形状/线/面积/文字按系列支持范围
data.itemStyle更具体样式通常优先于系列
emphasis / blur / select现代状态旧normal/highlight/downplay分开迁移

本章独立核心源码与验证步骤

含完整源码 · 521 行
展开查看收起
javascript
import * as echarts from 'echarts';
import {mount} from './lab.js';
import theme from './blue-sky-theme.js';
echarts.registerTheme('blue-sky-js',theme);

// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
  "key": "echarts-style",
  "title": "ECharts 样式:主题、调色盘与高亮状态",
  "cases": [
    {
      "id": "style-default",
      "title": "当前默认主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      }
    },
    {
      "id": "style-dark",
      "title": "内置dark",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "dark"
    },
    {
      "id": "style-js",
      "title": "本站JS注册主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-js"
    },
    {
      "id": "style-json",
      "title": "本站JSON加载主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-json"
    },
    {
      "id": "palette-global",
      "title": "全局调色盘",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ]
          }
        ],
        "color": [
          "#ff0000",
          "#00aa00",
          "#0000ff",
          "#aa00aa",
          "#00aaaa"
        ]
      }
    },
    {
      "id": "palette-series",
      "title": "系列调色盘覆盖",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ],
            "color": [
              "#00aa00",
              "#0000ff",
              "#aa00aa",
              "#00aaaa",
              "#aaaa00"
            ]
          }
        ],
        "color": [
          "#ff0000"
        ]
      }
    },
    {
      "id": "style-explicit",
      "title": "数据项覆盖系列样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              {
                "value": 12,
                "itemStyle": {
                  "color": "#db2777"
                }
              },
              24,
              18,
              31,
              22,
              27
            ],
            "itemStyle": {
              "color": "#2563eb",
              "borderWidth": 2,
              "borderColor": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-line",
      "title": "线、面积与文字样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "line",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "lineStyle": {
              "width": 4,
              "color": "#2563eb"
            },
            "areaStyle": {
              "color": "rgba(37,99,235,.2)"
            },
            "label": {
              "show": true,
              "color": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-emphasis",
      "title": "高亮样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "emphasis": {
              "itemStyle": {
                "color": "#ff0000"
              },
              "label": {
                "show": true,
                "formatter": "学习高亮"
              }
            }
          }
        ]
      }
    }
  ]
};
export default async function run(){await mount(echarts,specification);}

查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包

  • 本章所有变体真实渲染,实际图元和状态与本章教学条件对应
  • 不同初始化、轴/数据编码、状态分支或媒体布局分别核对
  • 定时器、请求及容器观察器在销毁后释放,不以模拟文字代替实际运行

内置dark:独立实例

含完整源码 · 521 行
展开查看收起
javascript
import * as echarts from 'echarts';
import {mount} from './lab.js';
import theme from './blue-sky-theme.js';
echarts.registerTheme('blue-sky-js',theme);

// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
  "key": "echarts-style",
  "title": "ECharts 样式:主题、调色盘与高亮状态",
  "cases": [
    {
      "id": "style-default",
      "title": "当前默认主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      }
    },
    {
      "id": "style-dark",
      "title": "内置dark",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "dark"
    },
    {
      "id": "style-js",
      "title": "本站JS注册主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-js"
    },
    {
      "id": "style-json",
      "title": "本站JSON加载主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-json"
    },
    {
      "id": "palette-global",
      "title": "全局调色盘",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ]
          }
        ],
        "color": [
          "#ff0000",
          "#00aa00",
          "#0000ff",
          "#aa00aa",
          "#00aaaa"
        ]
      }
    },
    {
      "id": "palette-series",
      "title": "系列调色盘覆盖",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ],
            "color": [
              "#00aa00",
              "#0000ff",
              "#aa00aa",
              "#00aaaa",
              "#aaaa00"
            ]
          }
        ],
        "color": [
          "#ff0000"
        ]
      }
    },
    {
      "id": "style-explicit",
      "title": "数据项覆盖系列样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              {
                "value": 12,
                "itemStyle": {
                  "color": "#db2777"
                }
              },
              24,
              18,
              31,
              22,
              27
            ],
            "itemStyle": {
              "color": "#2563eb",
              "borderWidth": 2,
              "borderColor": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-line",
      "title": "线、面积与文字样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "line",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "lineStyle": {
              "width": 4,
              "color": "#2563eb"
            },
            "areaStyle": {
              "color": "rgba(37,99,235,.2)"
            },
            "label": {
              "show": true,
              "color": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-emphasis",
      "title": "高亮样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "emphasis": {
              "itemStyle": {
                "color": "#ff0000"
              },
              "label": {
                "show": true,
                "formatter": "学习高亮"
              }
            }
          }
        ]
      }
    }
  ]
};
export default async function run(){await mount(echarts,specification);}

查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包

  • 对应变体真实运行;其数据、图元、事件或状态独立记录

本站JS注册主题:独立实例

含完整源码 · 521 行
展开查看收起
javascript
import * as echarts from 'echarts';
import {mount} from './lab.js';
import theme from './blue-sky-theme.js';
echarts.registerTheme('blue-sky-js',theme);

// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
  "key": "echarts-style",
  "title": "ECharts 样式:主题、调色盘与高亮状态",
  "cases": [
    {
      "id": "style-default",
      "title": "当前默认主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      }
    },
    {
      "id": "style-dark",
      "title": "内置dark",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "dark"
    },
    {
      "id": "style-js",
      "title": "本站JS注册主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-js"
    },
    {
      "id": "style-json",
      "title": "本站JSON加载主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-json"
    },
    {
      "id": "palette-global",
      "title": "全局调色盘",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ]
          }
        ],
        "color": [
          "#ff0000",
          "#00aa00",
          "#0000ff",
          "#aa00aa",
          "#00aaaa"
        ]
      }
    },
    {
      "id": "palette-series",
      "title": "系列调色盘覆盖",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ],
            "color": [
              "#00aa00",
              "#0000ff",
              "#aa00aa",
              "#00aaaa",
              "#aaaa00"
            ]
          }
        ],
        "color": [
          "#ff0000"
        ]
      }
    },
    {
      "id": "style-explicit",
      "title": "数据项覆盖系列样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              {
                "value": 12,
                "itemStyle": {
                  "color": "#db2777"
                }
              },
              24,
              18,
              31,
              22,
              27
            ],
            "itemStyle": {
              "color": "#2563eb",
              "borderWidth": 2,
              "borderColor": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-line",
      "title": "线、面积与文字样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "line",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "lineStyle": {
              "width": 4,
              "color": "#2563eb"
            },
            "areaStyle": {
              "color": "rgba(37,99,235,.2)"
            },
            "label": {
              "show": true,
              "color": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-emphasis",
      "title": "高亮样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "emphasis": {
              "itemStyle": {
                "color": "#ff0000"
              },
              "label": {
                "show": true,
                "formatter": "学习高亮"
              }
            }
          }
        ]
      }
    }
  ]
};
export default async function run(){await mount(echarts,specification);}

查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包

  • 对应变体真实运行;其数据、图元、事件或状态独立记录

本站JSON加载主题:独立实例

含完整源码 · 521 行
展开查看收起
javascript
import * as echarts from 'echarts';
import {mount} from './lab.js';
import theme from './blue-sky-theme.js';
echarts.registerTheme('blue-sky-js',theme);

// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
  "key": "echarts-style",
  "title": "ECharts 样式:主题、调色盘与高亮状态",
  "cases": [
    {
      "id": "style-default",
      "title": "当前默认主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      }
    },
    {
      "id": "style-dark",
      "title": "内置dark",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "dark"
    },
    {
      "id": "style-js",
      "title": "本站JS注册主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-js"
    },
    {
      "id": "style-json",
      "title": "本站JSON加载主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-json"
    },
    {
      "id": "palette-global",
      "title": "全局调色盘",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ]
          }
        ],
        "color": [
          "#ff0000",
          "#00aa00",
          "#0000ff",
          "#aa00aa",
          "#00aaaa"
        ]
      }
    },
    {
      "id": "palette-series",
      "title": "系列调色盘覆盖",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ],
            "color": [
              "#00aa00",
              "#0000ff",
              "#aa00aa",
              "#00aaaa",
              "#aaaa00"
            ]
          }
        ],
        "color": [
          "#ff0000"
        ]
      }
    },
    {
      "id": "style-explicit",
      "title": "数据项覆盖系列样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              {
                "value": 12,
                "itemStyle": {
                  "color": "#db2777"
                }
              },
              24,
              18,
              31,
              22,
              27
            ],
            "itemStyle": {
              "color": "#2563eb",
              "borderWidth": 2,
              "borderColor": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-line",
      "title": "线、面积与文字样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "line",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "lineStyle": {
              "width": 4,
              "color": "#2563eb"
            },
            "areaStyle": {
              "color": "rgba(37,99,235,.2)"
            },
            "label": {
              "show": true,
              "color": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-emphasis",
      "title": "高亮样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "emphasis": {
              "itemStyle": {
                "color": "#ff0000"
              },
              "label": {
                "show": true,
                "formatter": "学习高亮"
              }
            }
          }
        ]
      }
    }
  ]
};
export default async function run(){await mount(echarts,specification);}

查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包

  • 对应变体真实运行;其数据、图元、事件或状态独立记录

全局调色盘:独立实例

含完整源码 · 521 行
展开查看收起
javascript
import * as echarts from 'echarts';
import {mount} from './lab.js';
import theme from './blue-sky-theme.js';
echarts.registerTheme('blue-sky-js',theme);

// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
  "key": "echarts-style",
  "title": "ECharts 样式:主题、调色盘与高亮状态",
  "cases": [
    {
      "id": "style-default",
      "title": "当前默认主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      }
    },
    {
      "id": "style-dark",
      "title": "内置dark",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "dark"
    },
    {
      "id": "style-js",
      "title": "本站JS注册主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-js"
    },
    {
      "id": "style-json",
      "title": "本站JSON加载主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-json"
    },
    {
      "id": "palette-global",
      "title": "全局调色盘",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ]
          }
        ],
        "color": [
          "#ff0000",
          "#00aa00",
          "#0000ff",
          "#aa00aa",
          "#00aaaa"
        ]
      }
    },
    {
      "id": "palette-series",
      "title": "系列调色盘覆盖",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ],
            "color": [
              "#00aa00",
              "#0000ff",
              "#aa00aa",
              "#00aaaa",
              "#aaaa00"
            ]
          }
        ],
        "color": [
          "#ff0000"
        ]
      }
    },
    {
      "id": "style-explicit",
      "title": "数据项覆盖系列样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              {
                "value": 12,
                "itemStyle": {
                  "color": "#db2777"
                }
              },
              24,
              18,
              31,
              22,
              27
            ],
            "itemStyle": {
              "color": "#2563eb",
              "borderWidth": 2,
              "borderColor": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-line",
      "title": "线、面积与文字样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "line",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "lineStyle": {
              "width": 4,
              "color": "#2563eb"
            },
            "areaStyle": {
              "color": "rgba(37,99,235,.2)"
            },
            "label": {
              "show": true,
              "color": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-emphasis",
      "title": "高亮样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "emphasis": {
              "itemStyle": {
                "color": "#ff0000"
              },
              "label": {
                "show": true,
                "formatter": "学习高亮"
              }
            }
          }
        ]
      }
    }
  ]
};
export default async function run(){await mount(echarts,specification);}

查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包

  • 对应变体真实运行;其数据、图元、事件或状态独立记录

系列调色盘覆盖:独立实例

含完整源码 · 521 行
展开查看收起
javascript
import * as echarts from 'echarts';
import {mount} from './lab.js';
import theme from './blue-sky-theme.js';
echarts.registerTheme('blue-sky-js',theme);

// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
  "key": "echarts-style",
  "title": "ECharts 样式:主题、调色盘与高亮状态",
  "cases": [
    {
      "id": "style-default",
      "title": "当前默认主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      }
    },
    {
      "id": "style-dark",
      "title": "内置dark",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "dark"
    },
    {
      "id": "style-js",
      "title": "本站JS注册主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-js"
    },
    {
      "id": "style-json",
      "title": "本站JSON加载主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-json"
    },
    {
      "id": "palette-global",
      "title": "全局调色盘",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ]
          }
        ],
        "color": [
          "#ff0000",
          "#00aa00",
          "#0000ff",
          "#aa00aa",
          "#00aaaa"
        ]
      }
    },
    {
      "id": "palette-series",
      "title": "系列调色盘覆盖",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ],
            "color": [
              "#00aa00",
              "#0000ff",
              "#aa00aa",
              "#00aaaa",
              "#aaaa00"
            ]
          }
        ],
        "color": [
          "#ff0000"
        ]
      }
    },
    {
      "id": "style-explicit",
      "title": "数据项覆盖系列样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              {
                "value": 12,
                "itemStyle": {
                  "color": "#db2777"
                }
              },
              24,
              18,
              31,
              22,
              27
            ],
            "itemStyle": {
              "color": "#2563eb",
              "borderWidth": 2,
              "borderColor": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-line",
      "title": "线、面积与文字样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "line",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "lineStyle": {
              "width": 4,
              "color": "#2563eb"
            },
            "areaStyle": {
              "color": "rgba(37,99,235,.2)"
            },
            "label": {
              "show": true,
              "color": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-emphasis",
      "title": "高亮样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "emphasis": {
              "itemStyle": {
                "color": "#ff0000"
              },
              "label": {
                "show": true,
                "formatter": "学习高亮"
              }
            }
          }
        ]
      }
    }
  ]
};
export default async function run(){await mount(echarts,specification);}

查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包

  • 对应变体真实运行;其数据、图元、事件或状态独立记录

数据项覆盖系列样式:独立实例

含完整源码 · 521 行
展开查看收起
javascript
import * as echarts from 'echarts';
import {mount} from './lab.js';
import theme from './blue-sky-theme.js';
echarts.registerTheme('blue-sky-js',theme);

// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
  "key": "echarts-style",
  "title": "ECharts 样式:主题、调色盘与高亮状态",
  "cases": [
    {
      "id": "style-default",
      "title": "当前默认主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      }
    },
    {
      "id": "style-dark",
      "title": "内置dark",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "dark"
    },
    {
      "id": "style-js",
      "title": "本站JS注册主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-js"
    },
    {
      "id": "style-json",
      "title": "本站JSON加载主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-json"
    },
    {
      "id": "palette-global",
      "title": "全局调色盘",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ]
          }
        ],
        "color": [
          "#ff0000",
          "#00aa00",
          "#0000ff",
          "#aa00aa",
          "#00aaaa"
        ]
      }
    },
    {
      "id": "palette-series",
      "title": "系列调色盘覆盖",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ],
            "color": [
              "#00aa00",
              "#0000ff",
              "#aa00aa",
              "#00aaaa",
              "#aaaa00"
            ]
          }
        ],
        "color": [
          "#ff0000"
        ]
      }
    },
    {
      "id": "style-explicit",
      "title": "数据项覆盖系列样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              {
                "value": 12,
                "itemStyle": {
                  "color": "#db2777"
                }
              },
              24,
              18,
              31,
              22,
              27
            ],
            "itemStyle": {
              "color": "#2563eb",
              "borderWidth": 2,
              "borderColor": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-line",
      "title": "线、面积与文字样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "line",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "lineStyle": {
              "width": 4,
              "color": "#2563eb"
            },
            "areaStyle": {
              "color": "rgba(37,99,235,.2)"
            },
            "label": {
              "show": true,
              "color": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-emphasis",
      "title": "高亮样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "emphasis": {
              "itemStyle": {
                "color": "#ff0000"
              },
              "label": {
                "show": true,
                "formatter": "学习高亮"
              }
            }
          }
        ]
      }
    }
  ]
};
export default async function run(){await mount(echarts,specification);}

查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包

  • 对应变体真实运行;其数据、图元、事件或状态独立记录

线、面积与文字样式:独立实例

含完整源码 · 521 行
展开查看收起
javascript
import * as echarts from 'echarts';
import {mount} from './lab.js';
import theme from './blue-sky-theme.js';
echarts.registerTheme('blue-sky-js',theme);

// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
  "key": "echarts-style",
  "title": "ECharts 样式:主题、调色盘与高亮状态",
  "cases": [
    {
      "id": "style-default",
      "title": "当前默认主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      }
    },
    {
      "id": "style-dark",
      "title": "内置dark",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "dark"
    },
    {
      "id": "style-js",
      "title": "本站JS注册主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-js"
    },
    {
      "id": "style-json",
      "title": "本站JSON加载主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-json"
    },
    {
      "id": "palette-global",
      "title": "全局调色盘",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ]
          }
        ],
        "color": [
          "#ff0000",
          "#00aa00",
          "#0000ff",
          "#aa00aa",
          "#00aaaa"
        ]
      }
    },
    {
      "id": "palette-series",
      "title": "系列调色盘覆盖",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ],
            "color": [
              "#00aa00",
              "#0000ff",
              "#aa00aa",
              "#00aaaa",
              "#aaaa00"
            ]
          }
        ],
        "color": [
          "#ff0000"
        ]
      }
    },
    {
      "id": "style-explicit",
      "title": "数据项覆盖系列样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              {
                "value": 12,
                "itemStyle": {
                  "color": "#db2777"
                }
              },
              24,
              18,
              31,
              22,
              27
            ],
            "itemStyle": {
              "color": "#2563eb",
              "borderWidth": 2,
              "borderColor": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-line",
      "title": "线、面积与文字样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "line",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "lineStyle": {
              "width": 4,
              "color": "#2563eb"
            },
            "areaStyle": {
              "color": "rgba(37,99,235,.2)"
            },
            "label": {
              "show": true,
              "color": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-emphasis",
      "title": "高亮样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "emphasis": {
              "itemStyle": {
                "color": "#ff0000"
              },
              "label": {
                "show": true,
                "formatter": "学习高亮"
              }
            }
          }
        ]
      }
    }
  ]
};
export default async function run(){await mount(echarts,specification);}

查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包

  • 对应变体真实运行;其数据、图元、事件或状态独立记录

高亮样式:独立实例

含完整源码 · 521 行
展开查看收起
javascript
import * as echarts from 'echarts';
import {mount} from './lab.js';
import theme from './blue-sky-theme.js';
echarts.registerTheme('blue-sky-js',theme);

// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
  "key": "echarts-style",
  "title": "ECharts 样式:主题、调色盘与高亮状态",
  "cases": [
    {
      "id": "style-default",
      "title": "当前默认主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      }
    },
    {
      "id": "style-dark",
      "title": "内置dark",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "dark"
    },
    {
      "id": "style-js",
      "title": "本站JS注册主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-js"
    },
    {
      "id": "style-json",
      "title": "本站JSON加载主题",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ]
          }
        ]
      },
      "theme": "blue-sky-json"
    },
    {
      "id": "palette-global",
      "title": "全局调色盘",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ]
          }
        ],
        "color": [
          "#ff0000",
          "#00aa00",
          "#0000ff",
          "#aa00aa",
          "#00aaaa"
        ]
      }
    },
    {
      "id": "palette-series",
      "title": "系列调色盘覆盖",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 学习构成"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "bottom": 0
        },
        "series": [
          {
            "id": "composition",
            "name": "学习构成",
            "type": "pie",
            "radius": "55%",
            "center": [
              "50%",
              "50%"
            ],
            "data": [
              {
                "name": "阅读",
                "value": 12
              },
              {
                "name": "实作",
                "value": 24
              },
              {
                "name": "复习",
                "value": 18
              },
              {
                "name": "调试",
                "value": 31
              },
              {
                "name": "整理",
                "value": 22
              }
            ],
            "color": [
              "#00aa00",
              "#0000ff",
              "#aa00aa",
              "#00aaaa",
              "#aaaa00"
            ]
          }
        ],
        "color": [
          "#ff0000"
        ]
      }
    },
    {
      "id": "style-explicit",
      "title": "数据项覆盖系列样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              {
                "value": 12,
                "itemStyle": {
                  "color": "#db2777"
                }
              },
              24,
              18,
              31,
              22,
              27
            ],
            "itemStyle": {
              "color": "#2563eb",
              "borderWidth": 2,
              "borderColor": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-line",
      "title": "线、面积与文字样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "line",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "lineStyle": {
              "width": 4,
              "color": "#2563eb"
            },
            "areaStyle": {
              "color": "rgba(37,99,235,.2)"
            },
            "label": {
              "show": true,
              "color": "#18283d"
            }
          }
        ]
      }
    },
    {
      "id": "style-emphasis",
      "title": "高亮样式",
      "option": {
        "animation": false,
        "title": {
          "text": "蓝色天空网 · 虚构学习数据"
        },
        "tooltip": {
          "trigger": "item"
        },
        "legend": {
          "top": 35
        },
        "grid": {
          "top": 90,
          "bottom": 65,
          "containLabel": true
        },
        "xAxis": {
          "type": "category",
          "data": [
            "阅读",
            "实作",
            "复习",
            "调试",
            "整理",
            "回顾"
          ]
        },
        "yAxis": {
          "type": "value",
          "name": "次数"
        },
        "series": [
          {
            "id": "study",
            "name": "练习次数",
            "type": "bar",
            "data": [
              12,
              24,
              18,
              31,
              22,
              27
            ],
            "emphasis": {
              "itemStyle": {
                "color": "#ff0000"
              },
              "label": {
                "show": true,
                "formatter": "学习高亮"
              }
            }
          }
        ]
      }
    }
  ]
};
export default async function run(){await mount(echarts,specification);}

查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包

  • 对应变体真实运行;其数据、图元、事件或状态独立记录

本章附件与实例包

下载课程关联工程包:ECharts

课程关联工程包(登记关联12章) · 含当前章节或实例 · mbskycom202611a498.zip

常见错误与边界检查

  • 只看option或标题而未核对真实数据、图元、状态。
  • 旧版本、外部数据及未运行环境被误写成已完成。

技术规范与官方资料

练习与参考解答

查看参考解答

保持图表类型、轴、维度、数据和交互对应;完整来源事实、真人键盘/触屏/读屏及其他版本仍需独立复核。

SITE SEARCH

搜索教程、工具与资讯

热门搜索

JavaScriptJSON格式化正则表达式AI 编程AI 翻译AI导航专题标签
Esc 关闭

欢迎登录蓝色天空网

使用会员账号,继续你的学习