Spice Up Your Flutter App with Interactive Features in Syncfusion Charts | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (174).NET Core  (29).NET MAUI  (207)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (215)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (915)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (147)Chart  (131)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (628)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)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  (507)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)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  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (592)What's new  (332)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Spice Up Your Flutter App with Interactive Features in Syncfusion Charts

Spice Up Your Flutter App with Interactive Features in Syncfusion Charts

Looking at raw data and trying draw conclusions from it is very tedious. Visual representations such as charts and graphs overcome this problem. These visual representations, when powered by interactive features, are a piece of cake to understand. In this blog, I am going to walk you through the rich and highly interactive features of Syncfusion Flutter Charts, namely:

These features help users understand data in various ways. Users can experiment with their data’s presentation to answer questions about it with the best visuals. Let’s check out these rich interactive capabilities.

Tooltip

The tooltip is one of the Syncfusion Flutter Charts control’s most valuable features. On interacting with data points in a series, the specific data point values will be displayed in a pop-up called a tooltip. We can easily customize the tooltips to define additional chart point information, change their appearance, place images or custom widgets in them, and more. So, there’s almost no limit to the possibilities. Here are some of the key features of the tooltip:

  • It can be enabled for all series in a chart.
  • It can be activated on tap, double-tap, or long press.
  • It can be positioned to always display at the top of the data point or at the pointer position.
  • Its content can be formatted.
  • Any widget can be used as a tooltip using Builder.
  • It can be shown or hidden dynamically using public methods.
  • Its appearance can be completely customized.

Refer to the following links for more details:

Refer to the following code example to enable tooltips in your Flutter chart.

  
[Dart]
class _MyHomePageState extends State<MyHomePage> {
  TooltipBehavior tooltip;

  @override
  void initState() {
    tooltip = TooltipBehavior(enable: true);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SfCartesianChart(
        series: <LineSeries<ChartData, num>>[
          LineSeries<ChartData, num>(
            enableTooltip: true,
            dataSource: chartData,
            xValueMapper: (ChartData sales, _) => sales.x,
            yValueMapper: (ChartData sales, _) => sales.y
          )
        ],
        tooltipBehavior: tooltip
      )
    );
  }
}
Chart with Tooltips
Chart with Tooltips

Selection

A user can interact with and highlight a data point in Flutter Charts using the selection feature. Performing selection brings the center of focus to that data point over other points. Some of the key features of selection include:

  • A data point or group of data points can be selected.
  • Selection can be activated on tap, double-tap, or long press.
  • Selection modes can be point, series, or cluster.
  • The appearance of both selected and not-selected data points can be customized.
  • Data points can be selected even while rendering the chart initially.
  • Data points can be selected or cleared dynamically using public methods.
  • The selected data point details can be fetched for future use.

Refer to the following links for more details:

Refer to the following code example to enable selection in your Flutter Charts.

  
[Dart]
SfCartesianChart(
  series: <ColumnSeries<ChartData, String>>[
    ColumnSeries<ChartData, String>(
      selectionSettings: SelectionSettings(
        enable: true, 
        unselectedOpacity: 0.5
      ),
      dataSource: chartData,
      xValueMapper: (ChartData sales, _) => sales.x,
      yValueMapper: (ChartData sales, _) => sales.y
    )
  ]
);
Chart with Selection Enabled
Chart with Selection Enabled

Trackball

In Flutter Charts, the trackball feature is similar to a tooltip, but the difference is that the trackball will appear as a label connected by a vertical or horizontal line to a data point. This feature can be used as an alternative to the data label feature in case you are unable to show data labels for all data points. This feature is particularly helpful in scenarios with space constraints. The following are some of the key features of the trackball:

  • It can be displayed for both vertical and horizontal series.
  • It can be activated on tap, double-tap, or long press.
  • Trackball tooltips can be displayed in three modes: grouped for all series, individual tooltips for all series, or tooltip only for closest point.
  • Track marker support is also available.
  • The appearance of the track line, track marker, and tooltip can be completely customized.
  • Trackball can be shown or hidden dynamically using public methods.
  • Trackball hide duration can be customized, or it can be made to always be displayed.

Refer to the following links for more details:

Refer to the following code example to enable the trackball feature in your Flutter charts.

  
[Dart]
class _MyHomePageState extends State<MyHomePage> {
  TrackballBehavior trackball;

  @override
  void initState() {
    trackball = TrackballBehavior(
      enable: true,
      lineType: TrackballLineType.vertical,
      activationMode: ActivationMode.singleTap,
      tooltipAlignment: ChartAlignment.center,
      tooltipDisplayMode: TrackballDisplayMode.nearestPoint,
      tooltipSettings: InteractiveTooltip(format: 'point.x: point.y'),
      shouldAlwaysShow: false,
      hideDelay: 2000
    )
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SfCartesianChart(
        series: <LineSeries<ChartData, num>>[
          LineSeries<ChartData, num>(
            dataSource: chartData,
            xValueMapper: (ChartData sales, _) => sales.x,
            yValueMapper: (ChartData sales, _) => sales.y
          )
        ],
        trackballBehavior: trackball
      )
    );
  }
}
Chart with Trackball
Chart with Trackball

Crosshair

In Flutter Charts, a crosshair is used to display the value of any position in the chart area regardless of the data point. Even if a data point is not present at a location in the chart, the crosshair will display the value of that location. Some of the key features of the crosshair include:

  • Crosshair lines can be displayed vertically, horizontally, or both together.
  • Crosshair can be activated on tap, double-tap, or long press.
  • Tooltips are displayed at the axis to show the current value.
  • The appearance of crosshair lines and axis tooltips can be completely customized.
  • Crosshair can be shown or hidden dynamically using public methods.
  • Crosshair hide duration can be customized and made to always be displayed.

Refer to the following links for more details:

Refer to the following code example to enable the crosshair feature in your Flutter Charts.

  
[Dart]
class _MyHomePageState extends State<MyHomePage> {
  CrosshairBehavior crosshair;

  @override
  void initState() {
    crosshair = CrosshairBehavior(
      enable: true,
      activationMode: ActivationMode.singleTap,
      hideDelay: 2000,
      shouldAlwaysShow: false,
      lineType: CrosshairLineType.both,
      lineWidth: 1
    )
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SfCartesianChart(
        primaryXAxis: DateTimeAxis( 
          interactiveTooltip: InteractiveTooltip( 
            enable: true 
          ) 
        ), 
        crosshairBehavior: crosshair
      )
    );
  }
}
Chart with Crosshair
Chart with Crosshair

Zooming and panning

When plotting a Flutter chart with a large amount of data, zooming and panning can be used to provide better data readability. Zooming is performed by pinching or selecting a region, and panning is done by dragging your finger across the touchscreen. Here are a few helpful aspects of zooming and panning:

  • You can ably zoom for the x axis, y axis, or both axes together.
  • You can perform zooming and panning dynamically using public methods.
  • On zooming, intervals are autocalculated, and axis label formats are updated.
  • Maximum zoom level can be specified.
  • Axis range can be autocalculated based on the visible data points.
  • Axis elements support animation.
  • View a particular piece of data in a chart using the visible minimum and visible maximum options.

Refer to the following links for more details:

Refer to the following code example to enable zooming and panning in your Flutter charts.

  
[Dart]
class _MyHomePageState extends State<MyHomePage> {
  ZoomPanBehavior zoomPan;

  @override
  void initState() {
    zoomPan = ZoomPanBehavior(
      enablePinching: true,
      enableSelectionZooming: true,
      enableMouseWheelZooming: true,
      enablePanning: true,
      zoomMode: ZoomMode.xy
    )
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SfCartesianChart(
        series: <LineSeries<ChartData, num>>[
          LineSeries<ChartData, num>(
            dataSource: chartData,
            xValueMapper: (ChartData sales, _) => sales.x,
            yValueMapper: (ChartData sales, _) => sales.y
          )
        ],
        zoomPanBehavior: zoomPan
      )
    );
  }
}
Chart with Zooming and Panning
Chart with Zooming and Panning

Conclusion

Data visualization and analysis is now an essential component of business processes. All big and small companies need clear, efficient, and interactive ways to communicate information properly. We ensure that our Flutter Charts component contributes to your business process with the user-oriented, interactive features that we built into it. You can find more information about these interactive features here.

Play with our Charts control for Flutter with the samples available at this GitHub location. Also, explore our samples available on Google Play and the App Store. Learn about the controls’ advanced features through our documentation.

If you have any questions or need any clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

googleplay.png

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed