Search code examples
flutterdartsyncfusion

how to flutter syncfusion bar chart background grid line delete?


how to flutter syncfusion bar chart background grid line delete?

use pub.dev // syncfusion_flutter_charts 19.4.56 https://pub.dev/packages/syncfusion_flutter_charts

< image grid line (grey color line) >

enter image description here

my code

return SfCartesianChart(
  title: ChartTitle(text: totalTaxString, textStyle: const TextStyle(fontWeight: FontWeight.bold)),
  primaryXAxis: CategoryAxis(
    maximumLabelWidth: MediaQuery.of(context).size.width > 480 ? MediaQuery.of(context).size.width * 0.3 : 100,
    labelStyle: const TextStyle(overflow: TextOverflow.ellipsis)
    // isVisible: false
  ),
  primaryYAxis: CategoryAxis(    
    isVisible: false
  ),
  series: <BarSeries>[
    BarSeries<ModelPioChartData, String>(
      dataSource: listPioChartData,
      pointColorMapper:(ModelPioChartData data, _) => data.color,
      xValueMapper: (ModelPioChartData data, _) => data.x,
      yValueMapper: (ModelPioChartData data, _) => data.y,
      dataLabelMapper: (ModelPioChartData data, _) {
        if(data.y.toStringAsFixed(0).length > 4) {
          return "${data.y/10000}조 원";
        } else {
          return "${data.y.toStringAsFixed(0)}억 원";
        }
        
      },

      dataLabelSettings: const DataLabelSettings(
        isVisible: true
      ),
      enableTooltip: true,
      
    ),
  ],
);

Solution

  • I suggest you use the majorGridLines property in the axis, you can customize the width, color, and size of the major grid line. We have attached the code snippet and UG below for your reference.

    primaryXAxis:
       CategoryAxis(
         majorGridLines: const MajorGridLines(width: 0)
      ),
    

    UG: https://help.syncfusion.com/flutter/cartesian-charts/axis-customization#grid-lines-customization