multiLevelLabelFormatter property

MultiLevelLabelFormatterCallback? multiLevelLabelFormatter
final

Called while rendering each multi-level label.

Provides label text, the actual level of the label, index, and text styles such as color, font size, etc using MultiLevelLabelRenderDetails class.

You can customize the text and text style using ChartAxisLabel class and can return it.

Defaults to null.

Widget build(BuildContext context) {
  return Container(
    child: SfCartesianChart(
      primaryXAxis: NumericAxis(
        multiLevelLabelFormatter: (MultiLevelLabelRenderDetails details) {
          if (details.index == 1) {
            return ChartAxisLabel('Text', details.textStyle);
          } else {
            return ChartAxisLabel(details.text, details.textStyle);
          }
        },
        multiLevelLabels: const <NumericMultiLevelLabel>[
          NumericMultiLevelLabel(
            start: 0,
            end: 2,
            text: 'First'
          ),
          NumericMultiLevelLabel(
            start: 2,
            end: 4,
            text: 'Second'
          )
        ]
      )
    )
  );
}

Implementation

final MultiLevelLabelFormatterCallback? multiLevelLabelFormatter;