Problems with SfCartesianChart build animation
Using the syncfusion_flutter_charts 19.1.55 + 1 package, I created a dynamic graph, but due to the built-in smooth animation, the graph is constantly distorted. How do I disable the built-in animation?

import 'dart:math';
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
Random r = Random();
List<_SalesData> dynamicData = [];
Stream<List<_SalesData>> _getStream() async* {
while(true) {
await Future.delayed(Duration(seconds: 1));
if(dynamicData.length == 10) {
dynamicData.removeAt(0);
for(int i = 0; i<dynamicData.length; ++i) {
dynamicData[i] = _SalesData(i.toDouble(), dynamicData[i].y);
}
}
dynamicData.add(_SalesData(dynamicData.length.toDouble(), r.nextDouble()));
yield dynamicData;
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: StreamBuilder<List<_SalesData>>(
stream: _getStream(),
builder: (context, snapshot) {
if(snapshot.connectionState == ConnectionState.active) {
return SfCartesianChart(
isTransposed: false,
primaryXAxis: NumericAxis(
isVisible: false,
),
tooltipBehavior: TooltipBehavior(enable: false),
series: <ChartSeries<_SalesData, double>>[
SplineSeries<_SalesData, double>(
dataSource: dynamicData,
xValueMapper: (_SalesData sales, _) => sales.x,
yValueMapper: (_SalesData sales, _) => sales.y,
name: 'Sales',
// Enable data label
dataLabelSettings: DataLabelSettings(isVisible: false))
]);
}
return Center(child: CircularProgressIndicator());
}
),
);
}
}
class _SalesData {
_SalesData(this.x, this.y);
final double x;
final double y;
}
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
DP
Dharanitharan Palanisamy
Syncfusion Team
April 13, 2021 01:44 PM UTC
Hi Sergey,
Greetings from Syncfusion. You can disable the animation by simply giving the animationDuration as 0 in the respective series. For more information, please refer to the help doument. Please revert us if you need any further assistance.
Thanks,
Dharanitharan. P
Marked as answer
Hi Sergey,Greetings from Syncfusion. You can disable the animation by simply giving the animationDuration as 0 in the respective series. For more information, please refer to the help doument. Please revert us if you need any further assistance.Thanks,Dharanitharan. P
Hello.
How to achieve a smooth shift of the graph on the X-axis, without distortion on the Y-axis?
That is, the X-axis animation is enabled, and the Y-axis animation is disabled.
Thanks.
DP
Dharanitharan Palanisamy
Syncfusion Team
April 19, 2021 08:58 AM UTC
Hi Dmitry,
We have analyzed your queries and kindly find the responses below.
How to achieve a smooth shift of the graph on the X-axis, without distortion on the Y-axis?
We would like to tell you that the axis range is calculated based on the data points and so the distortion of the axis is the default behavior and if you do not want to distort in the y-axis, you can set minimum and maximum in that axis. You can also refer to the help document to know more about this.
The X-axis animation is enabled, and the Y-axis animation is disabled.
We would like to tell you that as of now, we cannot disable the animation for the particular axis, you can enable animation for all the axes or disable the animation for the whole axes.
Kindly refer to the help document to know more about our charts and can refer to the following demo link for the sample,
Please revert us if you need further assistance on this.
Thanks,
Dharanitharan. P
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
- Marked answer
-
SE Sergey
- Apr 12, 2021 08:37 AM UTC
- Apr 19, 2021 08:58 AM UTC