imaNNeo / fl_chart

FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
https://flchart.dev
MIT License
6.77k stars 1.74k forks source link

Is the interval of SideTitles invalid for BarChart? #1619

Open GanZhiXiong opened 6 months ago

GanZhiXiong commented 6 months ago

see BarChartSample9 in https://zapp.run/edit/flutter-zphk0684phl0?entry=lib/main.dart&file=lib/bar_chart_sample9.dart

image

BarChartData(
          titlesData: FlTitlesData(
              bottomTitles: AxisTitles(
                  sideTitles: SideTitles(
                    showTitles: true,
            interval: 3,
            getTitlesWidget: (value, meta) {
              return Text('$value');
            },
          ))),
imaNNeo commented 4 months ago

Yes, basically, we don't consider the interval for the bottom titles, we just show them on the bottom of Rods. But I agree we need to fix it

vd3d commented 1 month ago

Ah great to know, I was looking for a fix. For now I have a lot of datas displayed in the bottom and so the chart is very slow :-( Hope you will find some time to fix it :-)

PS: btw, fl_chart is amazing... great work

vd3d commented 1 month ago

BTW, I fix it like this (It is not elegant, but seems to work)

SideTitles bottomTitles = SideTitles(showTitles: true, interval: _intervalSize, getTitlesWidget: _getBottomTitle, reservedSize: 32);

Widget _getBottomTitle(double value, TitleMeta meta) { if (value % _intervalSize != 0) return Container();

...

}