BoonieFlutter
BoonieFlutter

Reputation: 43

Flutter - Cartesian Charts - After a few minutes my chart starts to overwrite itself

I have an SfCartesianChart (Line-chart), which takes data from a bluetooth device. Works great for around 2/3 minutes. Then it starts plotting the data from the beginning again. Essentially overwriting the chart but leaving the existing data in place.

So rather than a continual left to right set of data points i get a line from the right side of the screen, back to the left about half way through the data reading.

Has anyone experienced this or is anyone able to offer some suggestions?

This is the widget that calls a _ChartData class and gets data from the streambuilder.

widget = Container(
                      height: 200,
                      child: SfCartesianChart(
                          zoomPanBehavior: _zoomPanBehavior,
                          borderColor: Colors.transparent,
                          onZoomEnd: (ZoomPanArgs args) {
                            print(args.currentZoomFactor);
                            print(args.currentZoomPosition);
                          },
                          borderWidth: 0,
                          primaryYAxis: NumericAxis(
                            title: AxisTitle(text: 'BPM'),
                            visibleMinimum: 45,
                            visibleMaximum: 90,
                          ),
                          plotAreaBackgroundColor: Colors.transparent,
                          tooltipBehavior: TooltipBehavior(enable: true),
                          primaryXAxis: NumericAxis(
                              isVisible: false,
                              interval: 20,
                              // visibleMinimum: 45,
                              // visibleMaximum: 90,
                              autoScrollingMode: AutoScrollingMode.start),
                          series: <LineSeries<_ChartData, int>>[
                            LineSeries<_ChartData, int>(
                                color: Colors.red,
                                onRendererCreated:
                                    (ChartSeriesController controller) {
                                  seriesController = controller;
                                },
                                animationDuration: 0,
                                dataSource: chartData,
                                xValueMapper: (_ChartData data, _) => data.x,
                                yValueMapper: (_ChartData data, _) => data.y1),
                          ]),
                    );```
                  

Upvotes: 2

Views: 1653

Answers (1)

Dharani
Dharani

Reputation: 309

Thanks for the interest in our Flutter charts. We have analyzed your query and the given code snippet and suspect that issue may be the setting of wrong visibleMinimum and visibleMaximum. By default, it will automatically calculate the range based on the data points and renders the chart correctly, so remove this or set proper values to them will resolve your issue. Also, ensure whether the chartData is getting proper data from the stream builder. Kindly contact us through our support forums, Direct-Trac, or feedback portal if you need any further assistance. We are always happy to assist you!

Upvotes: 1

Related Questions