Shape
F2.Shape
F2.Shape
F2.Shape provide an ability to customize shapes. With this, we can create a lot of interesting charts.
How to register
The explanation of the main methods are described below:
getPoints(pointInfo)
getPoints(pointInfo)
getPoints
is used to calculate the key points of each shape. Each shape in F2 is connected by a number of key points.
Parameters:
pointInfo
: Object
The values of the pointInfo are all normalized (range from 0 to 1), and the structure of the pointInfo
is shown below:
The following table lists the key point information mechanisms for each geometry shape in F2:
geom type
Explanation
point
line
area
interval
polygon
schema
draw(cfg, container)
draw(cfg, container)
getPoints
used to calculate the key points of each shape, so the draw
method is used to define how the points are connected and construct a shape.
NOTE: the draw
method must return the shape instance.
Parameters
cfg
: Object
This parameter contains all the data after mapping and corresponding raw data. The structure of the parameter is shown below:
1. The original data is store in cfg.origin._origin
2. The key points that calculated by getPoints
is stored in points
3. color
, size
and shape
in cfg
are all graph attributes after mapping and can be used directly.
container
: F2.G.Group instance, the container for shapes.
It is a container. The customized shape must first be added to the container.
In addition, we provide some utility methods to help users quickly convert normalized data to canvas coordinates. You can call these methods in the above two methods:
parsePoint(point)
parsePoint(point)
Convert the point in the range of [0, 1] to the actual coordinate on the canvas.
Parameters:
point
: Object
The structure of the point is shown below:
parsePoints(points)
parsePoints(points)
Convert the points in the range of [0, 1] to the actual coordinates on the canvas.
The structure of points:
Code Demo
Last updated