fl_chart icon indicating copy to clipboard operation
fl_chart copied to clipboard

Y axis clips chart size

Open thomasaldershof opened this issue 2 years ago • 3 comments

Describe the bug I think the picture shows pretty good what the problem is. image

To Reproduce I don't have a whole file ready to reproduce, but at least here is the widget containing the chart.

SingleChildScrollView( scrollDirection: Axis.horizontal, child: SizedBox( height: MediaQuery.of(context).size.height * 0.2, width: bars.length * 40.0, child: BarChart( BarChartData( gridData: FlGridData( show: false, ), alignment: BarChartAlignment.spaceEvenly, barTouchData: BarTouchData( enabled: true, touchTooltipData: BarTouchTooltipData( tooltipBgColor: Colors.transparent, tooltipPadding: const EdgeInsets.all(0), tooltipMargin: 6, fitInsideVertically: true, getTooltipItem: ( BarChartGroupData group, int groupIndex, BarChartRodData rod, int rodIndex, ) { return BarTooltipItem( rod.toY.round().toString(), Theme.of(context).textTheme.subtitle2!); }, ), ), titlesData: FlTitlesData( show: true, topTitles: AxisTitles( sideTitles: SideTitles(showTitles: false), ), bottomTitles: AxisTitles( sideTitles: SideTitles( showTitles: true, reservedSize: 32, getTitlesWidget: (value, meta) => Text( DateFormat("MMM\n’yy") .format(DateTime.fromMillisecondsSinceEpoch(value.round())), style: Theme.of(context).textTheme.subtitle2!, ), ), ), rightTitles: AxisTitles( sideTitles: SideTitles( interval: 500, showTitles: true, reservedSize: 60, ), ), leftTitles: AxisTitles( sideTitles: SideTitles( interval: 500, showTitles: true, reservedSize: 60, ), ), ), borderData: FlBorderData( show: false, ), barGroups: bars, maxY: [...bars] .sorted((a, b) => a.barRods.first.toY.compareTo(b.barRods.first.toY)) .last .barRods .first .toY + 300, ), ),

Versions

  • which version of the Flutter are you using? 3.3.9
  • which version of the FlChart are you using? 0.55.2

If you need for more information please reach out.

thomasaldershof avatar Dec 10 '22 21:12 thomasaldershof

Hi. I couldn't understand what is happening. Please provide a reproducible code and explain more about it.

imaNNeo avatar Jan 15 '23 14:01 imaNNeo

You have no padding for SingleChildScrollView. SingleChildScrollView has a property padding, try adding some padding to the property.

horgag avatar Jan 30 '23 19:01 horgag

I also have the same problem. I fixed it by add topTitles: AxisTitles( sideTitles: SideTitles(showTitles: false, reservedSize: 24, getTitlesWidget: (value, meta) => const SizedBox())) to titlesData tag.

viphoamt avatar Feb 06 '24 06:02 viphoamt