When to Use Custom Charts
The custom series type provides maximum flexibility when built-in chart types don’t meet your needs. Use custom charts for:- Unique visualizations: Creating chart types not available in ECharts by default
- Complex graphics: Building visualizations that combine multiple shapes and elements
- Custom interactions: Implementing specialized hover, click, or animation behaviors
- Business-specific displays: Designing charts that match specific business domain requirements
- Advanced layouts: Creating custom positioning and arrangement logic for data elements
renderItem function, allowing you to build virtually any visualization.
Basic Configuration
A custom chart uses thetype: 'custom' series option with a renderItem function:
Complete Working Example
Here’s a custom series that creates a custom error bar chart:The renderItem Function
TherenderItem function is called for each data item and returns a graphic element configuration.
Parameters
API Methods
Return Value: Element Options
TherenderItem function returns an element option object describing what to render.
Element Types
Custom series supports multiple graphic element types:Group
Container for multiple elements:Path Shapes
Built-in path shapes:Circle
Rectangle
Sector (Pie slice)
Line
Polygon
Polyline
Arc
Ring
SVG Path
Custom path from SVG path data:Image
Text
Common Element Properties
Transform
All elements support transform properties:Style
States
Elements can have different styles for emphasis, blur, and select states:Animation
Transition
Specify which properties should animate:Enter/Update/Leave Animations
During Callback
Execute code during animation:Coordinate System Integration
Custom series can work with any coordinate system:Cartesian (Default)
Polar
None (Absolute positioning)
Context for Persistent State
Useparams.context to maintain state across render calls:
Encoding Dimensions
Theencode option maps data dimensions to coordinate system axes:
Clipping
clip
Type: booleanDefault:
false
Whether to clip elements outside the coordinate system’s boundaries. By default, custom series does not clip.
Source: ~/workspace/source/src/chart/custom/CustomSeries.ts:402, 436