Skip to content

Animation behaviour when updating Cartesian chart #2351

Closed
@shaddeen

Description

@shaddeen

Bug description

I've implemented a line/area chart with a time range selector that updates the data source accordingly. I've noticed an undesirable animation effect when the number of data points increases; the transition between the old and new states appears jarring.

When the number of data points remains the same or decreases, the update is handled smoothly.

Is there a configuration option to control this behaviour, or is this a known issue?

flutter: 3.29.0
syncfusion_flutter_charts: 29.1.41

Platform: iOS 18.3 (Simulator)

Steps to reproduce

  1. Create a SfCartesianChart with a LineSeries.
  2. Bind the chart to a data source that can be changed.
  3. Implement a mechanism to update the data source.
  4. Update the data source whereby the number of data points increases compared to the current data.
  5. Observe the transition animation—notice the abrupt or undesirable behaviour.

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';

class ChartLData {
  ChartLData(this.x, this.y);
  final int x;
  final int y;
}

class TestLineChart extends StatefulWidget {
  const TestLineChart({super.key});

  @override
  _TestLineChartState createState() => _TestLineChartState();
}

class _TestLineChartState extends State<TestLineChart> {
  final List<ChartLData> _data = [ChartLData(0, 10), ChartLData(1, 20), ChartLData(2, 30)];

  void _add100DataPoints() {
    setState(() {
      final int currentLength = _data.length;
      for (int i = 0; i < 100; i++) {
        _data.add(ChartLData(currentLength + i, ((currentLength + i) * 7) % 100));
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        SfCartesianChart(
          series: <LineSeries<ChartLData, int>>[
            LineSeries<ChartLData, int>(
              dataSource: _data,
              xValueMapper: (ChartLData data, _) => data.x,
              yValueMapper: (ChartLData data, _) => data.y,
              animationDuration: 1000, // still animates, but behavior becomes abrupt
            ),
          ],
        ),
        Padding(
          padding: const EdgeInsets.all(16.0),
          child: ElevatedButton(
            onPressed: _add100DataPoints,
            child: const Text('Add 100 Data Points'),
          ),
        ),
      ],
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2025-05-13.at.13.59.53.mov

Stack Traces

Stack Traces

N/A

On which target platforms have you observed this bug?

iOS

Flutter Doctor output

Doctor output

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    chartsCharts componentfeatureNew featureuncertainUncertain featureworkaround availableWorkaround available to overcome the query

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions