google / charts

https://pub.dev/packages/charts_flutter
Apache License 2.0
2.81k stars 1.23k forks source link

any clue to reduce space between bar? #382

Open azamcsc opened 4 years ago

azamcsc commented 4 years ago

2020_01_18_04_08_51 1

huangsir0 commented 4 years ago

How to change bar's width?

huangsir0 commented 4 years ago

the smaller the parent widget height,the smaller space.

huffSamuel commented 4 years ago

You can changed the width of the bars by adding a FixedPixelOrdinalScaleSpec to your domain axis:

import 'package:charts_common/common.dart' as commonCharts;

...

final barWidth = 45.0;

return charts.BarChart(
  domainAxis: charts.OrdinalAxisSpec(
    scaleSpec: commonCharts.FixedPixelOrdinalScaleSpec(barWidth),
  ),
  ...
);

Or alternatively you can set the space between the bars by using a FixedPixelSpaceOrdinalScaleSpec:

import 'package:charts_common/common.dart' as commonCharts;

...

final spaceBetweenBars = 120.0;

return charts.BarChart(
  domainAxis: charts.OrdinalAxisSpec(
    scaleSpec: commonCharts.FixedPixelOrdinalScaleSpec(spaceBetweenBars),
  ),
  ...
);