简体   繁体   English

如何在 flutter 中创建堆叠的时间序列条形图?

[英]How to create a stacked time-series bar chart in flutter?

I was working around graphs and am looking for a way to create a graph with its x-axis as percentage (0-100%) and y-axis as DateTime.我正在处理图表,并正在寻找一种方法来创建一个图表,其 x 轴为百分比 (0-100%),y 轴为 DateTime。

I'm able to draw time series bar chart like this, but its not stacked.我可以像这样绘制时间序列条形图,但它没有堆叠。 时间序列条形图

Or I can draw a simple stacked bar chart, but its x-axis is string and not DateTime.或者我可以画一个简单的堆积条形图,但它的 x 轴是字符串而不是 DateTime。

Is there a way I can customise a chart like this to fit in my scenario.有没有办法可以自定义这样的图表以适合我的场景。

To get a rough idea, please check out this note.要大致了解一下,请查看此说明。 粗略的想法

Let me know if you need any more info.如果您需要更多信息,请告诉我。 Thanks in advance.提前致谢。

In case anybody gets stuck here in future, I was able to do what I wanted to, using the following library.万一将来有人被困在这里,我可以使用以下库做我想做的事。 Its presents data beautifully and brilliantly.它精美而精彩地呈现数据。 Also, it provides a good variety of graphs.此外,它还提供了多种图表。

SyncFusion Flutter Charts - https://www.syncfusion.com/flutter-widgets/flutter-charts/chart-types SyncFusion Flutter 图表 - https://www.syncfusion.com/flutter-widgets/flutter-charts/chart-types

You can pass a BarGroupingType widget to the groupingType argument of the BarRendererConfig.您可以将 BarGroupingType 小部件传递给 BarRendererConfig 的 groupingType 参数。 Not well documented, but you can find it if you dig into the source code of the BarRendererConfig.没有很好的文档记录,但是如果您深入研究 BarRendererConfig 的源代码,您可以找到它。

The below code snippet is adapted from: https://google.github.io/charts/flutter/example/time_series_charts/with_bar_renderer以下代码片段改编自: https://google.github.io/charts/flutter/example/time_series_charts/with_bar_renderer

Widget build(BuildContext context) {
return new charts.TimeSeriesChart(
  data,
  animate: true,
  defaultRenderer: new charts.BarRendererConfig<DateTime>(
    groupingType: charts.BarGroupingType.stacked, \\ add this
  ),
);

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM