Guide
Line | Text | Rect | Point | Tag | RegionFilter | Arc | Html |
Guide component is used for annotations of chart. In F2, annotations are driven by data. Being driven by data means that the aesthetics of an annotation object are linked to variables in a dataset in a similar manner to that for a graphic. A text annotation, for example, might be positioned according to a value of a variable, or its color might be determined by a variable value, or its content might be determined by statistical parameters.
We provide 8 types of guide components, we will introduce them and their usage below.
How to Register Guide Plugin
F2 has modular structure provides best tree-shaking results and package size optimization.
If you just import F2 from '@antv/f2'
, then it has included 6 types Guide by default, they are Arc, Html, Line, Rect, Tag and Text. But if you want a better package size optimization, you can register manually:
If you want to use all types of guide, you can:
or you just want to use several types, you can:
Line
Example Usage
Properties
The global options for the chart guide line is defined in F2.Global.guide.line.
Name | Type | Default | Description |
| Boolean | true | Wether draw the guide line to the top layer of the canvas, defaults to true. |
| Array/Function | Starting position of the guide line. Detail usage see here. | |
| Array/Function | Ending point of guide line, use the same way as | |
| Object | Style for guide line, see Canvas(todo) for more details. |
Text
Example Usage
Properties
The global options for the chart guide text is defined in F2.Global.guide.text.
Name | Type | Default | Description |
| Boolean | true | Wether draw the guide text to the top layer of the canvas, defaults to true |
| Array/Function | Position of the guide text, see detail usage here. | |
| String | text content | |
| Object | text style | |
| Number | 0 | offset of guide text in x-axis |
| Number | 0 | offset of guide text in y-axis |
Tag
Example Usage
Properties
The global options for the chart guide tag is defined in F2.Global.guide.tag.
Name | Type | Default | Description |
| Boolean | true | Wether draw the guide tag to the top layer of the canvas, defaults to true |
| Array/Function | Position of the guide tag, see detail usage here. | |
| String | tag content, if you want a text wrapping, just write '\n' in the text, such as 'maximum \n200'. | |
| String | 'tl' | direction of tag, if |
| Boolean | true | If value is |
| Number | 4 | The length of tag arrow. |
| Object | text style | |
| Number | 0 | offset of guide tag in x-axis |
| Number | 0 | offset of guide tag in y-axis |
| Object | The background style of guide tag. See below. | |
| Object | style for tag's label. | |
| Boolean | true | wether to draw a point at the dataset. |
| Object | If the |
direct
direct
backgroud
configuration
backgroud
configurationRect
Example Usage
Properties
The global options for the chart guide rect is defined in F2.Global.guide.rect.
Name | Type | Default | Description |
| Boolean | false | Wether draw the guide rect to the top layer of the canvas, defaults to false. |
| Array/Function | Starting position of the guide tag, see detail usage here. | |
| Array/Function | Ending position of the guide tag, see detail usage here. | |
| Object | rect box style |
Point
Example Usage
Properties
The global options for the chart guide point is defined in F2.Global.guide.point.
Name | Type | Default | Description |
| Boolean | true | Wether draw the guide point to the top layer of the canvas, defaults to true |
| Array/Function | Position of the guide point, see detail usage here. | |
| Object | point style | |
| Number | 0 | offset of guide point in x-axis |
| Number | 0 | offset of guide point in y-axis |
Arc
Works in polar coordinate.
Example Usage
Properties
The global options for the chart guide arc is defined in F2.Global.guide.arc.
Name | Type | Default | Description |
| Boolean | true | Wether draw the guide arc to the top layer of the canvas, defaults to true |
| Array/Function | starting position of the guide arc, see detail usage here. | |
| Array/Function | ending position of the guide arc, see detail usage here. | |
| Object | arc style |
RegionFilter
Example Usage
Properties
The global options for the chart guide regionFilter is defined in F2.Global.guide.regionFilter.
Name | Type | Default | Description |
| Array/Function | starting position of the guide regionFilter, see detail usage here. | |
| Array/Function | ending position of the guide regionFilter, see detail usage here. | |
| String | the filled color for the filtered region. | |
| Object | additional style settings for the shape in the filter region. |
Html
Example Usage
Properties
The global options for the chart guide html is defined in F2.Global.guide.html.
Name | Type | Default | Description |
| Array/Function | position of the guide html, see detail usage here. | |
| String | html code that needs to be displayed | |
| String | 'center' | alignment of html in horizontal direction, can be set to: 'left', 'center', 'right', defaults to 'center' |
| String | 'middle' | alignment of html in vertical direction, can be set to: 'top', 'middle', 'bottom', defaults to 'middle' |
| Number | 0 | offset of the guide html in x-axis |
| Number | 0 | offset of the guide html in y-axis |
start
, end
, position
usage
start
, end
, position
usageThe values of the three parameters passed in can be following type:
Array,the value in the array can be the data in dataset, or can be percentage, or keyword(they are 'max', 'min', 'median')
Function: Callback can used to dynamically locate the position. It is often used in the scenario where position of the guide element changes according to the change of the data. Detail demo and code here.
Repaint a guide component
guide.repaint()
How to clear guides
Last updated