What’s New in 2020 Volume 4: Flutter Charts | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (175).NET Core  (29).NET MAUI  (208)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (220)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  (101)Streamlit  (1)Succinctly series  (131)Syncfusion  (919)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#  (150)Chart  (132)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (633)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  (508)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  (11)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  (597)What's new  (333)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
What’s New in 2020 Volume 4: Flutter Charts

What’s New in 2020 Volume 4: Flutter Charts

The team at Syncfusion has been hard at work on the Flutter Charts widget, which can be used to create stunning charts and graphs. The new version available in the 2020 Volume 4 release has some great new features and enhancements.

This blog will give you information about the new features of the Charts widget and how they work.

Let’s see them!

Maximum width for axis labels

You can restrict the size of the axis labels by specifying a maximum text width. There are two scenarios in which this is applicable:

Maximum label width

If an axis label exceeds the specified width, it will get trimmed and an ellipsis (…) will be added at the end of the trimmed text. This can be achieved by using the maximumLabelWidth property in the axis. As the default value is null, labels will not be trimmed by default.

Labels extent

If an axis label exceeds the specified value, like the maximumLabelWidth feature, the axis label will be trimmed and an ellipsis (…) will be added at the end of the trimmed text. If an axis label width is within the specified value, white space will be added at the beginning to make up the remaining width. This is done to maintain uniform bounds and to eliminate axis label flickering on zooming and panning. This can be achieved by using the labelsExtent property in the axis.

Complete label text will be shown in a tooltip when tapping or clicking over the trimmed axis labels in both scenarios.

[Dart]
@override
Widget build(BuildContext context) {
  return Container(
    child: SfCartesianChart(
      primaryXAxis: CategoryAxis(
        maximumLabelWidth: 80
      ),
      series: <ChartSeries<SalesData, String>>[
        BarSeries<SalesData, String>(
          dataSource: <SalesData>[
            SalesData('Goldin Finance 117', 597),
            SalesData('Ping An Finance Center', 599),
            SalesData('Makkah Clock Royal Tower', 601),
            SalesData('Shanghai Tower', 632),
            SalesData('Burj Khalifa', 828)
          ],
          xValueMapper: (SalesData sales, _) => sales.year,
          yValueMapper: (SalesData sales, _) => sales.sales
        ),
      ]
    )
  );
}

Maximum width for axis labelsSB sample: https://flutter.syncfusion.com/#/cartesian-charts/axis-features/maximum-width-for-labels

UG link: https://help.syncfusion.com/flutter/cartesian-charts/axis-customization#axis-label-width-customization

Template support for trackball

You can add any custom widget as a trackball tooltip using the builder property in the TrackballBehavior class. If the trackball display mode is groupAllPoints or nearestPoint, it will be called once, and if it is floatAllPoints, it will be called for each point.

[Dart]
@override
  Widget build(BuildContext context) {
    return Scaffold(
      child: Center(
        child: Container(
          child: SfCartesianChart(
            trackballBehavior: TrackballBehavior(
              enable: true,
              builder: (BuildContext context, TrackballDetails trackballDetails) {
                return Container(
                  height: 50,
                  width: 150,
                  decoration: BoxDecoration(
                    color: Color.fromRGBO(0, 8, 22, 0.75),
                    borderRadius: BorderRadius.all(Radius.circular(6.0)),
                  ),
                  child: Row(
                    children: [
                      Padding(
                        padding: EdgeInsets.only(left: 5),
                        child: SizedBox(
                          child: Image.asset('images/People_Circle16.png'),
                          height: 30,
                          width: 30
                        )
                      ),
                      Center(
                        child: Container(
                          padding: EdgeInsets.only(top: 11, left: 7),
                          height: 40,
                          width: 100,
                          child: Text('${trackballDetails.point.x.toString()} : \${trackballDetails.point.y.toString()}',
                            style: TextStyle(
                              fontSize: 13,
                              color: Color.fromRGBO(255, 255, 255, 1)
                            )
                          )
                        )
                      )
                    ]
                  )
                );
              },
            ),
            series: <CartesianChart<SalesData, String>>
              [
                SplineSeries<SalesData, double>(
                  dataSource: data,
                  xValueMapper: (SalesData sales, _) => sales.year,
                  yValueMapper: (SalesData sales, _) => sales.sales
                )
              ]
            )
          )
        )
      );
    }

Template support for trackballSB sample: https://flutter.syncfusion.com/#/cartesian-charts/user-interactions/trackball/chart-with-trackball

UG link: https://help.syncfusion.com/flutter/cartesian-charts/trackball-crosshair#trackball-tooltip-template

Pixel and point value conversions

Pixel to point

Convert a logical pixel value to a chart data point. This feature helps add the data points dynamically on interaction. This can be done by passing a logical pixel value as input to the pixelToPoint method, which then returns the chart data point. Since this method is in the series controller, x-axis and y-axis coordinates associated with this particular series will be considered for the conversion.

Point to pixel

Convert a chart data point value to a logical pixel value. This can be done by passing chart data point value as input to the pointToPixel method, which returns the logical pixel value. Since this method is in the series controller, x-axis and y-axis coordinates associated with this particular series will be considered for conversion.

[Dart]
@override
Widget build(BuildContext context) {
  ChartSeriesController seriesController;
  return Container(
    child: SfCartesianChart(
      series: <CartesianSeries<ChartSampleData, num>>[
        LineSeries<ChartSampleData, num>(
          onRendererCreated: (ChartSeriesController controller) {
            seriesController = controller;
          },
        )
      ],
      onChartTouchInteractionUp: (ChartTouchInteractionArgs args) {
        final Offset value = Offset(args.position.dx, args.position.dy);
        CartesianChartPoint<dynamic> chartpoint = seriesController.pixelToPoint(value);
          print('X point: ${chartpoint.x}');
          print('Y point: ${chartpoint.y}');
      }
    )
  );
}

Pixel and point value conversionsSB sample: https://flutter.syncfusion.com/#/cartesian-charts/user-interactions/add-a-point-on-click/add-a-point-on-click

UG link: https://help.syncfusion.com/flutter/cartesian-charts/methods#pixeltopoint

Callback improvements

Along with the point index, you can now get the viewport point index from onDataLabelRender, onDataLabelTapped, onMarkerRender, onPointTapped, onSelectionChanged, and onTooltipRender callbacks. Point index is the index of the data point formed based on the overall data points in the series. The viewport point index value is based on the visible data points available on the view port.

[Dart]
SfCartesianChart(
  onDataLabelTapped: (DataLabelTapDetails args) {
    print(args.viewportPointIndex);
  },
  series: <ChartSeries<SalesData, num>>[
    ColumnSeries<SalesData, num>(
      dataSource: chartData,
      xValueMapper: (SalesData sales, _) => sales.year,
      yValueMapper: (SalesData sales, _) => sales.sales,
      dataLabelSettings: DataLabelSettings(
        isVisible: true
      )
    )
  ]
)

Conclusion

I hope you now have a clear idea of the new features available in the Syncfusion Flutter Charts widget for the 2020 Volume 4 release. For more details about the bug fixes and other enhancements, check out our release notes.

Browse our documentation to learn more about our Flutter widgets. You can also see Syncfusion’s Flutter app with many examples in this GitHub repo. Don’t miss our demo app in Google Play and the App Store.

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

Also, if you wish to send us feedback or would like to submit any questions, please feel free to post them in the comments section of this blog post. You can also contact us through our support forumfeedback portal, or Direct-Trac support system. 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