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