What’s New in 2021 Volume 2: Flutter Charts | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (173).NET Core  (29).NET MAUI  (203)Angular  (107)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (40)Black Friday Deal  (1)Blazor  (211)BoldSign  (13)DocIO  (24)Essential JS 2  (106)Essential Studio  (200)File Formats  (65)Flutter  (132)JavaScript  (219)Microsoft  (118)PDF  (81)Python  (1)React  (98)Streamlit  (1)Succinctly series  (131)Syncfusion  (897)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (50)Windows Forms  (61)WinUI  (68)WPF  (157)Xamarin  (161)XlsIO  (35)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (146)Chart  (127)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (618)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (39)Extensions  (22)File Manager  (6)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (501)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (42)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (381)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (17)Web  (582)What's new  (323)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
What’s New in 2021 Volume 2: Flutter Charts

What’s New in 2021 Volume 2: Flutter Charts

The Flutter Charts widget is a well-crafted control for visualizing data. It contains a rich gallery of over 30 charts and graphs, ranging from line to financial, that cater to all charting scenarios. In this blog post, I’ll quickly introduce the new features included in the Flutter Charts widget for the 2021 Volume 2 release.

Let’s see them!

Millisecond interval

DateTimeAxis and DateTimeCategoryAxis now support millisecond intervals. With this support, you can render the data points of a chart with millisecond differences. To achieve this, set the intervalType property of the axis as DateTimeIntervalType.milliseconds.

The following example shows how to render the date-time category axis with millisecond intervals in Flutter Charts.

[Dart]
// Chart data source with millisecond date-time x values.
final List<LiveData> chartData = <LiveData>[
  LiveData(x: DateTime(2012, 10, 15, 00, 00, 01, 001), y: 30),
  LiveData(x: DateTime(2012, 10, 15, 00, 00, 01, 002), y: 40),
  LiveData(x: DateTime(2012, 10, 15, 00, 00, 01, 003), y: 50),
  //...
];

@override
Widget build(BuildContext context) {
  return Container(
    child: SfCartesianChart(
      primaryXAxis: DateTimeCategoryAxis(
        // DateTime axis interval type is set as milliseconds.
        intervalType: DateTimeIntervalType.milliseconds,
        // Applied seconds:milliseconds format.
        dateFormat: DateFormat('ss:SSS')
      ),
      series: <ChartSeries<LiveData, DateTime>>[
        ColumnSeries<LiveData, DateTime>(
        dataSource: chartData,
        xValueMapper: (LiveData sales, _) => sales.x,
        yValueMapper: (LiveData sales, _) => sales.y),
      ],
    )
  );
}

Refer to the following screenshot.

Date-Time Category Axis with Millisecond Intervals in Flutter Charts
Date-Time Category Axis with Millisecond Intervals in Flutter Charts

Note: For more information, refer to the axis interval type demo and documentation.

Floating legend

You can now move the legend and place it anywhere on the top of the Flutter Chart widget. Also, the legend will not take a dedicated position. You can draw it even on top of the chart’s plot area. To achieve this, specify the value for the offset property available in the legend.  Now, the legend will be moved from its original position.

For example, if the position property of the legend is set as LegendPosition.top, then the legend will be placed on the top, but in the position specified by the offset property relative to the original top position.

This useful feature applies to these four chart widgets:

The following code example shows how to place a legend in a custom position.

[Dart]
SfCartesianChart(
  primaryXAxis: DateTimeAxis(),
  legend: Legend(
    isVisible: true,
    // Legend will be placed at the specified offset position.
    offset: Offset(20, 40)
  ),
  //...
)

Refer to the following screenshot.

Floating Legend in Flutter Chart
Floating Legend in Flutter Chart

Note: For more information, refer to the legend positioning demo and documentation.

Controlling deselection

Previously, when you tapped on a selected data point, it would be deselected. With the 2021 Volume 2 release, you can now decide whether to deselect the data point or let it remain selected by tapping it in the Flutter Charts widget. You can achieve this by setting values to the toggleSelection property in SelectionBehavior.

If the value in the toggleSelection property is true, you can deselect the selected points. If the value is false, then you can’t deselect the selected data points. This property defaults to true. This feature works even while calling public methods, in various selection modes, with multi-selection and on dynamic changes.

This feature is applicable for all four chart widgets:

Refer to the following code example.

[Dart]
late SelectionBehavior _selectionBehavior;

@override
void initState() {
  _selectionBehavior = SelectionBehavior(enable: true, toggleSelection: false);
  super.initState();
}
  
@override
Widget build(BuildContext context) {
  return Scaffold(
    body: Center(
      child: SfCircularChart(
        series: <CircularSeries<AgeDistributionData, String>>[
          PieSeries<AgeDistributionData, String>(
            dataSource: chartData,
            xValueMapper: (AgeDistributionData data, _) => data.x,
            yValueMapper: (AgeDistributionData data, _) => data.y,
            selectionBehavior: _selectionBehavior
          )
        ]
      ),
    )
  )
}

Refer to the following .gif image.

Toggle Selection Feature in Flutter Circular Chart
Toggle Selection Feature in Flutter Circular Chart

Note: For more information, refer to the selection modes demo and documentation.

Overfilled radial bar chart

Now, you can indicate a value that is beyond the maximum value by overfilling the radial bar chart. For example, if you set the maximumValue property of the RadialBarSeries to 100, but the radial bar data point value is 150. Then, it will render the chart by overfilling the current data point. You don’t need any additional property to achieve this. This works by default.

Refer to the following code example.

[Dart]
final List<StepsCountData> chartData = <StepsCountData>[
  StepsCountData('Low', 3500),
  StepsCountData('Average', 7200),
  StepsCountData('High', 10500),
];

SfCircularChart(
  series: <CircularSeries>[
    RadialBarSeries<StepsCountData, String>(
      // Setting the maximum value as 6000.
      maximumValue: 6000,
      dataSource: chartData,
      xValueMapper: (StepsCountData data, _) => data.x,
      yValueMapper: (StepsCountData data, _) => data.y
    )
  ]
)

Refer to the following screenshot.

Overfilled Flutter Radial Bar Chart
Overfilled Flutter Radial Bar Chart

Note: For more information, refer to the overfilled radial bar demo and documentation.

Callbacks for data point interactions

There may be several scenarios in an app that require performing certain actions while interacting with its data points. For this, we added three new callbacks in the Flutter charts in the 2021 Volume 2 release:

These callbacks are called when tapping, double-tapping, and long-pressing on the data points in the chart, respectively.

With these, you can get the point index, viewport point index, and series index values of the interacted data point. Also, you can get the list of data points in that series in all three callbacks.

This feature is applicable for all four chart widgets:

The following example shows how to define and get values from the onPointLongPress callback. In the same way, you can use the OnPointTap and onPointDoubleTap callbacks.

[Dart]
SfCartesianChart(
  series: <ChartSeries<SalesData, num>>[
    ColumnSeries(
      dataSource: chartData,
      //Retrieving the long-pressed data point values.
      onPointLongPress: (ChartPointDetails details) {
        print(details.pointIndex);
        print(details.seriesIndex);
      }
    )
  ]
)

Note: For more information, refer to the data point events demo and documentation.

Retrieving all the calculated indicator values

In some scenarios, we may require internally calculated technical indicator values at the application level for further processing. With the 2021 Volume 2 release,  the Flutter Charts widget now allows you to get internally calculated indicator values using the onRenderDetailsUpdate callback event in TechnicalIndicators. This callback will be called while rendering an indicator.

Using this callback event, you can get the indicator name and calculated data point values. Also, you can change the values of line color, width, and a dash array using this callback event.

The following code example shows how to define the onRenderDetailsUpdate indicator and how to get and set values in it.

[Dart]
SfCartesianChart(
  indicators: <TechnicalIndicators<ChartData, DateTime>>[
    SmaIndicator<ChartData, DateTime>(
      onRenderDetailsUpdate: (IndicatorRenderParams params) {
        // Modifying the color, width and dash array of the signal line.
        return ChartIndicator(Colors.cyan, 3.0, <double>[5,5]);
      }
    )
  ]
)

Note: For more information, refer to the indicator callback documentation.

Breaking Changes

Now, let’s see about the breaking changes in the Flutter Charts widget in the 2021 Volume 2 release.

onPointTapped callback is deprecated

The onPointTapped callback in the SfCartesianChart has been deprecated. Instead, use the onPointTap callback event available in the CartesianSeries class to get the tapped data point details.

This new callback feature is available for all four chart widgets:

The following code example shows how to use the onPointTap callback and retrieve details with it.

[Dart]
SfCartesianChart(
  series: <ChartSeries<SalesData, num>>[
    ColumnSeries(
      dataSource: chartData,
      //Retrieving the tapped data point values.
      onPointTap: (ChartPointDetails details) {
        print(details.pointIndex);
        print(details.seriesIndex);
      }
    )
  ]
)

onIndicatorRender callback is deprecated

The onIndicatorRender callback has been deprecated in our Flutter Charts. Instead, use the onRenderDetailsUpdate callback in the TechnicalIndicators class to get the indicator details. The Flutter Charts will call this callback while rendering an indicator.

Conclusion

I hope you now have a clear idea about the new, useful features in the Syncfusion Flutter Charts widget for the 2021 Volume 2 release. For more details about the bug fixes and other enhancements, check out our release notes and What’s New pages. Try out these new features and leave your feedback in the comments section!

Also, browse through our documentation to learn more about our Flutter widgets. You can also see Syncfusion’s Flutter app with many examples in our GitHub repository. Don’t miss our demo app in Google Play, the App Store, the Windows Store, the App CenterSnapcraft, and on our website.

If you aren’t a customer yet, you can try our 30-day free trial to check out these features.

You can also contact us through our support forumfeedback portal, or Direct-Trac support system. We are always happy to assist you!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed