Search code examples
flutterdartfl-chart

Flutter fl_chart limit amount of titles on x axis


Is it possible to limit the amount of shown titles on the x axis (e.g. max 3 titles) to avoid that titles overlap like in the picture? enter image description here


Solution

  • You can use the bottomTitles parameter when creating your LineChartData object to specify an interval.

    bottomTitles: AxisTitles(
        sideTitles: SideTitles(
            showTitles: true,
            interval: 10,
        ),
    ),
    

    If you want even more control, you can specify a functor for the getTitlesWidget parameter to control exactly which values are labeled and how they're styled.

    Take a look at the code sample for Sample 1 here.