I have a realtime chart that reads adds data to the list of data every couple seconds however I only want to show the latest 5 data points at a time. I have enabled panning and set visibleminimum, visiblemaximum but the graph acts strangely because the line disappears after the first few points on build and I have to pan it manually for it to work properly.

As you can see here the last point remains in the middle and sometimes will even disappear to the left. This will only fix itself when I manually pan it)
(How I want my chart to automatically look like from the start.
SfCartesianChart(
zoomPanBehavior: ZoomPanBehavior(enablePanning: true),
enableAxisAnimation: false,
margin: EdgeInsets.all(5),
primaryXAxis: CategoryAxis(
interval: 2,
zoomFactor: 0.95,
visibleMinimum: ((chartData.length <= 5) ? 0 : ((chartData.length).toDouble() - 5)),
visibleMaximum: ((chartData.length).toDouble()),
edgeLabelPlacement: EdgeLabelPlacement.hide,
labelPlacement: LabelPlacement.onTicks,
labelIntersectAction: AxisLabelIntersectAction.hide,
),
primaryYAxis: NumericAxis(
anchorRangeToVisiblePoints: true,
decimalPlaces: 2,
zoomFactor: 0.95,
desiredIntervals: 5,
labelFormat: '{value} °C', // '%' will be append to all Y-axis labels
labelIntersectAction: AxisLabelIntersectAction.multipleRows,
majorTickLines: MajorTickLines(size: 1.5),
majorGridLines: MajorGridLines(width: 0),
minorGridLines: MinorGridLines(width: 0.0),
),
legend: Legend(isVisible: false), //Enable tooltip
tooltipBehavior: TooltipBehavior(enable: true),
series: <ChartSeries<SensorData, dynamic>>[
LineSeries<SensorData, dynamic>(
name: 'Realtime Temperature',
color: chartColors,
dataSource: chartData,
xValueMapper: (SensorData data, _) => data.now,
yValueMapper: (SensorData data, _) => data.sen1,
animationDuration: 500,
//Enable Label Settings
dataLabelSettings: DataLabelSettings(isVisible: false),
markerSettings: MarkerSettings(isVisible: false),
),
],
)