Canvas API in F2
Last updated
Last updated
Since F2 use html5 canvas as its renderer, all charts drawn support the attributes of the canvas. This chapter lists commonly used properties, see Canvas Attributes for more details.
Name
Description
fill
fillStyle
same as fill
stroke
strokeStyle
same as stroke
shadowColor
the color of the shadow.
shadowBlur
shadowOffsetX
shadowOffsetY
opacity
globalOpacity
same as opacity
.
globalCompositionOperation
For the convenience of users, F2 provides support for two types of gradient color:
Linear gradient
Radial gradient
Name
Description
lineCap
lineJoin
lineWidth
miterLimit
lineDash
Name
Description
textAlign
textBaseline
fontStyle
fontSize
fontFamily
fontWeight
fontVariant
lineHeight
roate
rotation angle for text, should be a radian value.
the color or style to use inside shapes, can be a color string, a object (a linear or radial gradient) or a object (a repetitive image).
the color or style to use for the lines around shapes, can be a color string, a object (a linear or radial gradient) or a object (a repetitive image).
the level of the blurring effect; this value doesn't correspond to a number of pixels and is not affected by the current transformation matrix. The default value is 0. Negative, or values are ignored.
the distance that the shadow will be offset in horizontal distance.The default value is 0. or values are ignored.
the distance that the shadow will be offset in vertical distance. The default value is 0. or values are ignored.
the alpha value that is applied to shapes and images before they are drawn onto the canvas. The value is in the range from 0.0 (fully transparent) to 1.0 (fully opaque).Values outside the range, including and will not be set and globalAlpha
will retain its previous value.
sets the type of compositing operation to apply when drawing new shapes, where type is a string identifying which of the compositing or blending mode operations to use. See .
determines how the end points of every line are drawn. There are three possible values for this property and those are: butt
, round
and square
. By default this property is set to butt
. See .
determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together (degenerate segments with zero lengths, whose specified endpoints and control points are exactly at the same position, are skipped). See .
sets the thickness of lines in space units. When getting, it returns the current value (1.0
by default). When setting, zero, negative, and values are ignored; otherwise the current value is set to the new value. See .
sets the miter limit ratio in space units. When getting, it returns the current value (10.0
by default). When setting, zero, negative, and values are ignored; otherwise the current value is set to the new value. See .
An of numbers which specify distances to alternately draw a line and a gap (in coordinate space units). If the number of elements in the array is odd, the elements of the array get copied and concatenated. For example, [5, 15, 25]
will become [5, 15, 25, 5, 15, 25]
. If the array is empty, the line dash list is cleared and line strokes return to being solid.
specifies the horizontal alignment of text in an element. The value can be set same as css property .
sets the vertical alignment of an element. The value can be set same as css property .
specifies the font style for text. The value can be set same as css property .
specifies the font size of text. The value can be set same as css property .
specifies the font family for text.The value can be set same as css property .
specifies the weight of a font. The value can be set same as css property .
specifies whether or not a text should be displayed in a small-caps font. The value can be set same as css property .
specifies the height of a line. The value can be set same as css property .