Purpose
Based on the source implementation in~/workspace/source/src/component/toolbox/ToolboxModel.ts, the toolbox component:
- Provides interactive tools as clickable icons
- Supports built-in features like save as image, data view, data zoom, restore, and magic type
- Allows custom tool creation and configuration
- Positioned flexibly within the chart container
- Displays tooltips for tool descriptions
Basic Usage
Save as Image Feature
From~/workspace/source/src/component/toolbox/feature/SaveAsImage.ts:
Data Zoom Feature
From~/workspace/source/src/component/toolbox/feature/DataZoom.ts:
Magic Type Feature
Styled Toolbox
Configuration Options
Core Properties
Whether to display the toolbox component. From
ToolboxModel.ts:113.Layout orientation of toolbox items. From
ToolboxModel.ts:119.Distance from the left side of the container. Default positions toolbox on the right.From
ToolboxModel.ts:121.Distance from the top of the container. From
ToolboxModel.ts:123.Distance from the right side of the container.
Distance from the bottom of the container.
Item Layout
Size of toolbox icons in pixels. From
ToolboxModel.ts:138.Gap between toolbox items. From
ToolboxModel.ts:140.Whether to show title (tooltip) when hovering over tools. From
ToolboxModel.ts:142.Background and Border
Background color of the toolbox. From
ToolboxModel.ts:128.Border color of the toolbox container. From
ToolboxModel.ts:130.Border width of the toolbox in pixels. From
ToolboxModel.ts:134.Border radius of the toolbox container. From
ToolboxModel.ts:132.Padding inside the toolbox. Can be single number or array [top, right, bottom, left].From
ToolboxModel.ts:136.Icon Styling
Style configuration for toolbox icons. From
ToolboxModel.ts:144-147:Style configuration for hovered/emphasized icons. From
ToolboxModel.ts:148-152:Tooltip
Tooltip configuration for toolbox items. From
ToolboxModel.ts:157-160:Built-in Features
Dictionary of toolbox features to enable. Each feature has its own configuration.See
ToolboxModel.ts:83 for the feature type definition.Save as Image
From~/workspace/source/src/component/toolbox/feature/SaveAsImage.ts:
Image format for export. SVG is automatically used if chart uses SVG renderer.
Filename for the downloaded image (without extension).Falls back to chart title or ‘echarts’. See
SaveAsImage.ts:49.Background color for the exported image. Defaults to chart background.From
SaveAsImage.ts:54-55.Array of component types to exclude from the export. Default excludes toolbox.See
SaveAsImage.ts:138.Pixel ratio for the exported image. Higher values create higher resolution images.From
SaveAsImage.ts:58.Data Zoom
From~/workspace/source/src/component/toolbox/feature/DataZoom.ts:
Data filtering mode when zooming. From
DataZoom.ts:207.X-axis indices to control with data zoom. ‘all’ controls all x-axes.
Y-axis indices to control with data zoom.
Style for the brush selection area. From
DataZoom.ts:215-218:Custom icons for zoom and back buttons. From
DataZoom.ts:209-212:Custom titles for zoom and back buttons:
Other Features
Data view feature for displaying raw data in a table format:
Restore feature to reset chart to initial state:
Magic type feature for switching between chart types:
Brush selection feature for selecting data regions:
Feature Management
The toolbox uses a feature manager system (fromToolboxModel.ts:100-108) that:
- Automatically merges default options for each feature
- Supports custom feature registration
- Handles feature initialization and option updates