Axis
Last updated
Last updated
The picture below reveals the composition of our axes:
chart.axis(false)
Close all axes.
chart.axis(field, false)
field
: String type, the data field name corresponding to the axis
Do not render the axis corresponding to the field.
chart.axis(field, config)
field
: String type, the data field name corresponding to the axis
config
: Object type, configuration for the axis. It can be used to configure each component of the axis: include label, line, tick, tickLine and grid.The properties included are as follows:
Name
Type
Default
Description
line
Object / null
{ stroke: '#e8e8e8', lineWidth: 1 }
labelOffset
Number
7.5
The distance between the axis label and axis line
grid
Object/Function/null
{ type: 'line', stroke: '#e8e8e8', lineWidth: 1, lineDash: [ 2 ] }
tickLine
Object/null
null
label
Object/Function/null
{ fill: '#808080', fontSize: 10 }
position
String
'left'
Configuration for the position of the Y-axis. X-axis defaults to 'bottom', the position of y-axis can be set to 'left' or 'right'.
top
Boolean
false
Used to adjust the layer level. true
represents the top layer level, false
means the bottom layer level.
line
, grid
, label
, tickLine
all have a property top
which is used to adjust the display layer, true
represents the top layer, false
means the bottom layer level.
Note: When grid and label are callback functions, the return values must be an object.
If you want to change the axis label to include information about the data type, you can define a callback function for label. In the following example, every label of the Y axis would be formatted as a percentage, and if the value is greater than zero, the font color will be red, equal to zero is black, and less than zero is green.
If the callback returns null
or undefined
the label and the associated grid line will be hidden.
See detailed demo: here.
Same as label. The following example will highlight the grid line which the value is zero.
See detailed demo: here.
Demo
The axis line's configuration. The axis line is not displayed when line
set to null
. It supports all html5 canvas's line attributes, see for more details.
The axis grid's configuration. The grid is not displayed when grid
is set to null
. It supports all html5 canvas's line attributes, see for more details.
If gird is a function type, see
The configuration for style of the tickLine in axis. The tickLine of axis is not displayed when tickLine
is set to null
. It supports all html5 canvas's line attributes, see for more details.
Configuration for label of the axis. The labek of the axis is not displayed when label
is set to null
. It supports all html5 canvas's attributes, see for more details.
If label is a function type, see