Axis Labels
The only missing element of our basic chart structure are Axis Labels. These are labels you would like to display on each interval tick along the axis.
To display interval labels along the axes, we will use the axisLabels
property on any Cartesian Chart.
AxisLabels
The property axisLabels
requires a AxisLabelConfig
for each individual axis. If the config is not provided, then interval labels won't be rendered for those axes.
Let's dive deeper into the AxisLabelConfig
that's been provided to left and bottom edges.
AxisLabelConfig
Each config must implement the mandatory builder
method. This method provides the index
of that iteration, and the value
of the interval that has been processed with the Unit Values. Finally, it must return a widget that will be displayed as the label.
Because the label consumes a widget, you have the complete freedom to provide even images or icons if you choose.
Additionally, there are two more properties that can help you position your labels better.
If you wish to have your labels positioned in the center of the unit interval, you can set the value of centerLabels
property to true.
And you can constrain the labels at the edges of each axis to fit within the axis range.
Class Properties
builder
Widget Function(int, double)
true
--
centerLabels
bool
false
false
constraintEdgeLabels
bool
false
false
This concludes our section to structure and customize the Cartesian Grid and Axes elements.
Last updated