ECharts visualMap:维度、通道与分段边界
保留连续、三种分段及多映射目标,修正系列索引和尺寸语义。
学完这一章,你能够
- 保留连续、三种分段及多映射目标,修正系列索引和尺寸语义。
- 保留连续、三种分段及多映射目标,修正系列索引和尺寸语义。
数据项与视觉通道
series.data每项可为值或含value/itemStyle的对象,value可为多维数组。维度的顺序和类型必须明确:维度3是第四列,seriesIndex:4是第五个系列,不能把0基索引解释错位。
可映射symbol、symbolSize、color、opacity、colorAlpha、colorLightness、colorSaturation、colorHue。opacity会影响图元及关联内容,而colorAlpha只改颜色透明度;色调、饱和度、明度也不是同一参数。
连续及分段分别保留
continuous表达连续映射并可设选中范围;piecewise可按splitNumber自动分段、pieces自定义范围,或categories按离散类别分段。本例分别保留三个分段入口,边界lt/lte/gt/gte要精确,不用含糊的低中高代替。
分段型视觉映射示意,紧接三种分段模式说明;原文件缺失待补。
inRange/outOfRange描述当前选中与范围外的视觉状态;数据范围、选择范围与过滤不是同一概念。symbolSize表示符号布局尺寸,并不普遍等于气泡半径或面积。
多组件与实际结果
多个visualMap可用不同dimension和seriesIndex作用于颜色、尺寸或明度。避免同通道竞争而不知道最终覆盖关系;本例保留第四维到第五系列的映射,并另有明度对照。
检查实际数据视觉值、图元样式和选择动作结果,不因配置中写了color就判定所有点已按预期变化。缺失的原分段图保持原锚点待补,不能用错图填位。
配置与生命周期参考
| 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 | 轴与数据系列 | 类型、单位、索引均明确 |
本章字段及全部分支
| 字段/通道 | 类型/含义 | 边界 |
| dimension | 0基维度 | 3表示第四列 |
| seriesIndex | 0基系列 | 4表示第五系列 |
| continuous | 连续映射 | 数据范围与选择范围分开 |
| piecewise.splitNumber | 均分连续数据 | 不是类别个数 |
| piecewise.pieces | 自定义lt/lte/gt/gte等 | 精确覆盖边界 |
| piecewise.categories | 离散类别 | 对应字符串值 |
| inRange / outOfRange | 选中内外的视觉 | 不直接等同删除原数据 |
| symbol / symbolSize | 符号类型/尺寸 | 不笼统解释成半径 |
| color / colorAlpha | 颜色/颜色透明度 | 与整体opacity不同 |
| opacity | 整体透明度 | 包括关联内容的适用行为 |
| colorLightness / colorSaturation / colorHue | 明度/饱和度/色调 | 不同视觉通道,竞争时检查覆盖 |
本章独立核心源码与验证步骤
展开查看收起
import * as echarts from 'echarts';
import {mount} from './lab.js';
// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
"key": "echarts-visualmap",
"title": "ECharts visualMap:维度、通道与分段边界",
"cases": [
{
"id": "visual-continuous",
"title": "连续映射与选择",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "continuous",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
}
}
},
"behavior": "visual"
},
{
"id": "visual-split",
"title": "自动三段",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
},
"splitNumber": 3
}
}
},
{
"id": "visual-pieces",
"title": "自定义边界",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
},
"pieces": [
{
"lt": 50,
"label": "低于50"
},
{
"gte": 50,
"lte": 80,
"label": "50至80"
},
{
"gt": 80,
"label": "大于80"
}
]
}
}
},
{
"id": "visual-categories",
"title": "类别及形状映射",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
"基础"
],
[
1,
5,
"进阶"
],
[
2,
8,
"项目"
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"categories": [
"基础",
"进阶",
"项目"
],
"inRange": {
"color": [
"#2563eb",
"#db2777",
"#059669"
],
"symbol": [
"circle",
"rect",
"triangle"
]
}
}
}
},
{
"id": "visual-multiple",
"title": "第四维到第五系列及明度",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"id": "v0",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v1",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v2",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v3",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v4",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
}
],
"visualMap": [
{
"type": "continuous",
"min": 0,
"max": 100,
"dimension": 3,
"seriesIndex": 4,
"right": 0,
"top": 45,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
}
},
{
"type": "continuous",
"min": 0,
"max": 100,
"dimension": 2,
"seriesIndex": 0,
"right": 0,
"bottom": 0,
"inRange": {
"colorLightness": [
0.2,
0.8
]
}
}
]
}
}
]
};
export default async function run(){await mount(echarts,specification);}
查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包
- 本章所有变体真实渲染,实际图元和状态与本章教学条件对应
- 不同初始化、轴/数据编码、状态分支或媒体布局分别核对
- 定时器、请求及容器观察器在销毁后释放,不以模拟文字代替实际运行
自动三段:独立实例
展开查看收起
import * as echarts from 'echarts';
import {mount} from './lab.js';
// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
"key": "echarts-visualmap",
"title": "ECharts visualMap:维度、通道与分段边界",
"cases": [
{
"id": "visual-continuous",
"title": "连续映射与选择",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "continuous",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
}
}
},
"behavior": "visual"
},
{
"id": "visual-split",
"title": "自动三段",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
},
"splitNumber": 3
}
}
},
{
"id": "visual-pieces",
"title": "自定义边界",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
},
"pieces": [
{
"lt": 50,
"label": "低于50"
},
{
"gte": 50,
"lte": 80,
"label": "50至80"
},
{
"gt": 80,
"label": "大于80"
}
]
}
}
},
{
"id": "visual-categories",
"title": "类别及形状映射",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
"基础"
],
[
1,
5,
"进阶"
],
[
2,
8,
"项目"
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"categories": [
"基础",
"进阶",
"项目"
],
"inRange": {
"color": [
"#2563eb",
"#db2777",
"#059669"
],
"symbol": [
"circle",
"rect",
"triangle"
]
}
}
}
},
{
"id": "visual-multiple",
"title": "第四维到第五系列及明度",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"id": "v0",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v1",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v2",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v3",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v4",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
}
],
"visualMap": [
{
"type": "continuous",
"min": 0,
"max": 100,
"dimension": 3,
"seriesIndex": 4,
"right": 0,
"top": 45,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
}
},
{
"type": "continuous",
"min": 0,
"max": 100,
"dimension": 2,
"seriesIndex": 0,
"right": 0,
"bottom": 0,
"inRange": {
"colorLightness": [
0.2,
0.8
]
}
}
]
}
}
]
};
export default async function run(){await mount(echarts,specification);}
查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包
- 对应变体真实运行;其数据、图元、事件或状态独立记录
自定义边界:独立实例
展开查看收起
import * as echarts from 'echarts';
import {mount} from './lab.js';
// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
"key": "echarts-visualmap",
"title": "ECharts visualMap:维度、通道与分段边界",
"cases": [
{
"id": "visual-continuous",
"title": "连续映射与选择",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "continuous",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
}
}
},
"behavior": "visual"
},
{
"id": "visual-split",
"title": "自动三段",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
},
"splitNumber": 3
}
}
},
{
"id": "visual-pieces",
"title": "自定义边界",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
},
"pieces": [
{
"lt": 50,
"label": "低于50"
},
{
"gte": 50,
"lte": 80,
"label": "50至80"
},
{
"gt": 80,
"label": "大于80"
}
]
}
}
},
{
"id": "visual-categories",
"title": "类别及形状映射",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
"基础"
],
[
1,
5,
"进阶"
],
[
2,
8,
"项目"
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"categories": [
"基础",
"进阶",
"项目"
],
"inRange": {
"color": [
"#2563eb",
"#db2777",
"#059669"
],
"symbol": [
"circle",
"rect",
"triangle"
]
}
}
}
},
{
"id": "visual-multiple",
"title": "第四维到第五系列及明度",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"id": "v0",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v1",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v2",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v3",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v4",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
}
],
"visualMap": [
{
"type": "continuous",
"min": 0,
"max": 100,
"dimension": 3,
"seriesIndex": 4,
"right": 0,
"top": 45,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
}
},
{
"type": "continuous",
"min": 0,
"max": 100,
"dimension": 2,
"seriesIndex": 0,
"right": 0,
"bottom": 0,
"inRange": {
"colorLightness": [
0.2,
0.8
]
}
}
]
}
}
]
};
export default async function run(){await mount(echarts,specification);}
查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包
- 对应变体真实运行;其数据、图元、事件或状态独立记录
类别及形状映射:独立实例
展开查看收起
import * as echarts from 'echarts';
import {mount} from './lab.js';
// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
"key": "echarts-visualmap",
"title": "ECharts visualMap:维度、通道与分段边界",
"cases": [
{
"id": "visual-continuous",
"title": "连续映射与选择",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "continuous",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
}
}
},
"behavior": "visual"
},
{
"id": "visual-split",
"title": "自动三段",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
},
"splitNumber": 3
}
}
},
{
"id": "visual-pieces",
"title": "自定义边界",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
},
"pieces": [
{
"lt": 50,
"label": "低于50"
},
{
"gte": 50,
"lte": 80,
"label": "50至80"
},
{
"gt": 80,
"label": "大于80"
}
]
}
}
},
{
"id": "visual-categories",
"title": "类别及形状映射",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
"基础"
],
[
1,
5,
"进阶"
],
[
2,
8,
"项目"
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"categories": [
"基础",
"进阶",
"项目"
],
"inRange": {
"color": [
"#2563eb",
"#db2777",
"#059669"
],
"symbol": [
"circle",
"rect",
"triangle"
]
}
}
}
},
{
"id": "visual-multiple",
"title": "第四维到第五系列及明度",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"id": "v0",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v1",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v2",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v3",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v4",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
}
],
"visualMap": [
{
"type": "continuous",
"min": 0,
"max": 100,
"dimension": 3,
"seriesIndex": 4,
"right": 0,
"top": 45,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
}
},
{
"type": "continuous",
"min": 0,
"max": 100,
"dimension": 2,
"seriesIndex": 0,
"right": 0,
"bottom": 0,
"inRange": {
"colorLightness": [
0.2,
0.8
]
}
}
]
}
}
]
};
export default async function run(){await mount(echarts,specification);}
查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包
- 对应变体真实运行;其数据、图元、事件或状态独立记录
第四维到第五系列及明度:独立实例
展开查看收起
import * as echarts from 'echarts';
import {mount} from './lab.js';
// 本章独立配置和实际运行共用;数值均为自有虚构数据。
const specification = {
"key": "echarts-visualmap",
"title": "ECharts visualMap:维度、通道与分段边界",
"cases": [
{
"id": "visual-continuous",
"title": "连续映射与选择",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "continuous",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
}
}
},
"behavior": "visual"
},
{
"id": "visual-split",
"title": "自动三段",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
},
"splitNumber": 3
}
}
},
{
"id": "visual-pieces",
"title": "自定义边界",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
20
],
[
1,
5,
50
],
[
2,
8,
80
],
[
3,
4,
95
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"min": 0,
"max": 100,
"right": 5,
"top": 50,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
},
"outOfRange": {
"opacity": 0.2
},
"pieces": [
{
"lt": 50,
"label": "低于50"
},
{
"gte": 50,
"lte": 80,
"label": "50至80"
},
{
"gt": 80,
"label": "大于80"
}
]
}
}
},
{
"id": "visual-categories",
"title": "类别及形状映射",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"name": "视觉数据",
"type": "scatter",
"data": [
[
0,
2,
"基础"
],
[
1,
5,
"进阶"
],
[
2,
8,
"项目"
]
],
"symbolSize": 14
}
],
"visualMap": {
"type": "piecewise",
"dimension": 2,
"seriesIndex": 0,
"categories": [
"基础",
"进阶",
"项目"
],
"inRange": {
"color": [
"#2563eb",
"#db2777",
"#059669"
],
"symbol": [
"circle",
"rect",
"triangle"
]
}
}
}
},
{
"id": "visual-multiple",
"title": "第四维到第五系列及明度",
"option": {
"animation": false,
"grid": {
"left": 60,
"right": 150,
"top": 45,
"bottom": 65
},
"xAxis": {
"type": "value"
},
"yAxis": {
"type": "value"
},
"series": [
{
"id": "v0",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v1",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v2",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v3",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
},
{
"id": "v4",
"type": "scatter",
"data": [
[
0,
2,
20,
20
],
[
1,
5,
50,
50
],
[
2,
8,
80,
80
]
],
"symbolSize": 12,
"itemStyle": {
"color": "#2563eb"
}
}
],
"visualMap": [
{
"type": "continuous",
"min": 0,
"max": 100,
"dimension": 3,
"seriesIndex": 4,
"right": 0,
"top": 45,
"inRange": {
"color": [
"#2563eb",
"#db2777"
],
"symbolSize": [
10,
40
]
}
},
{
"type": "continuous",
"min": 0,
"max": 100,
"dimension": 2,
"seriesIndex": 0,
"right": 0,
"bottom": 0,
"inRange": {
"colorLightness": [
0.2,
0.8
]
}
}
]
}
}
]
};
export default async function run(){await mount(echarts,specification);}
查看独立实例 ↗ 在独立页面查看源码、运行环境与工程包
- 对应变体真实运行;其数据、图元、事件或状态独立记录
本章附件与实例包
常见错误与边界检查
- 只看option或标题而未核对真实数据、图元、状态。
- 旧版本、外部数据及未运行环境被误写成已完成。
技术规范与官方资料
练习与参考解答
查看参考解答
保持图表类型、轴、维度、数据和交互对应;完整来源事实、真人键盘/触屏/读屏及其他版本仍需独立复核。