[英]Flutter Charts How do I rotate the X axis?
Example Image How can I only rotate the x axis on the bar chart? 示例图像如何仅旋转条形图上的x轴? I used labelRotationAngle to do it with the Kotlin language. 我使用labelRotationAngle来使用Kotlin语言。 Is it possible to do this with Flutter?. Flutter是否可以执行此操作? Thank you for your help. 谢谢您的帮助。
charts.BarChart(
_createDataForChart(key, city_name),
animate: true,
behaviors: [new charts.PanAndZoomBehavior()],,
)
List<charts.Series<priceChart,String>> _createDataForChart(key, city_name){
return [
new charts.Series<priceChart, String>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (priceChart sales, _) => sales.date,
measureFn: (priceChart sales, _) => sales.price,
data: data,
)
]
}
U can use the domainAxis with renderSpec to achieve this. U可以将domainAxis与renderSpec配合使用来实现此目的。 Example Code here: 示例代码在这里:
charts.BarChart(
seriesList,
animate: animate,
domainAxis: new charts.OrdinalAxisSpec(
renderSpec: charts.SmallTickRendererSpec(
//
// Rotation Here,
labelRotation: 45,
),
),
)
45 degree is the best one yet. 45度是最好的。 if u go 90 it will shrink the chart. 如果您转到90,它将缩小图表。 but you can use labelAnchor: charts.TickLabelAnchor.before
with labelRotation: -90
to achieve what you want. 但您可以在labelRotation: -90
使用labelAnchor: charts.TickLabelAnchor.before
。来实现所需的功能。 Example code: 示例代码:
charts.BarChart(
seriesList,
animate: animate,
domainAxis: new charts.OrdinalAxisSpec(
renderSpec: charts.SmallTickRendererSpec(
// Rotation Here,
labelRotation: -90,
labelAnchor: charts.TickLabelAnchor.before,
),
),
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.