简体   繁体   English

是否可以使用 charts_flutter 绘制带有值流的实时图表?

[英]Is possible to use charts_flutter to draw a real-time chart with a stream of values?

I haven't found an example where charts_flutter has been used using a data stream that changes over time.我还没有找到使用随时间变化的数据流使用 charts_flutter 的示例。 Is it possible to do it, or is it not the right tool?是否有可能做到,或者它不是正确的工具? In my case, I have to show a line graph that follows the signals from microphone.就我而言,我必须显示一个跟随麦克风信号的折线图。 Thanks谢谢

UPDATE This is my attempt: inside my build() method I defined the chart like this:更新这是我的尝试:在我的 build() 方法中,我定义了这样的图表:

charts.TimeSeriesChart(
              getStreamData(),
              animate: true,
              domainAxis: new charts.OrdinalAxisSpec(renderSpec: new charts.NoneRenderSpec(), showAxisLine: false),
              primaryMeasureAxis: new charts.NumericAxisSpec(showAxisLine: false),
              dateTimeFactory: const charts.LocalDateTimeFactory(),

where my goal is consuming a data stream, and set a fixed range of measurements axis to avoid strange oscillations of the graph.我的目标是使用数据流,并设置固定范围的测量轴以避免图形的奇怪振荡。

At this time the chart successfully rebuilds, but the range on measurement axis changed every time.此时图表成功重建,但每次测量轴上的范围都会发生变化。

You can provide a static range for an axis like this (example is for 12-18 inclusive):您可以为这样的轴提供静态范围(例如 12-18 包括):

    primaryMeasureAxis: new charts.NumericAxisSpec(
      tickProviderSpec: new charts.StaticNumericTickProviderSpec(
        <charts.TickSpec<num>>[
          charts.TickSpec<num>(12),
          charts.TickSpec<num>(14),
          charts.TickSpec<num>(16),
          charts.TickSpec<num>(18),
        ],
      ),
    ),

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

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