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);}
本例需在 ECharts6.1.0 / Edge156.0.4314.58 / 自有同源数据与本地HTTP服务;实际程序化指针和动作 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:ECharts6.1.0 / Edge156.0.4314.58 / 自有同源数据与本地HTTP服务;实际程序化指针和动作
入口文件:projects/echarts-lab/src/echarts-style.js
预期结果与验证条件观察提示
- 对应变体真实运行;其数据、图元、事件或状态独立记录
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联12章) · 含当前章节或实例 · mbskycom202611a498.zip