颤振图:^0.1.10
https://pub.dev/packages/charts_flutter
https://pub.dev/documentation/charts_flutter/latest/flutter/BarChart-class.html
我想设置条形图的固定宽度并且需要滚动水平 x 轴。所以可能吗?
import 'package:charts_flutter/flutter.dart' as charts;
final data = [
new OrdinalSales('2014', random.nextInt(100)),
new OrdinalSales('2015', random.nextInt(100)),
new OrdinalSales('2016', random.nextInt(100)),
new OrdinalSales('2017', random.nextInt(100)),
new OrdinalSales('2018', random.nextInt(100)),
new OrdinalSales('2019', random.nextInt(100)),
new OrdinalSales('2020', random.nextInt(100)),
new OrdinalSales('2021', random.nextInt(100)),
new OrdinalSales('2022', random.nextInt(100)),
new OrdinalSales('2023', random.nextInt(100)),
];
...
@override
Widget build(BuildContext context) {
return new charts.BarChart(
seriesList,
animate: animate,
);
}
...
Run Code Online (Sandbox Code Playgroud)
为什么不使用您想要的列宽来计算父宽度应该是多少?用 包裹图表SizedBox,用水平包裹SingleChildScrollView。将宽度设置SizedBox为例如。1.5 * desiredColumnWidth * columnCount. 我不知道列之间的确切填充,但从视觉上看,它大约是列宽的一半。