Purpose
Visual Map enables data-driven visual encoding, allowing you to represent data magnitude through colors, sizes, or other visual channels. Based on~/workspace/source/src/component/visualMap/VisualMapModel.ts, it supports both continuous gradients and discrete categorical mappings.
Types
ECharts provides two types of Visual Map components:- Continuous: Maps data to a continuous color gradient or size range
- Piecewise: Divides data into discrete pieces with distinct visual properties
Basic Usage
Continuous Visual Map
Piecewise Visual Map
Common Configuration
Type of the visual map component.
Whether to display the visual map component.
Minimum value for the visual mapping range.
Maximum value for the visual mapping range.
Specifies which dimension of the data to map. If not specified, the last dimension is used.
Specifies which series the visual map applies to. Can be a single index, array of indices, or ‘all’.
Advanced option for targeting specific dimensions in specific series.
Visual properties for data within the selected range.
Visual properties for data outside the selected range.
Orientation of the visual map component.
Whether to inverse the component.
Number of decimal places for displayed values.
Width of the visual map item in pixels.
Height of the visual map item in pixels.
Text labels for both ends of the visual map, such as
['High', 'Low'].Gap between text and the visual map item.
Formatter for the label text. Can be a template string or function.
Position
Distance from the left side of the container.
Distance from the top of the container.
Distance from the right side of the container.
Distance from the bottom of the container.
Padding inside the component. Can be a single number or array
[top, right, bottom, left].Continuous Visual Map
From~/workspace/source/src/component/visualMap/ContinuousModel.ts, continuous visual maps provide smooth gradients.
Selected range for continuous visual map, defaults to
[min, max].Whether to show handles to allow interactive range adjustment.
Whether to update the chart in real-time while dragging handles.
Whether to enable hover highlighting of data related to the hovered visual map item.
When
range touches min or max, whether to treat it as unbounded:true:range[0] <= minbecomes[-Infinity, range[1]]false: Range is strictly bounded
SVG path for the handle icon.
Size of the handle, can be a percentage of item width.
Style configuration for the handles.
Piecewise Visual Map
From~/workspace/source/src/component/visualMap/PiecewiseModel.ts, piecewise visual maps divide data into discrete ranges.
Array of piece definitions. Each piece can define a range and visual properties.
Category names for categorical data mapping.
When pieces are not specified, split the data range into this many equal pieces.
Which pieces are selected. Object keys are piece indices or category names.
Selection mode:
'multiple': Allow multiple pieces to be selected'single': Only one piece can be selected at a timefalse: Disable selection
Symbol shape for piecewise items.
Gap between items in pixels.
Whether to enable hover highlighting.
Examples
Heatmap with Continuous Visual Map
Scatter Plot with Piecewise Visual Map
Multiple Series with Series Targets
Implementation Details
From~/workspace/source/src/component/visualMap/VisualMapModel.ts:179-700, the Visual Map component:
- Dependencies: Requires series components to function
- Visual Properties: Supports color, symbolSize, opacity, and other visual channels
- Data Extent: Automatically calculates from specified min/max values
- Target Selection: Can target specific series and dimensions
- State Management: Maintains inRange and outOfRange visual states
- Interactive: Supports selection and hover interactions