Purpose
The Title component serves as the primary heading for your chart, providing context and description for the data visualization. Based on the source code at~/workspace/source/src/component/title/install.ts, it renders text elements with configurable layout, styling, and interactive features.
Basic Usage
Configuration Options
Whether to display the title component.
The main title text to display.
URL to navigate to when the title is clicked.
Specifies where to open the linked URL:
'self'- Opens in the same window'blank'- Opens in a new window/tab
Subtitle text displayed below the main title.
URL to navigate to when the subtitle is clicked.
Specifies where to open the subtitle link.
Horizontal alignment of the title text. If not specified, it aligns based on the
left or right positioning.Vertical alignment of the title text. If not specified, it aligns based on the
top or bottom positioning.Padding between text and border. Can be:
- A single number:
5(applies to all sides) - An array:
[5, 10](vertical, horizontal) or[5, 10, 5, 10](top, right, bottom, left)
Gap between the main title and subtitle, in pixels.
Background color of the title component. Supports color strings, hex values, and rgba.
Border color of the title component.
Width of the title border in pixels.
Radius of the background border corners. Can be a single number or an array for different corners.
Whether to trigger mouse or touch events on the title component.
Position
Horizontal position. Can be:
'left','center','right'- Absolute pixel value:
20 - Percentage:
'20%'
Vertical position. Can be:
'top','middle','bottom'- Absolute pixel value:
20 - Percentage:
'20%'
Distance from the right side of the container.
Distance from the bottom of the container.
Text Style
Style configuration for the main title text.
Style configuration for the subtitle text.
Examples
Centered Title with Subtitle
Title with Link
Styled Title with Background
Multiple Titles
Implementation Details
From~/workspace/source/src/component/title/install.ts:100-139, the Title component includes:
- Layout Mode: Box layout with size ignored
- Z-index: Defaults to 6, ensuring title appears above most chart elements
- Text Rendering: Uses ZRender Text elements with full styling support
- Click Events: Supports link navigation with configurable target windows
- Auto-alignment: Automatically determines text alignment based on position if not explicitly set
- Background: Optional background rectangle with border and border radius support