3

enter image description here LineChart(

    LineChartData(
    minX: 0,
    maxX: 40,
    minY: 0,

    lineBarsData: [
    LineChartBarData(

    spots: fl,
    isCurved: true,
    barWidth: 5,
    )
    ]
    )

),

here is my code values on x axis are overlapping. I am using fl_charts for flutter is there any option to specify intervals between axis value?

Hamza Ali
  • 272
  • 4
  • 9

1 Answers1

2
LineChartData(
  minX: 0,
  maxX: 40,
  gridData: FlGridData(
    show: false,
  ),
  titlesData: FlTitlesData(
    bottomTitles: SideTitles(
      showTitles: true,
      reservedSize: 22,
      getTextStyles: (value) => const TextStyle(
        color: CColors.pink,
        fontWeight: FontWeight.bold,
        fontSize: 16,
      ),
      margin: 10,
      getTitles: (value) {
        if (value.toInt() % 5 == 0) {
          return '${value.toInt()}';
        } else {
          return '';
        }
      },
    ),
    leftTitles: SideTitles(
      showTitles: true,
      getTextStyles: (value) => const TextStyle(
        color: CColors.pink,
        fontWeight: FontWeight.bold,
        fontSize: 14,
      ),
      getTitles: (value) {
        if (value.toInt() % 25 == 0) {
          return '${value.toInt()}';
        } else {
          return '';
        }
      },
      margin: 8,
      reservedSize: 30,
    ),
  ),
  borderData: FlBorderData(
    show: true,
  ),
  lineBarsData: [
    LineChartBarData(
      spots: fl,
      colors: [CColors.pink],
      barWidth: 5,
    ),
  ],
),
Abion47
  • 22,211
  • 4
  • 65
  • 88
Toqeer Yousaf
  • 382
  • 4
  • 9