We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to bind data from the list to the Flutter Cartesian chart (SfCartesianChart) ?

Platform: Flutter |
Control: SfCartesianChart

The following steps explains how to bind the list of data to the SfCartesianChart widget.


Step 1: Define the data source that needs to be bind to the chart as in the below code snippet.

final List<_ChartData> chartData = <_ChartData>[
     _ChartData(2005, 21, 28),
     _ChartData(2006, 24, 44),
     _ChartData(2007, 36, 48),
     _ChartData(2008, 38, 50),
     _ChartData(2009, 54, 66),
     _ChartData(2010, 57, 78),
     _ChartData(2011, 70, 84)
// Class for data source.
class _ChartData {
  _ChartData(this.x, this.y, this.y2);
  final double x;
  final double y;
  final double y2;


Step 2: Define the SfCartesianChart widget with the required properties and bind the chartData to the chart as below.

 series: <LineSeries<_ChartData, num>>[
  LineSeries<_ChartData, num>(
    animationDuration: 2500,
    // Binding list data to the chart.
    dataSource: chartData,
    xValueMapper: (_ChartData sales, _) => sales.x,
    yValueMapper: (_ChartData sales, _) => sales.y,
  LineSeries<_ChartData, num>(
    animationDuration: 2500,
    // Binding list data to the chart.
    dataSource: chartData,
    xValueMapper: (_ChartData sales, _) => sales.x,
    yValueMapper: (_ChartData sales, _) => sales.y2,


Thus, the data from the list is bound to the SfCartesianChart widget.


Binding list data to the chart.


View the sample in GitHub.


You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile