Syncfusion Flutter
Syncfusion Flutter
for Flutter
Version - v17.4.0.39 | Release Date - December 17,2019
Syncfusion Flutter Widgets ...................................................................................................................... 9
How to best read this user guide ......................................................................................................... 9
Additional help resources .................................................................................................................... 9
Create a support incident .................................................................................................................... 9
System Requirements.............................................................................................................................. 9
Development Environment .............................................................................................................. 9
SDK Version ..................................................................................................................................... 9
Supported Platforms ........................................................................................................................ 9
Download Installer ................................................................................................................................ 10
Download the Trial Version................................................................................................................ 10
Free Trial Page ............................................................................................................................... 10
Start Trial Page .............................................................................................................................. 10
Download the License Version ........................................................................................................... 11
Installation and Upgrade ....................................................................................................................... 12
Installation..................................................................................................................................... 12
Uninstallation ................................................................................................................................ 22
Installation and Uninstallation ....................................................................................................... 26
Installation using Offline Installer....................................................................................................... 33
Installing with UI ............................................................................................................................ 33
Installing in silent mode ................................................................................................................. 38
Mac Installation ................................................................................................................................. 40
Installation FAQ ................................................................................................................................. 46
Upgrade from one version to another version. .................................................................................. 46
Upgrade from major version to service pack version .......................................................................... 46
Upgrade from trial version to license version ................................................................................. 46
Charts.................................................................................................................................................... 46
Overview ........................................................................................................................................... 46
Key Features .................................................................................................................................. 47
Getting Started .................................................................................................................................. 47
Add Flutter Charts to an application ............................................................................................... 47
Initialize chart ................................................................................................................................ 48
Bind data source ............................................................................................................................ 49
Add title......................................................................................................................................... 50
Enable data labels .......................................................................................................................... 52
Enable legend ................................................................................................................................ 53
Enable tooltip ................................................................................................................................ 54
Title ................................................................................................................................................... 56
Cartesian chart types ......................................................................................................................... 58
Line chart....................................................................................................................................... 58
Fast line chart ................................................................................................................................ 62
Area chart ...................................................................................................................................... 63
Spline chart.................................................................................................................................... 65
Column chart ................................................................................................................................. 69
Bar chart ........................................................................................................................................ 74
Bubble chart .................................................................................................................................. 79
Scatter chart .................................................................................................................................. 82
Step line chart ............................................................................................................................... 84
Range column chart ....................................................................................................................... 86
Range area chart............................................................................................................................ 89
Spline area chart ............................................................................................................................ 91
Step area chart .............................................................................................................................. 94
Stacked line chart .......................................................................................................................... 96
Stacked area chart ....................................................................................................................... 100
Stacked column chart .................................................................................................................. 105
Stacked bar chart ......................................................................................................................... 109
100% Stacked Area Chart ............................................................................................................. 114
100% Stacked Column Chart ........................................................................................................ 115
100% Stacked Bar Chart ............................................................................................................... 118
100% Stacked Line Chart .............................................................................................................. 120
Circular Chart Types......................................................................................................................... 122
Pie chart ...................................................................................................................................... 122
Doughnut chart ........................................................................................................................... 130
Radial bar chart ........................................................................................................................... 139
Pyramid Chart.................................................................................................................................. 144
Pyramid modes ............................................................................................................................ 146
Changing pyramid size ................................................................................................................. 146
Gap between segments ............................................................................................................... 147
Explode segments ........................................................................................................................ 148
Smart data labels ......................................................................................................................... 149
Applying palette color .................................................................................................................. 150
Funnel Chart .................................................................................................................................... 151
Changing funnel size .................................................................................................................... 152
Changing neck size ....................................................................................................................... 153
Gap between segments ............................................................................................................... 154
Explode segments ........................................................................................................................ 155
Smart data labels ......................................................................................................................... 156
Applying palette color .................................................................................................................. 157
Multiple and Combinational Charts.................................................................................................. 158
Multiple series ............................................................................................................................. 158
Combination series ...................................................................................................................... 159
Series customization ........................................................................................................................ 160
Animation.................................................................................................................................... 160
Transpose the series .................................................................................................................... 161
Color palette................................................................................................................................ 162
Color mapping for data points ..................................................................................................... 163
Gradient fill.................................................................................................................................. 165
Empty points ............................................................................................................................... 166
Sorting ......................................................................................................................................... 168
Axis ................................................................................................................................................. 170
Numeric axis ................................................................................................................................ 170
Category axis ............................................................................................................................... 178
Date-time axis.............................................................................................................................. 182
Logarithmic axis ........................................................................................................................... 189
Axis customization ........................................................................................................................... 192
Common axis features ................................................................................................................. 192
Smart axis labels .......................................................................................................................... 206
Axis crossing ................................................................................................................................ 207
Plot bands.................................................................................................................................... 211
Multiple axes ............................................................................................................................... 216
Marker and data label ..................................................................................................................... 218
Marker ........................................................................................................................................ 218
Data label .................................................................................................................................... 222
Legend ............................................................................................................................................ 233
Customizing legend...................................................................................................................... 234
Legend title.................................................................................................................................. 236
Toggles the series visibility ........................................................................................................... 238
Legend visibility ........................................................................................................................... 238
Legend item visibility ................................................................................................................... 239
Legend overflow .......................................................................................................................... 240
Positioning the legend ................................................................................................................. 241
Legend item template .................................................................................................................. 242
Appearance ..................................................................................................................................... 243
Chart sizing .................................................................................................................................. 243
Chart margin................................................................................................................................ 244
Plot area customization ............................................................................................................... 245
Annotation ...................................................................................................................................... 246
Positioning the annotation........................................................................................................... 247
Adding multiple annotation ......................................................................................................... 249
Adding annotation for multiple axes ............................................................................................ 250
Zooming and Panning ...................................................................................................................... 252
Pinch zooming ............................................................................................................................. 252
Double tap zooming ..................................................................................................................... 253
Selection zooming........................................................................................................................ 253
Auto interval on zooming ............................................................................................................. 256
Maximum zoom level................................................................................................................... 256
Trackball and Crosshair .................................................................................................................... 257
Trackball ...................................................................................................................................... 257
Crosshair ..................................................................................................................................... 263
Tooltip ............................................................................................................................................. 266
Customizing the appearance ........................................................................................................ 267
Label format ................................................................................................................................ 268
Tooltip positioning ....................................................................................................................... 269
Tooltip template .......................................................................................................................... 269
Activation mode .......................................................................................................................... 270
Selection ......................................................................................................................................... 271
Customizing the segments ........................................................................................................... 271
Selection modes .......................................................................................................................... 273
Multi-selection ............................................................................................................................ 274
Selection on initial rendering ....................................................................................................... 275
Cartesian chart methods .................................................................................................................. 276
Show method in tooltipBehavior.................................................................................................. 276
Hide method in tooltipBehavior ................................................................................................... 277
Show method in trackballBehavior............................................................................................... 278
Hide method in trackballBehavior ................................................................................................ 278
Show method in crosshairBehavior .............................................................................................. 279
Hide method in crosshairBehavior ............................................................................................... 280
SelectionIndex method in selectionSettings ................................................................................. 281
ZoomIn method in zoomPanBehavior .......................................................................................... 282
ZoomOut method in zoomPanBehavior ....................................................................................... 283
zoomByFactor method in zoomPanBehavior ................................................................................ 283
ZoomByRect method in zoomPanBehavior .................................................................................. 284
ZoomToSingleAxis method in zoomPanBehavior .......................................................................... 285
PanToDirection method in zoomPanBehavior .............................................................................. 286
Reset method in zoomPanBehavior ............................................................................................. 287
Events ............................................................................................................................................. 288
onTooltipRender .......................................................................................................................... 288
onActualRangeChanged ............................................................................................................... 289
onAxisLabelRender ...................................................................................................................... 289
onDataLabelRender ..................................................................................................................... 290
onLegendItemRender .................................................................................................................. 290
onTrackballPositionChanging ....................................................................................................... 291
onCrosshairPositionChanging....................................................................................................... 291
onZooming .................................................................................................................................. 292
onZoomStart................................................................................................................................ 292
onZoomEnd ................................................................................................................................. 293
onZoomReset .............................................................................................................................. 294
onPointTapped ............................................................................................................................ 294
onAxisLabelTapped ...................................................................................................................... 295
onLegendTapped ......................................................................................................................... 295
onSelectionChanged .................................................................................................................... 295
onLegendItemRender .................................................................................................................. 296
onTooltipRender .......................................................................................................................... 297
onDataLabelRender ..................................................................................................................... 297
onPointTapped ............................................................................................................................ 298
onLegendTapped ......................................................................................................................... 298
onSelectionChanged .................................................................................................................... 299
Radial Gauge ....................................................................................................................................... 299
Overview ......................................................................................................................................... 299
Key Features ................................................................................................................................ 300
Getting Started ................................................................................................................................ 301
Add Flutter Radial Gauge to an application .................................................................................. 301
Initialize the radial gauge ............................................................................................................. 301
Add title....................................................................................................................................... 302
Add axis ....................................................................................................................................... 303
Add range .................................................................................................................................... 304
Add pointer ................................................................................................................................. 305
Add annotation ............................................................................................................................ 306
Title ................................................................................................................................................. 308
Text Alignment ............................................................................................................................ 308
Axis ................................................................................................................................................. 309
Axis Customization....................................................................................................................... 309
Label style customization ............................................................................................................. 324
Tick customization ....................................................................................................................... 328
Multiple axis ................................................................................................................................ 336
Events.......................................................................................................................................... 337
Custom scale ............................................................................................................................... 339
Pointers ........................................................................................................................................... 340
Multiple pointers ......................................................................................................................... 341
Pointer Dragging .......................................................................................................................... 342
Event ........................................................................................................................................... 343
Marker pointer ................................................................................................................................ 344
Image pointer .............................................................................................................................. 345
Text pointer ................................................................................................................................. 346
Marker Customization ................................................................................................................. 346
Position customization................................................................................................................. 347
Needle Pointer ................................................................................................................................ 348
Needle customization .................................................................................................................. 349
Knob customization ..................................................................................................................... 352
Tail Customization ....................................................................................................................... 354
Range Pointer .................................................................................................................................. 357
Corner customization................................................................................................................... 360
Position customization................................................................................................................. 361
Range .............................................................................................................................................. 362
Range Customization ................................................................................................................... 363
Setting range color to axis elements ............................................................................................ 366
Range label .................................................................................................................................. 367
Annotation ...................................................................................................................................... 368
Setting image for annotation ....................................................................................................... 371
Alignment of annotation .............................................................................................................. 372
Animation........................................................................................................................................ 374
Initial animation........................................................................................................................... 374
Pointer Animation ....................................................................................................................... 375
Syncfusion Flutter Widgets How to best read this user guide
• The best way to read the user guide is to start with the Getting Started section of the
documentation for the component that you need. The Getting Started guide gives information
needed to know before writing the code. This is the only section recommended for end-to-end
reading before writing the code. All the other information can be referred when needed.
• Now, that you are familiar with the basics of using the component, and the next step would be
to start integrating the component into your application. It is very likely that you would find a
code example that resembles your intended usage scenario.
• After you have integrated the component into your application, it is likely that you would need
additional information on specific features and API. Search the specific topic using the search
box available at the top of the user guide.
• Another valuable resource is the API reference that provides detailed information on the classes
and its members.
System Requirements
Development Environment
Refer to the following links for recommended development environment in Flutter.
• Windows - https://flutter.dev/docs/get-started/install/windows
• MacOS - https://flutter.dev/docs/get-started/install/macos
• Linux - https://flutter.dev/docs/get-started/install/linux
SDK Version
The minimum Flutter SDK version required for our component is v1.7.8
Supported Platforms
The following table lists the platforms supported by our Flutter controls.
Platform Device Types Supported Versions
Download Installer
You can download the installer from Syncfusion.com website.
Download the Trial Version
There are two ways to download our 30-day trial.
Free Trial Page
1. You can evaluate our 30-day free trial from Free Trial page.
2. Once you fill the required form or made the login using the your Syncfusion registered account
you can download the trial installer setup in the confirmation page.
3. You can download the latest version trial installer.
4. You can unlock the installer using the unlock key, also you can unlock the installer using the
Syncfusion registered login credential.
5. You can download the trial installer using the Trials & Downloads page under your registered
account at any time before the trial expire. (Refer the below screenshot).
1. You can evaluate our 30-day free trial from Start Trial page.
2. You should login using your Syncfusion account to access this page.
3. You can start your trail by clicking on the required product.
Note: If you already using the trail products and it’s not expired, you couldn’t start the trial again for
same product.
4. After you started the trial, you can download the latest version trial installer using the Trials &
Downloads page.
5. In Trials & Downloads page, you can find your current active trial products. Trials, which you
done in both Free Trial Page and Start trial pages are listed here.
6. Use the Download (element 1 in below screenshot) button to download the installer of
respective product.
7. Online installer can be downloaded from this page.
8. No need of unlock key to unlock the online installer.
9. You can unlock the installer using the Syncfusion registered login credential.
Note: You can generate the license key for your active trial products from Trials & Downloads page. This
license key will be mandatory to use our trial products in your application. To know more about License
key, refer this help topic.
Download the License Version
1. You can find your available licensed products which under your registered Syncfusion account in
License & Downloads page.
2. You can find all the licenses (both active licenses and expired licenses) which are under your
account.
3. You can find the licenses listed based on SKU names.
4. Use the Download (element 1 in below screenshot) button to download the installer of
respective product.
5. Latest version installer will be downloaded from this page.
6. You can navigate to Downloads Older Versions (element 2 in below screenshot) to download
older version installers.
7. From 16.2 version online installer will be downloaded by default, and earlier versions offline
installer will be downloaded.
Note: Online Installer have been introduced from the release version 16.2.
8. You can navigate to More Downloads Options (element 3 in below screenshot) to download
other setups.
9. EXE and Zip format available to download for Windows OS. Both are Offline Installer.
10. No need of unlock key to unlock the online installer.
11. You can unlock the installer using the unlock key for versions earlier to 16.2, also you can unlock
the installer using the Syncfusion registered login credential.
Note: You can generate the license key for your licensed products from License & Downloads page. This
license key will be required only from release version 16.2. To know more about License key, refer this
help topic.
1. Double-click the Syncfusion Essential Studio Platform Online Installer setup file. The Setup
Wizard opens and extracts the package automatically.
2. Welcome wizard of the Syncfusion Online Installer will be displayed. Click Next.

3. Platform Selection wizard will be displayed. Select the platforms to be installed from the
Available tab. Select
Information: If the required software of the selected platform was not already installed,
Additional Software Required alert will be displayed. However, you can continue the installation and
install the required software later.

4. Confirmation wizard will be displayed. Here you can view and modify the list of platforms that
will be installed.
5. Configuration wizard will be displayed. Here you can change the Download, Install and samples
location. Also, you can change the Additional settings by platform basis. To install using the
default configuration, click Next.
• Select the Install Demos check box to install Syncfusion samples, or leave the check box clear,
when you do not want to install Syncfusion samples.
• Select the Create Desktop Shortcut checkbox to create the desktop shortcut for Syncfusion
Control Panel or leave the check box clear, when you do not want to create desktop shortcut.
6. After reading the License Terms and Conditions, check the I agree to the License Terms and
Privacy Policy check box. Click Next.
7. Login wizard will be displayed. You should enter your Syncfusion Direct-Trac login credentials. If
you don't have Syncfusion Direct-Trac login credentials, then you can click on Create an
Account. Else if you forgot your password, click on
Information: The selected platforms will be installed based on your Syncfusion License (Trial or
Licensed).
Summary wizard will be displayed. Here you can check the list of platforms which are installed
successfully and failed. Click Finish to exit the Summary wizard.

• Click
Launch
Control Panel to open the Syncfusion Control Panel.
Uninstallation
Till version 17.2, Syncfusion Web Installer had option for installation alone. Starting with the version
17.3 (2019 Vol 3), Syncfusion provides option for uninstalling the platforms of the same version from the
Web Installer application itself. Select the list of the platforms to be uninstalled and Web Installer will
uninstall those platforms one by one.
The following procedure illustrates how to uninstall Essential Studio Platform from Web Installer setup.
1. Double-click the Syncfusion Essential Studio Platform Online Installer setup file. The Setup
Wizard opens and extracts the package automatically.
2. Welcome wizard of the Syncfusion Online Installer will be displayed. Click Next.
3. Platform Selection wizard will be displayed. Select the platforms to be uninstalled from the
Installed tab. Select
4. Confirmation wizard will be displayed. Here you can view and modify the list of platforms that
will be uninstalled. Click Uninstall.
Summary wizard will be displayed. Here you can check the list of platforms which are
uninstalled successfully and failed. Click Finish to exit the Summary wizard.

Installation and Uninstallation
Till version 17.2, Syncfusion Web Installer had option for installation alone. Starting with the version
17.3 (2019 Vol 3), Syncfusion provides option for both install and uninstall the platforms of the same
version from the Web Installer application itself.
The following procedure illustrates how to install/uninstall Essential Studio Platform from Web Installer
setup.
1. Double-click the Syncfusion Essential Studio Platform Online Installer setup file. The Setup
Wizard opens and extracts the package automatically.
2. Welcome wizard of the Syncfusion Online Installer will be displayed. Click Next.
3. Platform Selection wizard will be displayed. Select the platforms to be installed from the
Available tab and platforms to be uninstalled from the Installed tab. Click Next.
Available

Installed
4. Confirmation wizard will be displayed. Here you can view and modify the list of platforms that
will be installed/uninstalled.
5. Configuration wizard will be displayed. Here you can change the Download, Install and samples
location. Also, you can change the Additional settings by platform basis. To install using the
default configuration, click Next.
6. After reading the License Terms and Conditions, check the I agree to the License Terms and
Privacy Policy check box. Click Next.
7. Login wizard will be displayed. You should enter your Syncfusion Direct-Trac login credentials. If
you don't have Syncfusion Direct-Trac login credentials, then you can click on Create an
Account. Else if you forgot your password, click on
Information: The selected platforms will be installed based on your Syncfusion License (Trial or
Licensed).
9. Once the Installation is complete, Summary wizard will be displayed. Here you can check the list
of platforms which are
installed/uninstalled successfully and failed. Click Finish to exit the Summary wizard.

• Click Launch
Control Panel to open the Syncfusion Control Panel.

Note: The Setup wizard extracts the syncfusionessentialflutter_(version).exe dialog, displaying the unzip
operation of the package.
• Login To Install
• Use Unlock Key
Login To Install
You should enter your Syncfusion Direct-Trac login credentials. If you don't have Syncfusion Direct-Trac
login credentials, then you can click on Sign Up to a create new account. Else if you forgot your
password, click on Reset Password to create new password. Here Email address and Password is
validated and the Platform Selection window opens.

Use Unlock Key
You should use the Syncfusion License/Trial key. Trial key is valid for 30 days and the installer won't
accept the expired trial key. Licensed customer can generate key from here.
4. After reading the License Terms and Conditions, check the I agree to the License Terms and
Conditions check box.
5. Click Next. Select the Installation, Samples Folder and Advanced Options screen opens. To install
in the displayed default location, click Install
Note: From the 2018 Volume 2 release, Syncfusion has changed the install and samples location
Default Install location: {ProgramFilesFolder}\Syncfusion\{Platform}\{version}
Default Samples location: C:\Users\Public\Documents\Syncfusion\{platform}\{version}
However, you can change the locations by clicking browse button.
• Select the Install Demos check box to install Syncfusion samples, or leave the check box clear,
when you do not want to install Syncfusion samples.
• Select the Create Desktop Shortcut checkbox to create the desktop shortcut for Syncfusion
Control Panel or leave the check box clear, when you do not want to create desktop shortcut.
6. Click Install.
8. Select the Run Syncfusion Control Panel check box to launch the Syncfusion Control Panel after
installing.
9. Click Finish. Syncfusion Flutter platform is installed in your system and the Syncfusion Essential
Studio Syncfusion Control Panel is launched automatically.
1. Double-click the Syncfusion Essential Studio platform setup file. The Setup Wizard opens and
extracts the package automatically.
2. The syncfusionessentialflutter_(version).exe file is extracted into the Temp folder.
3. Run %temp%. The Temp folder will open. The syncfusionessentialflutter_(version).exe file is
available in one of the folders.
4. Copy the extracted syncfusionessentialflutter_(version).exe file in local drive.
5. Cancel the Wizard.
6. Open the Command Prompt in administrator mode and pass the following arguments.
7. Setup is installed.
Note: x.x.x.x needs to be replaced with the Essential Studio version and the Product Unlock Key needs
to be replaced with the Unlock Key for that version.
Command Line Uninstallation
Syncfusion Essential Studio supports uninstalling the setup through Command Line in Silent mode. The
following steps illustrate this.
8. Setup is uninstalled.
Note: x.x.x.x needs to be replaced with the Essential Studio version installed in your machine.
Mac Installation
The following procedure illustrates how to install Flutter Mac installer.
1. Double-click the Syncfusion Flutter Mac Setup(.pkg) file. The Setup Wizard opens. Click
Continue.
3. Confirmation window will be displayed for the License Agreement. Click Agree.
Note: Unlock key is not required for installing the Mac installer. Syncfusion Mac installer can be used for
developing purposes without registering the Unlock key.
5. Authentication window opens. Provide the password and click Install Software
7. Completed screen will be displayed once the installation is finished. Click Close to exit the
installation wizard.
Installation FAQ
Refer this topic for more information regarding the issues related to installation.
Upgrade from one version to another version.
You can upgrade to the latest version by downloading and installing the platforms you require from this
link.
Upgrade from major version to service pack version
Syncfusion provides a new Volume release once in every three months which has exciting new features.
For that Volume release, there may be one or two Service Pack releases. The issues in the Volume
release will be addressed in the Service Pack releases. You can download and install the latest Service
Pack setup here.
It is not required to install the Volume release setup before installing the Service Pack release setup. As
Volume and Service Packs releases works independently, you can directly install the latest Service Pack
setup which contains major issue fixes.
Upgrade from trial version to license version
To upgrade from trial version, there are two possible solutions.
• Uninstall the trial version and install the fully licensed build from the License & Downloads
section of our website.
• Replace the currently used trial license key with a paid license key that can be generated from
the License & Downloads section of our website.
Charts
Overview
Syncfusion Flutter Charts is a data visualization library written natively in Dart for creating beautiful and
high-performance charts, which are used to craft high-quality mobile app user interfaces using Flutter.
Key Features
• Supports more than 10 different series types such as line, column, area, bar, bubble, fast line,
scatter, spline, stepline, pie, doughnut, and radial bar series. Each type represents data in a
unique style. It is more user friendly and has greater UI visualization.
• Plots data against multiple scales that help to visualize the mixed types of data in a single chart.
• Supports to render multiple series at the same time with options to compare and visualize two
different chart series simultaneously.
• Provides various options to customize the chart features, axis, labels, legends, series, etc. and
visualize them accordingly.
You can get the sample in the following link: Flutter Charts.
Getting Started
This section explains the steps required to populate the chart with data, title, data labels, legend, and
tooltips. This section covers only the minimal features needed to know to get started with the chart.
To get start quickly with our Flutter chart widget, you can check on this video.
<style>#flutterChartVideoTutorial{width : 90% !important; height: 300px !important }</style>
<iframe id='flutterChartVideoTutorial' src='https://www.youtube.com/embed/t3Dczqj8-10'></iframe>
Add Flutter Charts to an application
Create a simple project using the instructions given in the Getting Started with your first Flutter app
documentation.
Add dependency
Add the Syncfusion Flutter Chart dependency to your pub spec file.
DART
dependencies:
syncfusion_flutter_charts: ^1.0.0-beta.3
Get packages
Run the following command to get the required packages.
DART
$ flutter pub get
Import package
Import the following package in your Dart code.
DART
import 'package:syncfusion_flutter_charts/charts.dart';
Initialize chart
Once the package has been imported, initialize the chart as a child of any widget. There are two kinds of
chart widgets - SfCartesianChart and SfCircularChart. SfCartesianChart is used to render all kinds of
charts which need to be plotted in Cartesian coordinates. SfCircularChart can be used to render pie,
doughnut and radial bar charts. Here, as we are plotting line chart, initialize SfCartesianChart widget as a
child of Container widget.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
//Initialize chart
child: SfCartesianChart()
)
)
);
}
Add title
You can add a title to the chart to provide quick information to users about the data plotted in the chart.
The title to chart can be set as demonstrated in the following code snippet.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
Enable legend
The legend provides information about the series rendered in the chart.
You can use legend in chart by setting the isVisible property to true in SfCartesianChart.legend.
Additionally, you need to set label for each series using the series.name property. The labels will be
displayed in corresponding legends.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
// Enables the legend
legend: Legend(isVisible: true),
// Initialize category axis
primaryXAxis: CategoryAxis(),
series: <ChartSeries>[
// Initialize line series
LineSeries<SalesData, String>(
dataSource: [
// Bind data source
SalesData('Jan', 35),
SalesData('Feb', 28),
SalesData('Mar', 34),
SalesData('Apr', 32),
SalesData('May', 40)
],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales,
name: 'Sales'
)
]
)
)
)
);
}
Enable tooltip
The tooltip is used when you cannot display information using the data labels due to space constraints.
The tooltipBehavior property in chart is used to enable and customize the tooltip for all the series
whereas the enableTooltip property in series is used to toggle the tooltip visibility of each series. The
tooltip is enabled as demonstrated in the following code snippet.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Container(
child: SfCartesianChart(
// Enables the tooltip for all the series in chart
tooltipBehavior: TooltipBehavior(enable: true),
// Initialize category axis
primaryXAxis: CategoryAxis(),
series: <ChartSeries>[
// Initialize line series
LineSeries<SalesData, String>(
// Enables the tooltip for individual series
enableTooltip: true,
dataSource: [
// Bind data source
SalesData('Jan', 35),
SalesData('Feb', 28),
SalesData('Mar', 34),
SalesData('Apr', 32),
SalesData('May', 40)
],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
You can find the complete getting started sample from this link.
Title
You can define and customize the Chart title using title property of SfCartesianChart. The text property
of ChartTitle is used to set the text for the title.
Following properties are used to customize its appearance.
Text Alignment
You can align the title text content horizontally to the near, center or far of the chart using the
alignment property of the title.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
title: ChartTitle(
text: 'Half yearly sales analysis',
backgroundColor: Colors.lightGreen,
borderColor: Colors.blue,
borderWidth: 2,
// Aligns the chart title to left
alignment: ChartAlignment.near,
textStyle: ChartTextStyle(
color: Colors.red,
fontFamily: 'Roboto',
fontStyle: FontStyle.italic,
fontSize: 14,
)
),
// Initialize category axis
primaryXAxis: CategoryAxis(),
series: <ChartSeries>[
// Initialize line series
LineSeries<SalesData, String>(
dataSource: [
// Bind data source
SalesData('Jan', 35),
SalesData('Feb', 28),
SalesData('Mar', 34),
SalesData('Apr', 32),
SalesData('May', 40)
],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
final List<SalesData> chartData = [
SalesData(2010, 35),
SalesData(2011, 28),
SalesData(2012, 34),
SalesData(2013, 32),
SalesData(2014, 40)
];
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
Dashed line
The dashArray property of LineSeries is used to render line series with dashes. Odd value is considered
as rendering size and even value is considered as gap.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
LineSeries<SalesData, String>(
dataSource: chartData,
// Dash values for line
dashArray: <double>[5,5],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
Multi-colored line
To render a multi-colored line series, map the individual colors to the data using the pointColorMapper
property.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(),
series: <ChartSeries>[
LineSeries<SalesData, String>(
dataSource: [
SalesData('Jan', 35, Colors.red),
SalesData('Feb', 28, Colors.green),
SalesData('Mar', 34, Colors.blue),
SalesData('Apr', 32, Colors.pink),
SalesData('May', 40, Colors.black)
],
// Bind the color for all the data points from the data source
pointColorMapper:(SalesData sales, _) => sales.segmentColor,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
class SalesData {
SalesData(this.year, this.sales, this.segmentColor);
final double year;
final double sales;
final Color segmentColor;
}
Also refer, color palette, color mapping, animation, gradient and empty points for customizing the line
series further.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
// Renders fast line chart
FastLineSeries<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
Also refer, color palette, color mapping, animation, gradient and empty points for customizing the fast
line series further.
Area chart
To render an area chart, create an instance of AreaSeries, and add it to the series collection property of
SfCartesianChart. The area chart shows the filled area to represent the data, but when there are more
than a series, this may hide the other series. To get rid of this, increase or decrease the transparency of
the series.
The following properties are used to customize the appearance:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
// Renders area chart
AreaSeries<SalesData, double>(
dataSource: chartData,
Border customization
The borders of the area chart can be customized using the borderMode property. The default value of
the borderMode property is top. The other values are all and excludeBottom.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
AreaSeries<SalesData, double>(
dataSource: chartData,
color: Colors.deepOrange[300],
borderMode: AreaBorderMode.excludeBottom,
borderColor: Colors.green,
borderWidth: 2,
Also refer, color palette, color mapping, animation, gradient and empty points for customizing the area
series further.
Spline chart
To render a spline chart, create an instance of SplineSeries, and add it to the series collection property
of SfCartesianChart. The following properties are used to customize the appearance of spline segment:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
// Renders spline chart
SplineSeries<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
Dashed spline
The [dashArray]() property of the SplineSeries is used to render spline series with dashes. Odd value is
considered as rendering size and even value is considered as gap.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
SplineSeries<SalesData, String>(
dataSource: chartData,
// Dash values for spline
dashArray: <double>[5, 5],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
• natural
• monotonic
• cardinal
• clamped
The following code sample demonstrates how to set the splineType value to cardinal. When you set the
cardinal type, you can specify the desired line tension of the cardinal spline using the
cardinalSplineTension property. The value of this property ranges from 0 to 1.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
SplineSeries<SalesData, double>(
dataSource: chartData,
// Type of spline
splineType: SplineType.cardinal,
cardinalSplineTension: 0.9,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
Also refer, color palette, color mapping, animation, gradient and empty points for customizing the spline
series further.
Column chart
To render a column chart, create an instance of ColumnSeries, and add it to the [series]() collection
property of SfCartesianChart. The following properties are used to customize the appearance:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
// Renders column chart
ColumnSeries<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
ColumnSeries<SalesData, double>(
opacity: 0.9,
width: 0.4,
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.loss
)
]
)
)
)
);
}
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
ColumnSeries<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales,
width: 0.8, // Width of the columns
spacing: 0.2 // Spacing between the columns
)
]
)
)
)
);
}
Rounded corners
The borderRadius property is used to add the rounded corners to the rectangle.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
ColumnSeries<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales,
// Sets the corner radius
borderRadius: BorderRadius.all(Radius.circular(15))
)
]
)
)
)
);
}
Track customization
Renders column with track. Track is a rectangular bar rendered from the start to the end of the axis.
Column series will be rendered above the track. The isTrackVisible property is used to enable the track.
The following properties are used to customize the appearance:
DART
@override
Also refer, color palette, color mapping, animation, gradient and empty points for customizing the
column series further.
Bar chart
To render a bar chart, create an instance of BarSeries, and add it to the series collection property of
SfCartesianChart. The following properties are used to customize the appearance:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
// Renders bar chart
BarSeries<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
Rounded corners
The borderRadius property is used to add the rounded corners to the rectangle.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
BarSeries<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales,
borderRadius: BorderRadius.all(Radius.circular(15))
)
]
)
)
)
);
}
Track customization
You can render the bar chart with track. Track is a rectangular bar rendered from the start to the end of
the axis. Bar series will be rendered above the track. The isTrackVisible property is used to enable the
track. The following properties are used to customize the appearance:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
BarSeries<SalesData, double>(
dataSource: chartData,
// Renders the track
isTrackVisible: true,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
Also refer, color palette, color mapping, animation, gradient and empty points for customizing the bar
series further.
Bubble chart
To render a bubble chart, create an instance of BubbleSeries, and add it to the series collection property
of SfCartesianChart.
Bubble chart requires three fields (X, Y, and Size) to plot a point. Here, sizeValueMapper is used to map
the size of each bubble segment from data source.
DART
@override
Widget build(BuildContext context) {
final List<ChartData> chartData = [
ChartData(2010, 35, 0.32),
ChartData(2011, 38, 0.21),
ChartData(2012, 34, 0.38),
Also refer, color palette, color mapping, animation, gradient and empty points for customizing the
bubble series further.
Scatter chart
To render a scatter chart, create an instance of ScatterSeries, and add it to the series collection property
of SfCartesianChart. The following properties are used to customize the scatter segment appearance.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
// Renders scatter chart
ScatterSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y
)
]
)
)
)
);
}
)
)
)
);
}
Also refer, color palette, color mapping, animation, gradient and empty points for customizing the
scatter series further.
Step line chart
To render a step line chart, create an instance of StepLineSeries, and add it to the series collection
property of SfCartesianChart. The following properties are used to customize the appearance of spline
segment:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
// Renders step line chart
StepLineSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y
)
]
)
)
)
);
}
Also refer, color palette, color mapping, animation, gradient and empty points for customizing the step
line series further.
Range column chart
To render a range column chart, create an instance of RangeColumnSeries and add to the series
collection property of SfCartesianChart.
Since the RangeColumnSeries requires two Y values for a point, your data should contain high and low
values. High and low value specifies the maximum and minimum range of the point.
• highValueMapper - Field in the data source, which is considered as high value for the data
points.
• lowValueMapper - Field in the data source, which is considered as low value for the data points.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(),
series: <ChartSeries>[
RangeColumnSeries<ChartData, double>(
dataSource: <ChartData>[
ChartData('Jan', 3, 9),
ChartData('Feb', 4, 11),
ChartData('Mar', 6, 13),
ChartData('Apr', 9, 17),
ChartData('May', 12, 20),
],
xValueMapper: (ChartData sales, _) => sales.x,
lowValueMapper: (ChartData sales, _) => sales.low,
highValueMapper: (ChartData sales, _) => sales.high,
)
]
)
)
)
);
}
class ChartData {
ChartData(this.x, this.high, this.low);
final String x;
final double high;
final double low;
}
Data label
In the range column chart when data label is enabled, by default there will be two values displayed
namely, high and low, but in the other types of charts, only y value will be displayed.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(),
series: <ChartSeries>[
RangeColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
lowValueMapper: (ChartData sales, _) => sales.low,
highValueMapper: (ChartData sales, _) => sales.high,
dataLabelSettings: DataLabelSettings(
isVisible: true,
position: CartesianLabelPosition.top
),
)
]
)
)
)
);
}
• highValueMapper - Field in the data source, which is considered as high value for the data
points.
• lowValueMapper - Field in the data source, which is considered as low value for the data points.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
RangeAreaSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
lowValueMapper: (ChartData sales, _) => sales.low,
highValueMapper: (ChartData sales, _) => sales.high,
)
]
)
)
)
);
}
class ChartData {
ChartData(this.x, this.high, this.low);
final double x;
final double high;
final double low;
}
Border customization
The borders of the range area chart can be customized using the borderDrawMode property. The
default value of the borderMode property is all and the other value is excludeSides.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
RangeAreaSeries<SalesData, double>(
dataSource: chartData,
color: Colors.deepOrange[300],
borderDrawMode: RangeAreaBorderMode.excludeSides,
borderColor: Colors.green,
borderWidth: 2,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
SplineAreaSeries<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
• natural
• monotonic
• cardinal
• clamped
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StepAreaSeries<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
)
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedLineSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y1
),
StackedLineSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y2
),
StackedLineSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y3
),
StackedLineSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
Grouping series
You can group and stack the similar stacked series types using the groupName property of stacked
series. The stacked series that contains the same groupName will be stacked in a single group.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedLineSeries<ChartData, double>(
groupName: 'Group A',
dataLabelSettings: DataLabelSettings(
isVisible: true,
useSeriesColor: true
),
dataSource: chartData,
),
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y2
),
StackedLineSeries<ChartData, double>(
groupName: 'Group A',
dataLabelSettings: DataLabelSettings(
isVisible: true,
showCumulativeValues: true,
useSeriesColor: true
),
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y3
),
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedAreaSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y1
),
StackedAreaSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y2
),
StackedAreaSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y3
),
]
)
)
)
);
}
Grouping series
You can group and stack the similar stacked series types using the groupName property of stacked
series. The stacked series that contains the same groupName will be stacked in a single group.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedAreaSeries<ChartData, double>(
groupName: 'Group A',
dataLabelSettings: DataLabelSettings(
isVisible: true,
useSeriesColor: true
),
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y1
),
StackedAreaSeries<ChartData, double>(
groupName: 'Group B',
dataLabelSettings: DataLabelSettings(
isVisible: true,
useSeriesColor: true
),
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y2
),
StackedAreaSeries<ChartData, double>(
groupName: 'Group A',
dataLabelSettings: DataLabelSettings(
isVisible: true,
useSeriesColor: true
),
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y3
),
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y1
),
StackedColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
Grouping series
You can group and stack the similar stacked series types using the groupName property of stacked
series. The stacked series that contains the same groupName will be stacked in a single group.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedColumnSeries<ChartData, double>(
groupName: 'Group A',
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y1
),
StackedColumnSeries<ChartData, double>(
groupName: 'Group B',
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y2
),
StackedColumnSeries<ChartData, double>(
groupName: 'Group A',
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y3
),
StackedColumnSeries<ChartData, double>(
groupName: 'Group B',
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y4
)
]
)
)
)
);
}
StackedColumnSeries<ChartData, double>(
groupName: 'Group A',
dataLabelSettings: DataLabelSettings(isVisible:true, showCumulativeValues:
true),
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y3
),
StackedColumnSeries<ChartData, double>(
groupName: 'Group B',
dataLabelSettings: DataLabelSettings(isVisible:true, showCumulativeValues:
true),
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y4
)
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedBarSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y1
),
StackedBarSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y2
),
StackedBarSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y3
),
StackedBarSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y4
)
]
)
)
)
);
}
Grouping series
You can group and stack the similar stacked series types using the groupName property of stacked
series. The stacked series that contains the same groupName will be stacked in a single group.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedBarSeries<ChartData, double>(
groupName: 'Group A',
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y1
),
StackedBarSeries<ChartData, double>(
groupName: 'Group B',
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y2
),
StackedBarSeries<ChartData, double>(
groupName: 'Group A',
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedArea100Series<ChartData, DateTime>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.year,
yValueMapper: (ChartData sales, _) => sales.sales1
),
StackedArea100Series<ChartData, DateTime>(
dataSource: chartData,
DART
@override
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedBar100Series<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
),
StackedBar100Series<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales2
),
StackedBar100Series<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales3
),
StackedBar100Series<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales4
)
]
)
)
)
);
}
StackedBar100Series<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales2,
width: 0.8,
spacing: 0.2
)
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedLine100Series<SalesData, double>(
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.year,
Dashed line
The dashArray property of StackedLine100Series is used to render line series with dashes. Odd value
is considered as rendering size and even value is considered as gap.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <ChartSeries>[
StackedLine100Series<SalesData, String>(
dataSource: chartData,
dashArray: <double>[5,5],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
),
StackedLine100Series<SalesData, String>(
dataSource: chartData,
dashArray: <double>[5,5],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales2
),
StackedLine100Series<SalesData, String>(
dataSource: chartData,
dashArray: <double>[5,5],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales3
),
StackedLine100Series<SalesData, String>(
dataSource: chartData,
dashArray: <double>[5,5],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales4
)
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
final List<ChartData> chartData = [
ChartData('David', 25),
ChartData('Steve', 38),
ChartData('Jack', 34),
ChartData('Others', 52)
];
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(series: <CircularSeries>[
// Render pie chart
PieSeries<ChartData, String>(
dataSource: chartData,
pointColorMapper:(ChartData data, _) => data.color,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
)
)
)
);
}
class ChartData {
ChartData(this.x, this.y, [this.color]);
final String x;
final double y;
final Color color;
}
Exploding a segment
You can explode a pie segment by enabling the explode property. The following properties are used to
customize the explode options:
• explodeIndex - Specifies the index of the slice to explode it at the initial rendering.
• explodeOffset - Specifies the offset of exploded slice. The value ranges from 0% to 100%.
• explodeGesture - Gesture for activating the explode. Explode can be activated in single tap,
double tap, and long press. The available gesture types are singleTap, doubleTap, longPress, and
none and the default value is singleTap.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
// Segments will explode on tap
explode: true,
// First segment will be exploded on initial rendering
explodeIndex: 1
)
]
)
)
)
);
}
)
);
}
Angle of pie
SfCircularChart allows you to render all the data points or segments in semi-pie, quarter-pie, or in any
sector using the startAngle and endAngle properties.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
startAngle: 270, // starting angle of pie
endAngle: 90 // ending angle of pie
)
]
)
)
)
);
)
)
);
}
)
]
)
)
)
);
}
class ChartData {
ChartData(this.x, this.y, this.size);
final String x;
final double y;
final String size;
}
Doughnut chart
To render a doughnut chart, create an instance of DoughnutSeries, and add it to the series collection
property of SfCircularChart. The following properties are used to customize the appearance of doughnut
segment:
DART
@override
Rounded corners
The cornerStyle property specifies the corner type for doughnut chart. The corners can be customized
using the bothFlat, bothCurve, startCurve, and endCurve options. The default value of this property is
bothFlat.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
series: <CircularSeries>[
DoughnutSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
// Corner style of doughnut segment
cornerStyle: CornerStyle.bothCurve
)
]
)
)
)
);
}
Exploding a segment
You can explode a doughnut segment by enabling the explode property. The following properties are
used to customize the explode options:
• explodeIndex - Specifies the index of the slice to explode it at the initial rendering.
• explodeOffset - Specifies the offset of exploded slice. The value ranges from 0% to 100%.
• explodeGesture - Gesture for activating the explode. Explode can be activated in single tap,
double tap, and long press. The available gesture types are singleTap, doubleTap, longPress, and
none. The default value is singleTap.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
series: <CircularSeries>[
DoughnutSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
// Explode the segments on tap
explode: true,
explodeIndex: 1
)
]
)
)
)
);
}
Angle of doughnut
SfCircularChart allows you to render all the data points or segments in semi-pie, quarter-pie, or in any
sector using the startAngle and endAngle properties.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
series: <CircularSeries>[
DoughnutSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
startAngle: 270, // Starting angle of doughnut
endAngle: 90 // Ending angle of doughnut
)
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
series: <CircularSeries>[
// Renders radial bar chart
RadialBarSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
)
)
)
);
}
series: <CircularSeries>[
RadialBarSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
// Radius of the radial bar
radius: '50%'
)
]
)
)
)
);
}
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
// Radius of the radial bar's inner circle
innerRadius: '80%'
)
]
)
)
)
);
}
Rounded corners
The cornerStyle property specifies the corner type for radial bar chart. The corners can be customized
using the bothFlat, bothCurve, startCurve, and endCurve options. The default value of this property is
bothFlat.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
series: <CircularSeries>[
RadialBarSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
// Corner style of radial bar segment
cornerStyle: CornerStyle.bothCurve
)
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
series: <CircularSeries>[
RadialBarSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
dataLabelSettings: DataLabelSettings(
// Renders the data label
isVisible: true
)
)
]
)
)
)
);
}
Pyramid Chart
To render a pyramid chart, create an instance of PyramidSeries, and add it to the series property of
SfPyramidChart. The following properties are used to customize the appearance of a pyramid segment.
DART
@override
Pyramid modes
You can render the pyramid series as linear or surface mode. In linear mode, the height of the pyramid
segment is based on the Y value, and in surface mode, area of the pyramid segment is based on the Y
value. The default value of pyramidMode property is linear.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfPyramidChart(
series: PyramidSeries<ChartData, String>(
pyramidMode: PyramidMode.surface
)
)
)
)
);
}
)
)
)
);
}
Explode segments
You can explode a pyramid segment using the explodeIndex property. The explodeOffset property is
used to specify the exploded segment’s distance.
Also, the segments can be exploded by tapping the segment.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfPyramidChart(
series: PyramidSeries<ChartData, String>(
explode: true,
explodeOffset: '5%',
explodeIndex: 2,
)
)
)
)
);
• shift - Shifts the data label position when a label intersects with other label.
• none - Renders all the data label when intersect.
• hide - Hides the intersecting data label, and it is the default value.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfPyramidChart(
smartLabelMode: SmartLabelMode.shift,
series: PyramidSeries<ChartData, String>(
dataLabelSettings: DataLabelSettings(
isVisible: true,
labelPosition: LabelPosition.inside
),
)
)
)
)
);
}
Funnel Chart
To render a funnel chart, create an instance of FunnelSeries, and add it to the series property of
SfFunnelChart. The following properties are used to customize the appearance of a funnel segment:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfFunnelChart(
series: FunnelSeries<ChartData, String>(
dataSource: [
ChartData('Walnuts', 654),
ChartData('Almonds', 575),
ChartData('Soybeans', 446),
ChartData('Black beans', 341),
ChartData('Mushrooms', 296),
ChartData('Avacado', 160),
],
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y)
)
)
)
);
}
class ChartData {
ChartData(this.x, this.y, [this.color]);
final String x;
final double y;
final Color color;
}
Explode segments
You can explode a funnel segment using the explodeIndex property. The explodeOffset property is used
to specify the exploded segment’s distance.
Also, the segments can be exploded by tapping the segment.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfFunnelChart(
series: FunnelSeries<ChartData, String>(
explode: true,
explodeOffset: '5%',
explodeIndex: 2,
)
)
)
)
);
}
• shift - Shifts the data label position when a label intersects with other label.
• none - Renders all the data labels when intersect.
• hide - Hides the intersecting data label, and it is the default value.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfFunnelChart(
smartLabelMode: SmartLabelMode.shift,
series: FunnelSeries<ChartData, String>(
dataLabelSettings: DataLabelSettings(
isVisible: true,
labelPosition: LabelPosition.inside
),
)
)
)
)
);
}
)
)
);
}
• Cartesian type series cannot be combined with circular series (pie, doughnut, and radial bar).
Series customization
Animation
SfCartesianChart provides animation support for the series. Series will be animated while rendering.
Animation is enabled by default, you can also control the duration of the animation using
animationDuration property. You can disable the animation by setting 0 value to that property.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(),
series: <CartesianSeries>[
ColumnSeries<ChartData, String>(
dataSource: chartData,
Color palette
The palette property is used to define the colors for the series available in chart. By default, a set of 10
colors are predefined for applying it to the series. If the colors specified in the series are less than the
number of series, than the remaining series are filled with the specified palette colors rotationally.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(),
// Palette colors
palette: <Color>[
Colors.teal,
Colors.orange,
Colors.brown
],
series: <CartesianSeries>[
ColumnSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
),
ColumnSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y2
),
ColumnSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y3
)
]
)
)
)
);
}
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(),
series: <CartesianSeries>[
ColumnSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
// Map color for each data points from the data source
pointColorMapper: (ChartData data, _) => data.color
)
]
)
)
)
);
}
class ChartData {
ChartData(this.x, this.y, this.color);
final String x;
final double y;
final Color color;
}
Gradient fill
The gradient property is used to define the gradient colors. The colors from this property is used for
series.
DART
@override
Widget build(BuildContext context) {
final List<Color> color = <Color>[];
color.add(Colors.deepOrange[50]);
color.add(Colors.deepOrange[200]);
color.add(Colors.deepOrange);
final List<double> stops = <double>[];
stops.add(0.0);
stops.add(0.5);
stops.add(1.0);
final LinearGradient gradientColors =
LinearGradient(colors: color, stops: stops);
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <CartesianSeries>[
AreaSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
// Applies gradient color
gradient: gradientColors
)
]
)
)
)
);
}
Empty points
The data points that has null value are considered as empty points. Empty data points are ignored and
not plotted in the chart. By using emptyPointSettings property in series, you can decide the action taken
for empty points. Available modes are gap, zero, drop and average. Default mode of the empty point is
gap.
DART
@override
Widget build(BuildContext context) {
final List<ChartData> chartData = [
ChartData(1, 112),
ChartData(2, null),
ChartData(3, 107),
ChartData(4, 87)
];
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
emptyPointSettings: EmptyPointSettings(
// Mode of empty point
mode: EmptyPointMode.average
)
)
]
)
)
)
);
}
Sorting
The chart’s data source can be sorted using the sortingOrder and sortFieldValueMapper properties of
series. The sortingOrder property specifies the data points in the series can be sorted in ascending or
descending order. The data points will be rendered in the specified order if sortingOrder is set to none.
The sortFieldValueMapper specifies the field in the data source, which is considered for sorting the data
points.
DART
@override
Axis
Charts typically have two axes that are used to measure and categorize data: a vertical (Y) axis, and a
horizontal (X) axis.
Vertical(Y) axis always uses numerical scale. Horizontal(X) axis supports the following types of scale:
• Category
• Numeric
• Date-time
• Logarithmic
Numeric axis
Numeric axis uses numerical scale and displays numbers as labels. By default, Numeric Axis is set to both
horizontal axis and vertical axis.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: NumericAxis(),
primaryYAxis: NumericAxis()
)
)
)
);
}
Customizing range
To customize the range of an axis, use the minimum and maximum properties of NumericAxis. By
default, nice range will be calculated automatically based on the provided data.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryYAxis: NumericAxis(
minimum: 10,
maximum: 50
)
)
)
)
);
}
Customizing interval
Axis interval can be customized using the interval property of ChartAxis. By default, nice interval will be
calculated based on the minimum and maximum values of the provided data.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryYAxis: NumericAxis(
// axis interval is set to 10
interval: 10
)
)
)
)
);
}
• additional
• auto
• none
• normal
• round
additional
When the value of rangePadding property is additional, the axis range will be rounded and an interval of
the axis will be added as padding to the minimum and maximum values of the range.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryYAxis: NumericAxis(
// Additional range padding is applied to y axis
rangePadding: ChartRangePadding.additional
)
)
)
)
);
}
auto
When the value of rangePadding property is auto, the horizontal numeric axis takes none for padding
calculation, whereas the vertical numeric axis takes normal for padding calculation. This is also the
default value of rangePadding.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryYAxis: NumericAxis(
rangePadding: ChartRangePadding.auto
)
)
)
)
);
}
none
When the value of rangePadding property is none, padding will not be applied to the axis.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryYAxis: NumericAxis(
rangePadding: ChartRangePadding.none
)
)
)
)
);
}
normal
When the value of rangePadding property is normal, padding is applied to the axis based on the default
range calculation.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryYAxis: NumericAxis(
rangePadding: ChartRangePadding.normal
)
)
)
)
);
}
round
When the value of rangePadding property is round, axis range will be rounded to the nearest possible
numeric value.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryYAxis: NumericAxis(
rangePadding: ChartRangePadding.round
)
)
)
)
);
}
Also refer label format and date format for formatting the labels further.
Category axis
Category axis displays text labels instead of numbers. When the string values are bound to x values, then
the x-axis must be initialized with CategoryAxis.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis()
)
)
)
);
}
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(
// Axis will be rendered based on the index values
arrangeByIndex: true
),
series: <ChartSeries<ChartData, String>>[
ColumnSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y,
),
ColumnSeries<ChartData, String>(
dataSource: chartData2,
xValueMapper: (ChartData sales, _) => sales.x,
yValueMapper: (ChartData sales, _) => sales.y,
)
]
)
)
)
);
}
Date-time axis
The date-time axis uses date-time scale and displays date-time values as axis labels in specified format.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: DateTimeAxis()
)
)
)
);
}
Customizing range
To customize the range of an axis, use the minimum and maximum properties of DateTimeAxis. By
default, nice range will be calculated automatically based on the provided data.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: DateTimeAxis(
minimum: DateTime(2010),
maximum: DateTime(2020)
)
)
)
)
);
}
Date-time intervals
The date-time intervals can be customized using the interval and intervalType properties of
DateTimeAxis. For example, setting interval as 2 and intervalType as years will consider 2 years as
interval.
The Flutter Chart supports the following types of interval for date-time axis:
• auto
• years
• months
• days
• hours
• minutes
• seconds
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: DateTimeAxis(
// Interval type will be months
intervalType: DateTimeIntervalType.months,
interval: 2
)
)
)
)
);
}
• none
• round
• additional
• normal
none
When the value of rangePadding property is none, padding will not be applied to the axis.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: DateTimeAxis(
rangePadding: ChartRangePadding.none
)
)
)
)
);
}
round
When the value of rangePadding property is round, axis range will be rounded to the nearest possible
date-time value.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: DateTimeAxis(
rangePadding: ChartRangePadding.round
)
)
)
)
);
}
additional
When the value of rangePadding property is additional, range will be rounded and date-time interval of
the axis will be added as padding to the minimum and maximum extremes of a range.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: DateTimeAxis(
rangePadding: ChartRangePadding.additional
)
)
)
)
);
}
normal
When the value of rangePadding property is normal, padding is applied to the axis based on the default
range calculation.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: DateTimeAxis(
rangePadding: ChartRangePadding.normal
)
)
)
)
);
}
Also refer label format and number format for formatting the labels further.
Logarithmic axis
Logarithmic axis uses logarithmic scale and displays numbers as axis labels.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: NumericAxis(),
primaryYAxis: LogarithmicAxis()
)
)
)
);
}
Axis customization
Common axis features
Customization of features such as axis title, labels, grid lines and tick lines are common to all the axes.
Each of these features are explained in this section.
Axis Visibility
Axis visibility can be controlled using the isVisible property of axis. Default value of isVisible is true.
When the axis visibility is set to false, then the axis elements like ticks, labels, title, etc will be hidden.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: NumericAxis(
// X axis is hidden now
isVisible: false
)
)
)
)
);
}
Axis title
The title property in axis provides options to customize the text and font of axis title. Axis does not
display title by default. The title can be customized using following properties,
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(
title: AxisTitle(
text: 'X-Axis',
textStyle: ChartTextStyle(
color: Colors.deepOrange,
fontFamily: 'Roboto',
fontSize: 16,
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w300
)
)
)
)
)
)
);
}
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(
axisLine: AxisLine(
color: Colors.deepOrange,
width: 2,
dashArray: <double>[5,5]
)
)
)
)
)
);
}
• labelStyle – used to change the text color, size, font family, font style, and font weight.
• color – used to change the color of the axis label.
• fontFamily - used to change the font family for the axis label.
• fontStyle - used to change the font style for the axis label.
• fontWeight - used to change the font weight for the axis label.
• fontSize - used to change the font size for the axis label.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: NumericAxis(
labelStyle: ChartTextStyle(
color: Colors.deepOrange,
fontFamily: 'Roboto',
fontSize: 14,
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w500
)
)
)
)
)
);
}
)
);
}
Also refer number format and date format for formatting the labels further.
Label and tick positioning
Axis labels and ticks can be positioned inside or outside the chart area by using labelPosition and
tickPosition properties of ChartAxis. By default labels and ticks will be positioned outside the chart area.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(
labelPosition: LabelPosition.inside,
tickPosition: TickPosition.inside
)
)
)
)
);
}
We have provided options to change the width, dashes, color of grid lines. By default minor grid lines
will not be visible.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: NumericAxis(
majorGridLines: MajorGridLines(
width: 1,
color: Colors.red,
dashArray: <double>[5,5]
),
minorGridLines: MinorGridLines(
width: 1,
color: Colors.green,
dashArray: <double>[5,5]
),
minorTicksPerInterval:2
)
)
)
)
);
}
Inversing axis
Axis can be inversed using the isInversed property of an axis. Default value of isInversed property is
false.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: NumericAxis(
// X axis will be inversed
isInversed: true
)
)
)
)
);
}
Visible minimum
The visibleMinimum property is used to set the minimum visible range of an axis. When panning is
enabled, you can pan to the actual minimum range of an axis.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: NumericAxis(
visibleMinimum: 2
)
)
)
)
);
}
)
)
)
)
);
}
Axis crossing
Axis can be positioned anywhere in the plot area using the crossesAt property. This property specifies
where the horizontal axis should intersect or cross the vertical axis, or vice-versa. The default value of
the crossesAt property is null.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis:NumericAxis(
crossesAt: 0
),
primaryYAxis:NumericAxis(
crossesAt: 0
)
)
)
)
);
}
Plot bands
Plot bands are also known as strip lines, which are used to shade the different ranges in plot area with
different colors to improve the readability of the chart. You can also add a text to indicate what that
particular region indicates. You can enable the plot bands to be drawn repeatedly at regular intervals.
This will be useful when you need to mark an event that occurs recursively along the timeline of the
chart.
Since plot bands are drawn based on the axis, you have to add plot bands using the plotBands property
of the respective axis. You can also add multiple plot bands to an axis.
The following properties are used to configure the plot bands:
The following code snippet and screenshot demonstrate this feature by highlighting weekends.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis:DateTimeAxis(
plotBands: <PlotBand>[
PlotBand(
isVisible: true,
isRepeatable: true,
repeatEvery: 2,
size: 1,
sizeType: DateTimeIntervalType.months,
repeatUntil: DateTime(2018, 6, 1),
),
)
)
)
);
}
isVisible: true,
start: DateTime(2018,2,1),
end: DateTime(2018,6,1),
associatedAxisStart: 8,
associatedAxisEnd: 15,
shouldRenderAboveSeries: true,
color: const Color.fromRGBO(224, 155, 0, 1)
),
)
)
)
);
}
Multiple axes
By default, the chart is rendered with primary x axis and primary y axis. But, the users can add n number
of axis to the chart. An additional horizontal or vertical axis can be added to the chart using the axes
property, and then you can associate it to a series by specifying the name of the axis to the xAxisName
or yAxisName property in the series.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: CategoryAxis(
title: AxisTitle(text: 'Primary X Axis')
),
primaryYAxis: NumericAxis(
title: AxisTitle(
text: 'Primary Y Axis'
)
),
// adding multiple axis
axes: <ChartAxis>[
NumericAxis(
name: 'xAxis',
opposedPosition: true,
interval:1,
minimum: 0,
maximum: 5,
title: AxisTitle(
text: 'Secondary X Axis'
)
),
NumericAxis(
name: 'yAxis',
opposedPosition: true,
title: AxisTitle(
text: 'Secondary Y Axis'
)
)
],
series: <ChartSeries>[
LineSeries<SalesData, String>(
dataSource: [
SalesData('Jan', 35),
SalesData('Feb', 28),
SalesData('Mar', 34),
SalesData('Apr', 32),
SalesData('May', 40)
],
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales
),
LineSeries<SalesData, double>(
dataSource: [
SalesData('Jan', 15, 1),
SalesData('Feb', 11, 2),
SalesData('Mar', 14, 3),
SalesData('Apr', 12, 4),
],
xValueMapper: (SalesData sales, _) => sales.numeric,
yValueMapper: (SalesData sales, _) => sales.sales,
xAxisName: 'xAxis',
yAxisName: 'yAxis'
)
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <CartesianSeries>[
LineSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
// Renders the marker
markerSettings: MarkerSettings(
isVisible: true
)
)
]
)
)
)
);
}
• circle
• rectangle
• image
• pentagon
• verticalLine
• horizontalLine
• diamond
• triangle
• invertedTriangle
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <CartesianSeries>[
LineSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
markerSettings: MarkerSettings(
isVisible: true,
// Marker shape is set to diamond
shape: DataMarkerType.diamond
)
)
]
)
)
)
);
}
Image marker
The markers can be rendered with desired image as shape. For this you have to specify the shape as
[image]() and refer the image path using imageUrl property.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <CartesianSeries>[
LineSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
markerSettings: MarkerSettings(
isVisible: true,
shape: DataMarkerType.image,
// Renders the image as marker
imageUrl: 'images/livechart.png'
)
)
]
)
)
)
);
}
Data label
Data label can be added to a chart series by enabling the isVisible option in the dataLabelSettings. You
can use the following properties to customize the appearance.
• color – used to change the background color of the data label shape.
• borderWidth – used to change the stroke width of the data label shape.
• borderColor – used to change the stroke color of the data label shape.
• alignment - aligns the data label text to near, center and far.
• textStyle – used to change the data label text color, size, font family, font style, and font weight.
• color – used to change the color of the data label.
• fontFamily - used to change the font family for the data label.
• fontStyle - used to change the font style for the data label.
• fontWeight - used to change the font weight for the data label.
• fontSize - used to change the font size for the data label.
• margin - used to change the margin size for data labels.
• opacity - used to control the transparency of the data label.
• labelAlignment - used to align the Cartesian data label positions. The available options to
customize the positions are outer, auto, top, bottom and middle.
• borderRadius - used to add the rounded corners to the data label shape.
• [angle]() - used to rotate the labels.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <CartesianSeries>[
LineSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
dataLabelSettings: DataLabelSettings(
// Renders the data label
isVisible: true
)
)
]
)
)
)
);
}
)
);
}
Label position
The labelAlignment property is used to position the Cartesian chart type data labels at top, bottom,
auto, outer and middle position of the actual data point position. By default, labels are auto positioned.
You can move the labels horizontally and vertically using OffsetX and OffsetY properties respectively.
The labelPosition property is used to place the circular series data labels either inside or outside. By
default the label of circular chart is placed inside the series.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
series: <CircularSeries>[
PieSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
dataLabelSettings: DataLabelSettings(
isVisible: true,
// Positioning the data label
labelPosition: ChartDataLabelPosition.outside
)
)
]
)
)
)
);
}
Note: The labelAlignment property is used to position the Cartesian chart labels whereas labelPosition
property is used to position the circular chart labels.
Smart labels
This feature is used to arrange the data labels smartly and avoid the intersection when there is
overlapping of labels. The property enableSmartLabels in CircularSeries is used to arrange the data
labels smartly. By default, this property is true.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child:SfCircularChart(
series: <CircularSeries>[
PieSeries<ChartData, double>(
// Avoid labels intersection
enableSmartLabels: true,
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
dataLabelMapper: (ChartData data, _) => data.x,
dataLabelSettings: DataLabelSettings(
isVisible: true,
labelPosition: ChartDataLabelPosition.inside
)
)
]
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child:SfCircularChart(
series: <CircularSeries>[
PieSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
dataLabelMapper: (ChartData data, _) => data.x,
dataLabelSettings: DataLabelSettings(
isVisible: true,
labelPosition: ChartDataLabelPosition.outside,
// Renders background rectangle and fills it with series color
useSeriesColor: true
)
)
]
)
)
)
);
}
Connector line
This feature is used to connect label and data point using a line. It can be enabled for Pie and Doughnut
chart types. The connectorLineSettings property used to customize the connector line.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
series: <CircularSeries>[
PieSeries<ChartData, double>(
enableSmartLabels: true,
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
dataLabelSettings: DataLabelSettings(
isVisible: true,
labelPosition: ChartDataLabelPosition.outside,
connectorLineSettings: ConnectorLineSettings(
// Type of the connector line
type: ConnectorType.curve
)
)
)
]
)
)
)
);
}
];
return Scaffold(
body: Center(
child: Container(
child:SfCircularChart(
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
// Map the data label text for each point from the data source
dataLabelMapper: (ChartData data, _) => data.text,
dataLabelSettings: DataLabelSettings(
isVisible: true
)
)
]
)
)
)
);
}
class ChartData {
ChartData(this.x, this.y, this.text);
final String x;
final double y;
final String text;
}
Label template
You can customize the appearance of the data label with your own template using the builder property
of dataLabelSettings.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child:SfCircularChart(
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
dataLabelMapper: (ChartData data, _) => data.text,
dataLabelSettings: DataLabelSettings(
isVisible: true,
// Templating the data label
builder: (dynamic data, dynamic point, dynamic series, int pointIndex, int
seriesIndex) {
return Container(
height: 30,
width: 30,
child: Image.asset('images/livechart.png')
);
}
)
)
]
)
)
)
);
}
Legend
The legend contains list of chart series/data points in chart. The information provided in each legend
item helps to identify the corresponding data series in chart.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child:SfCircularChart(
// Enables the legend
legend: Legend(isVisible: true),
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
)
)
)
);
}
Customizing legend
The name property of CartesianSeries is used to define the label for the corresponding series legend
item and for CircularSeries type chart by default values mapped with xValueMapper will be displayed.
The appearance of the label can be customized using the below properties.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child:SfCircularChart(
legend: Legend(
isVisible: true,
// Border color and border width of legend
borderColor: Colors.black,
borderWidth: 2
),
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
)
)
)
);
}
Legend title
The following properties are used to define and customize the title of legend.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child:SfCircularChart(
legend: Legend(
isVisible: true,
// Legend title
title: LegendTitle(
text:'Country',
textStyle: ChartTextStyle(
color: Colors.red,
fontSize: 15,
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w900
)
),
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
),
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
)
)
)
);
}
Legend visibility
The isVisible property of legend is used to toggle the visibility of legend.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child:SfCircularChart(
legend: Legend(
// Visibility of legend
isVisible: false
),
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
)
)
)
);
Legend overflow
The legend items can be placed in multiple rows or scroll can be enabled using the overflowMode
property if size of the total legend items exceeds the available size. The default value of the
overflowMode property is scroll.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
legend: Legend(
isVisible: true,
// Overflowing legend content will be wraped
overflowMode: LegendItemOverflowMode.wrap
),
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
)
)
)
);
}
)
Positioning the legend
You can change the position of the legend inside the chart. The following properties are used to
customize the position of legend. auto position will place the legend at the right, if the chart's width is
greater than the chart's height. Else the legend will be placed at the bottom position.
• [position]() – used to position the legend relatively. The available options are [auto](),
[bottom](), [left](), [right](), and [top](). Defaults to auto.
• [orientation]() - used to change the orientation of the legend, the default value is [auto](). Also
you can set [horizontal]() or [vertical]().
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCircularChart(
legend: Legend(
isVisible: true,
// Legend will be placed at the left
position: LegendPosition.left
),
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
),
]
)
)
)
);
}
)
Legend item template
You can customize the appearance of legend items with your template by using legendItemBuilder
property of legend. Here you can specify the content that needs to be displayed in the legend text as
widget.
DART
@override
Appearance
Chart sizing
Chart renders based on the parent widget size. If you need the chart to be rendered in specific size, then
set the size(width/height) to the parent widget.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
height: 300, // height of the Container widget
width: 350, // width of the Container widget
child: SfCartesianChart()
)
)
)
);
}
Chart margin
Margin to the chart can be specified using the margin property.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
height: 300,
width: 350,
child: SfCartesianChart(
borderColor: Colors.red,
borderWidth: 2,
// Sets 15 logical pixels as margin for all the 4 sides.
margin: EdgeInsets.all(15)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
height: 300,
width: 350,
child: SfCartesianChart(
plotAreaBorderWidth: 5,
plotAreaBorderColor: Colors.red,
plotAreaBackgroundColor: Colors.lightGreen,
plotAreaBackgroundImageUrl: 'images/livechart.png'
)
)
)
)
);
}
Annotation
Chart supports annotations which allows you to mark the specific area of interest in the chart area. You
can add the custom widgets using this annotations feature as depicted below.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
child: SfCartesianChart(
annotations: <CartesianChartAnnotation>[
CartesianChartAnnotation(
widget:
Container(
child: const Text('Annotation')
),
coordinateUnit: CoordinateUnit.point,
x: 'USA',
y: 20
)
]
)
)
)
)
);
}
],
)
)
)
),
);
}
child: Container(
child: SfCartesianChart(
annotations: <CartesianChartAnnotation>[
CartesianChartAnnotation(
widget: Container(child: const Text('Low')),
coordinateUnit: CoordinateUnit.point,
x: 15,
y: 50
),
CartesianChartAnnotation(
widget: Container(child: const Text('High')),
coordinateUnit: CoordinateUnit.point,
x: 35,
y: 130,
yAxisName: 'YAxis' // Refers to the additional axis
)
],
primaryYAxis: NumericAxis(minimum: 0, maximum: 80),
axes: <ChartAxis>[
NumericAxis(name: 'YAxis', opposedPosition: true)
],
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
),
ColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y2,
yAxisName: 'YAxis'
)
]
)
)
)
)
);
}
class ChartData {
ChartData(this.x, this.y, this.y2);
final double x;
final double y;
final double y2;
}
Selection zooming
By specifying enableSelectionZooming property to true, you can long press and drag to select a range on
the chart to be zoomed in.
Selection rectangle customization
You can customize the selection rectangle using the below properties.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
height: 300,
width: 350,
child: SfCartesianChart(
zoomPanBehavior: ZoomPanBehavior(
enableSelectionZooming: true,
selectionRectBorderColor: Colors.red,
selectionRectBorderWidth: 1,
selectionRectColor: Colors.grey
)
)
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: NumericAxis(
crosshairTooltip: InteractiveTooltip(
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
child: SfCartesianChart(
zoomPanBehavior: ZoomPanBehavior(
maximumZoomLevel: 3
)
)
)
)
)
);
}
Also refer zooming, zoom start and zoom end events for customizing the zooming further.
Trackball and Crosshair
Trackball
Trackball feature displays the tooltip for the data points that are closer to the point where you touch on
the chart area. This feature, especially, can be used instead of data label feature when you cannot show
data labels for all data points due to space constraint. This feature can be enabled using enable property
of trackballBehavior. Trackball will be activated once you long-press anywhere on the chart area. Once it
is activated, it will appear in the UI and move based on your touch movement until you stop touching on
the chart.
You can use the following properties to customize the appearance of trackball tooltip.
• lineType - specifies the type of trackball line. By default, vertical line will be displayed.
• lineColor - specifies the color of the trackball line.
• lineWidth - specifies the stroke width of the trackball line.
• lineDashArray- used to render trackball line with dashes.
• shouldAlwaysShow - used to show the trackball even after the touch end.
• tooltipSettings.borderWidth – used to change the stroke width of the axis tooltip.
• tooltipSettings.borderColor – used to change the stroke color of the axis tooltip.
• tooltipSettings.arrowLength - specifies the length of the tooltip arrow.
• tooltipSettings.arrowWidth - specifies the width of the tooltip arrow.
• tooltipSettings.format - by default, axis value will be displayed in the tooltip, and it can be
customized by adding desired text as prefix or suffix.
• tooltipSettings.textStyle – used to change the text color, size, font family, fontStyle, and font
weight.
• tooltipSettings.textStyle.color – used to change the color of the tooltip text.
• tooltipSettings.textStyle.fontFamily - used to change the font family for tooltip text.
• tooltipSettings.textStyle.fontStyle – used to change the font style for tooltip text.
• tooltipSettings.textStyle.fontSize - used to change the font size for tooltip text.
• hideDelay - used to specify disappear delay for trackball.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
child: SfCartesianChart(
trackballBehavior: TrackballBehavior(
// Enables the trackball
enable: true,
tooltipSettings: InteractiveTooltip(
enable: true,
color: Colors.red
)
)
)
)
)
)
);
}
• floatAllPoints – Displays label for all the data points along the tracker line.
• nearestPoint – Displays label for single data point that is nearer to the touch contact position.
• groupAllPoints – Displays label for all the data points grouped and positioned at the top of the
chart area.
• none - Doesn't display the label.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
child: SfCartesianChart(
trackballBehavior: TrackballBehavior(
enable: true,
// Display mode of trackball tooltip
tooltipDisplayMode: TrackballDisplayMode.floatAllPoints
)
)
)
)
)
);
}
Label alignment
The position of trackball tooltip can be changed using the tooltipAlignment property of
trackballBehavior. The following options are available in tooltipAlignment.
• near - aligns the trackball tooltip to the top position of plot area.
• far - aligns the trackball tooltip to the bottom position of plot area.
• center - aligns the trackball tooltip to the center position of plot area.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
child: SfCartesianChart(
trackballBehavior: TrackballBehavior(
enable: true,
tooltipAlignment: ChartAlignment.near,
tooltipDisplayMode: TrackballDisplayMode.groupAllPoints
)
)
)
)
)
);
}
Activation mode
The activationMode property is used to restrict the visibility of trackball based on the touch actions. The
default value of this property is ActivationMode.longPress.
The ActivationMode enum contains the following values:
• longPress – Activates trackball only when performing the long press action.
• singleTap – Activates trackball only when performing single tap action.
• doubleTap - Activates trackball only when performing double tap action.
• none – Hides the visibility of trackball when setting activation mode to none. It will be activated
when calling the [show]() method.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
child: SfCartesianChart(
trackballBehavior: TrackballBehavior(
enable: true,
// Displays the trackball on single tap
activationMode: ActivationMode.singleTap
)
)
)
)
)
);
}
Crosshair
Crosshair has a vertical and horizontal line to view the value of the axis.
Crosshair lines can be enabled by using enable property in the crosshairBehavior. Likewise tooltip label
for an axis can be enabled by using enable property of crosshairTooltip in the corresponding axis. The
hideDelay property can be used to specify a disappear delay for the crosshair.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
child: SfCartesianChart(
primaryXAxis: NumericAxis(
crosshairTooltip: InteractiveTooltip(
// Enables the crosshair tooltip
enable: true
)
),
crosshairBehavior: CrosshairBehavior(
// Enables the crosshair
enable: true
)
)
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
child: SfCartesianChart(
crosshairBehavior: CrosshairBehavior(
enable: true,
lineColor: Colors.red,
lineDashArray: <double>[5,5],
lineWidth: 2,
lineType: CrosshairLineType.vertical
)
)
)
)
)
);
}
Activation mode
The activationMode property is used to restrict the visibility of trackball based on the touch actions. The
default value of this property is ActivationMode.longPress.
The ActivationMode enum contains the following values:
• longPress – Activates crosshair only when performing the long press action.
• singleTap – Activates crosshair only when performing single tap action.
• doubleTap - Activates crosshair only when performing double tap action.
• none – Hides the visibility of crosshair when setting activation mode to none. It will be activated
when calling the show method.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Container(
child: SfCartesianChart(
crosshairBehavior: CrosshairBehavior(
enable: true,
// Displays the crosshair on single tap
activationMode: ActivationMode.singleTap
)
)
)
)
)
);
}
Also refer crosshair and trackball events for customizing the crosshair and trackball further.
Tooltip
Chart provides tooltip support for all the series. It is used to show information about the segment, when
you tap on the segment. To enable the tooltip, you need to set enableTooltip property as true.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
//Enables the tooltip for all the series
tooltipBehavior: TooltipBehavior(
enable: true
),
series: <CartesianSeries>[
LineSeries<ChartData, double>(
//Enables the tooltip for individual series
enableTooltip: true,
)
]
)
)
)
);
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
tooltipBehavior: TooltipBehavior(
enable: true,
borderColor: Colors.red,
borderWidth: 5,
color: Colors.lightBlue
)
)
)
)
);
}
Label format
By default, x and y value will be displayed in the tooltip, and it can be customized using format property
as depicted in the below code snippet. You can show the below values in the tooltip. Also you can add
prefix or suffix to these values.
• X value - point.x
• Y value - point.y
• Bubble size - point.size
• Name of the series - series.name
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
tooltipBehavior: TooltipBehavior(
enable: true,
// Formatting the tooltip text
format: 'point.y%'
)
)
)
)
);
}
Tooltip positioning
The tooltip can be made to display in the fixed location or at the pointer location itself using the
tooltipPosition property. This defaults to auto.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
tooltipBehavior: TooltipBehavior(
enable: true,
tooltipPosition: TooltipPosition.pointer
)
)
)
)
);
}
Tooltip template
You can customize the appearance of the tooltip with your own widget by using the builder property of
tooltipBehavior.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
tooltipBehavior: TooltipBehavior(
enable: true,
// Templating the tooltip
builder: (dynamic data, dynamic point, dynamic series,
Activation mode
The activationMode property is used to restrict the visibility of tooltip based on the touch actions. The
default value of this property is ActivationMode.singleTap.
The ActivationMode enum contains the following values:
• longPress – Activates tooltip only when performing the long press action.
• singleTap – Activates tooltip only when performing single tap action.
• doubleTap - Activates tooltip only when performing double tap action.
• none – Hides the visibility of tooltip when setting activation mode to none.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
tooltipBehavior: TooltipBehavior(
enable: true,
// Tooltip will be displayed on long press
activationMode: ActivationMode.longPress
)
)
)
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
selectionSettings: SelectionSettings(
enable: true,
selectedColor: Colors.red,
unselectedColor: Colors.grey
)
)
]
)
)
)
);
}
Selection modes
The selection features allows you to select segments in following modes using selectionType property of
chart.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
// Mode of selection
selectionType: SelectionType.cluster
)
)
)
);
}
Multi-selection
Multiple selection can be enabled using the enableMultiSelection property of chart.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
// Enables multiple selection
enableMultiSelection: true
)
)
)
);
}
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text('Show'),
onPressed: show
),
Container(child: chart)
]
)
)
);
}
void show() {
tooltip.show(121,164);
}
void hide(){
tooltip.hide();
}
)
);
}
void hide(){
tooltip.hide();
}
TrackballBehavior trackball;
@override
Widget build(BuildContext context) {
final List<ChartData> chartData = [
ChartData(10, 17),
ChartData(20, 34),
// Add the required data
];
trackball = TrackballBehavior(enable: true);
chart = SfCartesianChart(
trackballBehavior: trackball,
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
enableTooltip: true,
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y)
],
);
return Scaffold(
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text('Hide'),
onPressed: hide
),
Container(child: chart)
]
)
)
);
}
void hide() {
trackball.hide();
}
enableTooltip: true,
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
);
return Scaffold(
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text('Show'),
onPressed: show
),
Container(child: chart)
]
)
)
);
}
void show() {
crosshair.show(121, 164);
}
onPressed: hide
),
Container(child: chart)
]
)
)
);
}
void hide() {
crosshair.hide();
}
DART
SfCartesianChart chart;
SelectionSettings selection;
@override
Widget build(BuildContext context) {
final List<ChartData> chartData = [
hartData(10, 17),
ChartData(20, 34)
// Add the required data
];
selection = SelectionSettings(enable: true);
chart = SfCartesianChart(
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y,
selectionSettings: selection
)
]
);
return Scaffold(
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text('Select'),
onPressed: select
),
Container(child: chart)
]
)
)
);
}
void select() {
selection.selectionIndex(1, 0);
}
@override
Widget build(BuildContext context) {
final List<ChartData> chartData = [
ChartData(10, 17),
ChartData(20, 34),
//add the required data
];
zooming = ZoomPanBehavior(
enableSelectionZooming: true,
enableDoubleTapZooming: true,
enablePinching: true,
enablePanning: true
);
chart = SfCartesianChart(
zoomPanBehavior: zooming,
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
);
return Scaffold(
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text('Zoom'),
onPressed: zoom
),
Container(child: chart)
]
)
)
);
}
void zoom() {
zooming.zoomByFactor(0.5);
}
zooming = ZoomPanBehavior(
enableSelectionZooming: true,
enableDoubleTapZooming: true,
enablePinching: true,
enablePanning: true);
chart = SfCartesianChart(
zoomPanBehavior: zooming,
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
);
return Scaffold(
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text('Zoom'),
onPressed: zoom
),
Container(child: chart)
]
)
)
);
}
void zoom() {
zooming.zoomByRect(const Rect.fromLTRB(200, 300, 300, 400));
}
chart = SfCartesianChart(
zoomPanBehavior: zooming,
primaryXAxis: xAxis,
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
);
return Scaffold(
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text('Zoom'),
onPressed: zoom
),
Container(child: chart)
]
)
)
);
}
void zoom() {
final double zoomPosition = 0.5;
final double zoomFactor = 0.4;
zooming.zoomToSingleAxis(xAxis,zoomPosition,zoomFactor);
}
primaryXAxis: xAxis,
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y
)
]
);
return Scaffold(
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text('Pan'),
onPressed: pan
),
Container(child: chart)
]
)
)
);
}
void pan() {
//In similar way, specify other directions like bottom, left and right
zooming.panToDirection('top');
}
]
);
return Scaffold(
body: Center(
child: Column(
children: <Widget>[
FlatButton(
child: Text('Zoom'),
onPressed: zoom
),
Container(child: chart)
]
)
)
);
}
void zoom() {
zooming.reset();
}
Events
The below events are for Cartesian chart.
onTooltipRender
Triggers when the tooltip is rendering. Here, you can customize the text, header, x and y-positions. The
onTooltipRender event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
tooltipBehavior: TooltipBehavior(enable: true),
onTooltipRender: (TooltipArgs args) {
args.text = 'Customized Text';
}
)
)
);
}
onActualRangeChanged
Triggers when the visible range of an axis is changed, i.e. value changes for minimum, maximum, and
interval. Here, you can customize the visible range of an axis. The onActualRangeChanged event
contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
onActualRangeChanged: (ActualRangeChangedArgs args){
if (args.axisName == 'primaryYAxis'){
args.visibleMin = 10;
}
}
)
)
);
}
onAxisLabelRender
Triggers while rendering the axis labels. Text and text styles such as color, font size, and font weight can
be customized. The onAxisLabelRender event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
onAxisLabelRender: (AxisLabelRenderArgs args) {
if(args.axisName == 'primaryXAxis'){
args.text = 'Text';
args.textStyle.color = Colors.red;
}
}
)
)
);
}
onDataLabelRender
Triggers when data label is rendering. Text and text styles such as color, font size, and font weight can be
customized. The onDataLabelRender event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
onDataLabelRender:(DataLabelRenderArgs args){
args.text = 'Data label';
},
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
dataLabelSettings: DataLabelSettings(
isVisible: true
)
)
]
)
)
);
}
onLegendItemRender
Triggers when the legend item is rendering. Here, you can customize the legend’s text, and shape. The
onLegendItemRender event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
legend: Legend(isVisible: true),
onLegendItemRender: (LegendRenderArgs args){
args.text = 'Legend Text';
args.legendIconType = LegendIconType.diamond;
}
)
)
);
}
onTrackballPositionChanging
Triggers while the trackball position is changing. Here, you can customize the text of the trackball.The
onTrackballPositionChanging event contains the following argument.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
onTrackballPositionChanging: (TrackballArgs args) {
args.chartPointInfo.label = 'Custom Text';
},
trackballBehavior: TrackballBehavior(
enable: true
)
)
);
}
onCrosshairPositionChanging
Triggers while the crosshair position is changing. Here, you can customize the text and line color of the
crosshair.The onCrosshairPositionChanging event contains the following arguments.
DART
@override
onZooming
Triggers when the zooming action is in progress. The onZooming event contains the following
arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
zoomPanBehavior: ZoomPanBehavior(
enableDoubleTapZooming: true,
enablePanning: true,
enablePinching: true,
enableSelectionZooming: true
),
onZooming: (ZoomPanArgs args){
print(args.currentZoomFactor);
print(args.currentZoomPosition);
}
)
);
}
onZoomStart
Triggers when zooming action begins. The onZoomStart event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
zoomPanBehavior: ZoomPanBehavior(
enableDoubleTapZooming: true,
enablePanning: true,
enablePinching: true,
enableSelectionZooming: true
),
onZoomStart: (ZoomPanArgs args){
print(args.currentZoomFactor);
print(args.currentZoomPosition);
}
)
);
}
onZoomEnd
Triggers when the zooming action is completed. The onZoomEnd event contains the following
arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
zoomPanBehavior: ZoomPanBehavior(
enableDoubleTapZooming: true,
enablePanning: true,
enablePinching: true,
enableSelectionZooming: true
),
onZoomEnd: (ZoomPanArgs args){
print(args.currentZoomFactor);
print(args.currentZoomPosition);
}
)
);
}
onZoomReset
Triggers when zoomed state is reset. The onZoomReset event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
zoomPanBehavior: ZoomPanBehavior(
enableDoubleTapZooming: true,
enablePanning: true,
enablePinching: true,
enableSelectionZooming: true
),
onZoomReset: (ZoomPanArgs args){
print(args.currentZoomFactor);
print(args.currentZoomPosition);
}
)
);
}
onPointTapped
Triggers when tapping the series point. The onPointTapped event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
onPointTapped: (PointTapArgs args){
print(args.seriesIndex);
print(args.pointIndex);
}
)
);
}
onAxisLabelTapped
Triggers when tapping the axis label. The onAxisLabelTapped event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
onAxisLabelTapped: (AxisLabelTapArgs args) {
print(args.text);
}
)
);
}
onLegendTapped
Triggers when tapping the legend item. The onLegendTapped event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
onLegendTapped: (LegendTapArgs args) {
print(args.seriesIndex);
},
legend: Legend(isVisible: true)
)
);
}
onSelectionChanged
Triggers while selection changes. Here you can customize the selectedColor, unselectedColor,
selectedBorderColor, selectedBorderWidth, unselectedBorderColor, and unselectedBorderWidth
properties. The onSelectionChanged event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCartesianChart(
onSelectionChanged: (SelectionArgs args){
args.selectedColor = Colors.red;
args.unselectedColor = Colors.lightGreen;
},
series: <CartesianSeries>[
ColumnSeries<ChartData, double>(
selectionSettings: SelectionSettings(
enable: true,
)
)
]
)
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCircularChart(
legend: Legend(isVisible: true),
onLegendItemRender: (LegendRenderArgs args){
args.text = 'Legend Text';
args.legendIconType = LegendIconType.diamond;
}
)
)
);
}
onTooltipRender
Triggers while tooltip is rendering. Here, you can customize the text, header, x and y-positions. The
onTooltipRender event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCircularChart(
onTooltipRender: (TooltipArgs args){
args.text = 'Custom Text';
},
tooltipBehavior: TooltipBehavior(enable: true),
)
)
);
}
onDataLabelRender
Triggers when data label is rendering. Text and text styles such as color, font size, and font weight can be
customized. The onDataLabelRender event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCircularChart(
onDataLabelRender:(DataLabelRenderArgs args){
args.text = 'Data label';
},
series: <CircularSeries>[
PieSeries<ChartData, String>(
dataLabelSettings: DataLabelSettings(
isVisible: true
)
)
]
)
)
);
}
onPointTapped
Triggers when tapping the series point. The onPointTapped event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCircularChart(
onPointTapped: (PointTapArgs args){
print(args.seriesIndex);
print(args.pointIndex);
}
)
);
}
onLegendTapped
Triggers when tapping the legend item. The onLegendTapped event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCircularChart(
onLegendTapped: (LegendTapArgs args) {
print(args.seriesIndex);
},
legend: Legend(isVisible: true)
)
);
}
onSelectionChanged
Triggers while selection changes. Here you can customize the selectedColor, unselectedColor,
selectedBorderColor, selectedBorderWidth, unselectedBorderColor, and unselectedBorderWidth
properties. The onSelectionChanged event contains the following arguments.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfCircularChart(
onSelectionChanged: (SelectionArgs args){
args.selectedColor = Colors.red;
args.unselectedColor = Colors.lightGreen;
},
series: <CircularSeries>[
PieSeries<ChartData, String>(
selectionSettings: SelectionSettings(
enable: true
)
)
]
)
);
}
Radial Gauge
Overview
Syncfusion flutter radial gauge is a data visualization widget, which is written in dart, to create modern,
interactive, and animated gauge that is used to craft high-quality mobile app user interfaces using
Flutter.
Key Features
• Axes - The radial gauge axis is a circular arc in which a set of values are displayed along a linear
or custom scale based on the design requirements. Axis elements, such as labels, ticks, and axis
line, can be easily customized with built-in properties
• Ranges - Gauge range is a visual element that helps to quickly visualize a value where it falls on
the axis. The text can be easily annotated in range to improve the readability.
• Pointers - Pointer is used to indicate values on an axis. Radial gauge has three types of pointers:
needle pointer, marker pointer, and range pointer. All the pointers can be customized as
needed.
• Pointer Animation - Animates the pointer in a visually appealing way when the pointer moves
from one value to another. Gauge supports various pointer animations.
• Pointer interaction - Radial gauge provides an option to drag a pointer from one value to
another. It is used to change the value at run time.
• Annotations - Adds multiple widgets such as text and image as an annotation at a specific point
of interest in the radial gauge.
You can get the sample in the following link: Flutter Gauges.
Getting Started
This section explains the steps required to add the radial gauge and its elements such as title, axis,
range, pointer and annotation. This section covers only basic features needed to know to get started
with Syncfusion radial gauge.
To get start quickly with our Flutter radial gauge widget, you can check on this video.
<style>#flutterRadialGaugeVideoTutorial{width : 90% !important; height: 300px !important }</style>
<iframe id='flutterRadialGaugeVideoTutorial'
src='https://www.youtube.com/embed/2NuipO7j2tA'></iframe>
Add Flutter Radial Gauge to an application
Create a simple project using the instructions given in the Getting Started with your first Flutter app
documentation.
Add dependency
Add the Syncfusion Flutter Gauge dependency to your pubspec.yaml file.
DART
dependencies:
syncfusion_flutter_gauges: ^1.0.0-beta
Get packages
Run the following command to get the required packages.
DART
$ flutter pub get
Import package
Import the following package in your Dart code.
DART
import 'package:syncfusion_flutter_gauges/gauges.dart';
);
}
Add title
You can add a title to the radial gauge to provide information to users about the designed gauge. The
title can be set to gauge as demonstrated in following code snippet.
DART
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Container(
child: SfRadialGauge(
title:GaugeTitle(text: 'Speedometer', textStyle: TextStyle(
fontSize: 20.0,fontWeight: FontWeight.bold))
)
)
)
)
);
}
Add axis
Axes contain a list of axis elements, where you can add any number of radial axes inside the gauge. You
can specify the minimum and maximum values of axis using the minimum and maximum properties as
demonstrated in the following code snippet.
DART
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Container(
child: SfRadialGauge(
axes: <RadialAxis>[
RadialAxis(minimum: 0, maximum: 150)]
)
)
)
)
);
}
Add range
Ranges contain a list of range elements, where you can add any number of ranges inside the axis. You
can specify the start value, end value, and color for range using the startValue, endValue, and color
properties as demonstrated in the following code.
DART
axes: <RadialAxis>[
RadialAxis(minimum: 0,maximum: 150,
ranges: <GaugeRange>[
GaugeRange(startValue: 0,endValue: 50,color: Colors.green,startWidth:
10,endWidth:10),
GaugeRange(startValue: 50,endValue: 100,color: Colors.orange,startWidth:
10,endWidth: 10),
GaugeRange(startValue: 100,endValue: 150,color: Colors.red,startWidth:
10,endWidth: 10)]
)]
Add pointer
Pointers contains a list of pointer elements, where you can add any number of gauge pointers such as
needlePointer, rangePointer and markerPointer inside the axis to indicate the value.
DART
axes: <RadialAxis>[
RadialAxis(minimum: 0,maximum: 150,
pointers: <GaugePointer>[NeedlePointer(value:90)]
)]
Add annotation
You can add any number of widgets such as text or image as an annotation inside the axis. The position
of annotation can be customized using the angle and positionFactor properties as demonstrated in the
following code.
DART
axes: <RadialAxis>[
RadialAxis(minimum: 0,maximum: 150,
annotations: <GaugeAnnotation>[
GaugeAnnotation(widget: Container(child:
Text('90.0',style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold))),
angle: 90,positionFactor: 0.5)]
)]
The following code example gives you the complete code of above configurations.
DART
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_gauges/gauges.dart';
void main() => runApp(ChartApp());
class ChartApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Container(
child: SfRadialGauge(
axes: <RadialAxis>[
RadialAxis(minimum: 0,maximum: 150,
ranges: <GaugeRange>[
GaugeRange(startValue: 0,endValue: 50,color: Colors.green,startWidth:
10,endWidth: 10),
GaugeRange(startValue: 50,endValue: 100,color: Colors.orange,startWidth:
10,endWidth: 10),
GaugeRange(startValue: 100,endValue: 150,color: Colors.red,startWidth:
10,endWidth: 10)],
pointers: <GaugePointer>[NeedlePointer(value:90)],
annotations: <GaugeAnnotation>[
GaugeAnnotation(widget: Container(child:
Text('90.0',style: TextStyle(fontSize: 25,fontWeight:FontWeight.bold))),
angle: 90,positionFactor: 0.5)]
)]
)
)
)
)
);
}
}
Title
You can define and customize the gauge title using the title property of SfRadialGauge. The text property
of GaugeTitle is used to set text to the title.
The following properties are used to customize the appearance of title:
Text Alignment
You can align the title text content horizontally to the near, center, or far to the gauge using the
alignment property oftitle.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
title: GaugeTitle(text: 'SfRadialGauge',
backgroundColor: Colors.lightBlueAccent,
textStyle: TextStyle(fontSize: 15, fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic,
color: Colors.black, fontFamily: 'Times'),
borderColor: Colors.indigo, borderWidth: 3,
alignment: GaugeAlignment.near),
axes: <RadialAxis>[RadialAxis()],)
),
);
}
Axis
The radial axis is a circular arc in which a set of values are displayed along a linear or custom scale based
on the design requirements. Axis elements such as labels, ticks, and axis line can be easily customized
with built-in properties.
Axis Customization
Axis minimum and maximum
The minimum and maximum properties of an axis can be used to customize the axis range.The default
value of minimum is 0, and the default value of maximum is 100.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(minimum: -60, maximum: 60
)
]
),
),
);
}
Angle Customization
The start and end angles of radial axis can be customized using the startAngle and endAngle properties.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(startAngle: 180, endAngle: 90,
)
]
),
),
);
}
Radius customization
The radius of the radial axis can be customized using the radiusFactor property. The default value of the
radiusFactor is 0.95. The value of radiusFactor ranges from 0 to 1. For example, When the radiusFactor
value is 1, the full radius will be considered for rendering the axis, and when the radiusFactor value is
0.5, then half of the radius value will be considered for rendering the circle.
DART
@@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(),
RadialAxis(radiusFactor: 0.5)]
),
),
);
}
The default value of both the showFirstLabel and the showLastLabel properties is true.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis( interval: 1, showFirstLabel: false,
startAngle: 270, endAngle: 270, minimum: 0, maximum: 12),
]
),
),
);
}
Interval
The interval between labels can be customized using the interval property of axis.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(interval: 20)]
),
),
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(
axisLineStyle: AxisLineStyle(thickness: 0.1,
thicknessUnit: GaugeSizeUnit.factor, color: Colors.deepPurple,)),
]
),
),
);
}
Rounded Corners
The cornerStyle property of axisLineStyle specifies the corner type for axis line. The corners can be
customized using the bothFlat, bothCurve, startCurve, and endCurve options. The default value of this
property is bothFlat.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(axisLineStyle: AxisLineStyle(thickness: 15,
cornerStyle:CornerStyle.bothCurve)),
]
),
),
);
}
Gradient support
The gradient property of axisLineStyle allows to specify the smooth color transition to the axis line by
specifying the different colors based on provided factor value.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(
axisLineStyle: AxisLineStyle(thickness: 0.1,
thicknessUnit: GaugeSizeUnit.factor,
gradient: const SweepGradient(
colors: <Color>[Color(0xFFFF7676), Color(0xFFF54EA2)],
stops: <double>[0.25, 0.75]
),
)
),
]
),
),
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(axisLabelStyle: GaugeTextStyle(
color: Colors.red, fontSize: 15,
fontStyle:FontStyle.italic,
fontWeight: FontWeight.bold, fontFamily: 'Times') ),
]
),
),
);
}
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(labelFormat: '{value}m' ),]
),
),
);
}
• numberFormat- Allows to customize the axis label with the [globalized label format].
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(
numberFormat: NumberFormat.compactSimpleCurrency()),
]
),
),
);
}
Label visibility
The showLabels property of axis allows to enable or disable the visibility of labels. The default value of
the property is true.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(showLabels: false ),]
),
),
);
}
Tick customization
The major and minor tick lines of an axis can be customized using the majorTickStyle and minorTickStyle
properties, respectively. The following properties can be customized for both the major and the minor
ticks:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(majorTickStyle: MajorTickStyle(length: 0.1,
lengthUnit: GaugeSizeUnit.factor, thickness: 1.5, color: Colors.black),
minorTickStyle: MinorTickStyle(length: 0.05,
lengthUnit: GaugeSizeUnit.factor, thickness: 1.5, color: Colors.black)
)]
),
),
);
}
The following code example shows how to tick offset with the offsetUnit property of axis.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(tickOffset: 0.2,
labelOffset: 0.2, offsetUnit: GaugeSizeUnit.factor
),
]
),
),
);
}
The offsetUnit property of axis is common for both the tickOffset and labelOffset
Note: GaugeSizeUnit allows to specify the value either in logical pixels or in factor. GaugeSizeUnit.factor
ranges from 0 to 1. For example, when setting factor as 0.5, the half of axis radius value will be
considered.
Multiple axis
The Radial Gauge allows you to add n number of radial axis in its axes collection. You can also customize
individual axis added in the axes collection.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[ RadialAxis(minimum: 0 , maximum: 100, interval: 10,
ticksPosition: ElementsPosition.outside,
labelsPosition: ElementsPosition.outside,
minorTicksPerInterval: 5,
radiusFactor: 0.9, labelOffset: 15,
minorTickStyle: MinorTickStyle(thickness: 1.5,
color: Color.fromARGB(255, 143, 20, 2),
length: 0.07, lengthUnit: GaugeSizeUnit.factor),
majorTickStyle: MinorTickStyle(thickness: 1.5,
color: Color.fromARGB(255, 143, 20, 2),
length: 0.15, lengthUnit: GaugeSizeUnit.factor,),
axisLineStyle: AxisLineStyle( thickness: 3,
color: Color.fromARGB(255, 143, 20, 2), ),
axisLabelStyle: GaugeTextStyle(fontSize: 12,
color:Color.fromARGB(255, 143, 20, 2),),),
RadialAxis(minimum: 0 , maximum: 60, interval: 10,
radiusFactor: 0.6, labelOffset: 15, isInversed: true,
minorTicksPerInterval: 5,
minorTickStyle: MinorTickStyle(color: Colors.black, thickness: 1.5,
Events
onLabelCreated
The onLabelCreated event is called when an axis label is created. The following properties can be
customized for the corresponding axis label when this event args:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(
onLabelCreated:axisLabelCreated,),
]
),
),
);
}
void axisLabelCreated(AxisLabelCreatedArgs args){
if(args.text == '100'){
args.labelStyle = GaugeTextStyle(color: Colors.red,fontStyle:
FontStyle.italic,
fontFamily: 'Times', fontWeight: FontWeight.bold, fontSize: 15);
args.canRotate = true;
args.text = '100 %';
}
}
onAxisTapped
The onAxisTapped event is called when an axis is tapped. The corresponding axis value at the tapped
position will be got from the event.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[RadialAxis(
onAxisTapped: axisTapped),
]
),
),
);
}
void axisTapped(double _tappedValue){
}
Custom scale
Radial gauge allows you to display a set of values along with a custom scale based on your business
logic.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[
CustomAxis(minimum: 0,
maximum: 150,
)
],
)
),
);
}
class CustomAxis extends RadialAxis{
CustomAxis({
double minimum,
double maximum}) :super(
minimum: minimum ,
maximum: maximum ,
);
@override
List<CircularAxisLabel> generateVisibleLabels(){
final List<CircularAxisLabel> _visibleLabels = <CircularAxisLabel>[];
for (num i = 0; i < 9; i++) {
double _value = _calculateLabelValue(i);
final CircularAxisLabel label =
CircularAxisLabel(axisLabelStyle, _value.toInt().toString(), i, false);
label.value = _value;
_visibleLabels.add(label);
}
return _visibleLabels;
}
@override
double valueToFactor(double value)
{
if(value >= 0 && value <=2){
return (value * 0.125)/2;
}else if(value > 2 && value <=5){
return (((value - 2) * 0.125)/(5 - 2)) + (1 * 0.125);
}else if(value > 5 && value <=10){
return (((value - 5) * 0.125)/(10 - 5)) + (2 * 0.125);
}else if(value > 10 && value <=20){
return (((value - 10) * 0.125)/(20 - 10)) + (3 * 0.125);
}else if(value > 20 && value <=30){
return (((value - 20) * 0.125)/(30 - 20)) + (4 * 0.125);
}else if(value > 30 && value <=50){
return (((value - 30) * 0.125)/(50 - 30)) + (5 * 0.125);
}else if(value > 50 && value <=100){
return (((value - 50) * 0.125)/(100 - 50)) + (6 * 0.125);
}else if(value > 100 && value <=150){
Pointers
Pointer is used to indicate values on an axis. The radial gauge control has three types of pointers:
Marker pointer
Needle pointer
Range pointer
All the pointers can be customized as needed. You can add multiple pointers to the gauge to point
multiple values on the same scale. The value of the pointer is set using the value property.
Multiple pointers
In addition to the default pointer, you can add n number of pointers to an axis by adding in the pointers
property.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[RangePointer(value: 30, ),
MarkerPointer(value: 70),
NeedlePointer(value: 60)]
)],
)
),
);
}
Pointer Dragging
Pointers can be dragged over the scale value. It can be achieved by clicking and dragging the pointer. To
enable or disable the pointer drag, use the enableDragging property.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
axisLineStyle: AxisLineStyle(thickness: 30, color: Colors.lightBlueAccent),
showTicks: false,
pointers: <GaugePointer>[
MarkerPointer(value: 30, enableDragging: true,
markerWidth: 30, markerHeight: 30, markerOffset: -15,
color: Colors.indigo)
]
)],
)
),
);
}
Event
onValueChangeStart - Occurs whenever the pointer starts to drag.
onValueChanging - Occurs before the current drag value gets updated as pointer value. The cancel
argument of ValueChangingArgs allows to restrict the update of current drag value as pointer value.
onValueChanged - Occurs whenever the pointer value is changed while dragging.
onValueChangeEnd - Occurs once the dragging of the pointer gets completed.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[ RangePointer(value: 30,
enableDragging: true,
onValueChanging: onValueChanging,
onValueChanged: onvalueChanged)]
)],
)
),
);
}
void onValueChanging(ValueChangingArgs args){
if(args.value > 60){
args.cancel = true;
}
}
void onvalueChanged(double value){
}
Marker pointer
Different types of markers are used to mark the pointer values in a scale. You can change the marker
type using the markerType property.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[MarkerPointer(value: 60)]
)],
)
),
);
}
• Circle
• Diamond
• Image
• Inverted triangle
• Rectangle
• Text
• Triangle
Image pointer
Image is used to denote the current pointer values instead of shape. It can be achieved by specifying the
markerType as image and specifying the imageUrl property of marker pointer.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[MarkerPointer(value: 60,
markerType: MarkerType.image,markerHeight: 30,
markerWidth: 30,
imageUrl: 'images/pin.png')]
)],
)
),
);
}
Text pointer
Text is used to denote the current pointer value instead of any marker shape. It can be achieved by
setting the markerType as text. The provided text can be customized using the textStyle property of
marker pointer.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[MarkerPointer(value: 50,
markerType: MarkerType.text, text: 'Average',
textStyle: GaugeTextStyle(fontSize: 15,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic)
)]
)],
)
),
);
}
Marker Customization
The marker pointer can be customized using the following properties:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[MarkerPointer(value: 60,
markerHeight: 30, markerWidth: 30,
markerType: MarkerType.circle, color: Colors.lightBlue,
borderWidth: 3, borderColor: Colors.black)]
)],
)
),
);
}
Position customization
The marker pointer can be moved near or far from its actual position using the markerOffset and
offsetUnit properties.
When you set offsetUnit to logical pixel, then the marker pointer will be moved based on the logical
pixel value. If you set offsetUnit to factor, then provided factor will be multiplied with the axis radius
value, and then the pointer will be moved to corresponding value. The default value of offsetUnit is
GaugeSizeUnit.logicalPixel.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis( radiusFactor: 0.9, centerY: 0.65,
pointers: <GaugePointer>[MarkerPointer(value: 60,
markerOffset: -5
)
]
)],
)
),
);
}
Needle Pointer
Needle Pointer contains three parts, namely needle, knob, and tail and that can be placed on a gauge to
mark the values.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[NeedlePointer(value: 60)
]
)
],
)
),
);
}
Needle customization
The needle can be customized using the following properties:
• needleLength – Customizes the length of the needle. The length of the pointer can be set either
in logical pixel or factor.
• lengthUnit –Specifies whether to set the length in logical pixel or factor.
• needleStartWidth – Specifies the start width of the needle.
• needleEndWidth – Specifies the end width of the needle.
• needleColor – Specifies the needle color.
• gradient - Specifies the gradient for the needle.
)
),
);
}
Knob customization
The knob can be customized using the following properties:
If the sizeUnit is set to factor, the factor value will be set to knob radius. The factor value ranges from 0
to 1. For example, if the needle length is set to 0.1, 10% of the radius value of axis will be set to knob
radius. By default, the value of sizeUnit is GaugeSizeUnit.factor
Knob border customization
Like radius, the borderWidth can be specified either in logical pixel or factor. The sizeUnit property of
knob style is common for both knobRadius and borderWidth properties.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[NeedlePointer(value: 60,
needleStartWidth: 1, needleEndWidth: 5,
knobStyle: KnobStyle(knobRadius: 0.05, borderColor: Colors.black,
borderWidth: 0.02,
color: Colors.white
)
)]
)],
)
),
);
}
Tail Customization
The tail of the needle can be customized using the following properties,
By default, the value of lengthUnit is GaugeSizeUnit.factor.The factor value ranges from 0 to 1. When
the length is set to 0.2, 20 % of axis radius value will be considered as tail length.The following code
example shows how to specify the length in factor.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[NeedlePointer(value: 60,
tailStyle: TailStyle(width: 8, length: 0.15)
)]
)],
)
),
);
}
The following code example shows how to specify the length in logical pixels.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[NeedlePointer(value: 60,needleStartWidth: 3,
needleEndWidth: 3,
knobStyle: KnobStyle(color: Colors.white, knobRadius: 0.07,
borderColor: Colors.black, borderWidth: 0.02),
tailStyle: TailStyle(width: 5, length: 30, lengthUnit:
GaugeSizeUnit.logicalPixel,
color: Colors.white, borderWidth: 3, borderColor: Colors.black)
)
]
)],
)
),
);
}
The following code shows how to apply the gradient for the tail.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[
NeedlePointer(
value: 65,
lengthUnit: GaugeSizeUnit.factor,
needleLength: 0.8,
needleEndWidth: 11,
tailStyle: TailStyle(length: 0.2, width: 11,
gradient:LinearGradient(
colors: <Color>[
Color(0xFFFF6B78), Color(0xFFFF6B78),
Color(0xFFE20A22), Color(0xFFE20A22)],
stops: <double>[0, 0.5, 0.5, 1]),
),
gradient: LinearGradient(
colors: <Color>[
Color(0xFFFF6B78), Color(0xFFFF6B78),
Color(0xFFE20A22), Color(0xFFE20A22)],
stops: <double>[0, 0.5, 0.5, 1]),
needleColor: Color(0xFFF67280),
knobStyle: KnobStyle(
knobRadius: 0.08,
sizeUnit: GaugeSizeUnit.factor,
color: Colors.black)),
]
),
]
),
),
);
}
Range Pointer
A range pointer is an accenting line or shaded background range that can be placed on a gauge to mark
the current value.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[RangePointer(value: 30)]
)],
)
),
);
}
The width of the pointer can be specified either in logical pixel or factor. If the sizeUnit is specified as
logicalPixel, then the range will be rendered based on the provided pixel value. If the sizeUnitis set as
factor, the provided factor value will be multiplied with axis radius. For example, if the width is set as
0.1, then 10% of axis radius is considered as range pointer width.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[RangePointer(value: 30, width: 0.1,
color: Colors.indigo, sizeUnit: GaugeSizeUnit.factor
)
]
)],
)
),
);
}
Corner customization
The cornerStyle property of range pointer specifies the corner type for pointer. The corners can be
customized using the bothFlat, bothCurve, startCurve, and endCurve options. The default value of this
property is bothFlat.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(pointers:<GaugePointer>[RangePointer(value:
30,
cornerStyle: CornerStyle.bothCurve)]
)],
)
),
);
}
Position customization
The range pointer can be moved far or near to the axis line using the pointerOffset property. The
pointerOffset can be set either in logical pixel or factor value using its sizeUnit. The sizeUnit property is
common for bothwidth and pointerOffset
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[RangePointer(value: 30, pointerOffset: 50)]
)],
)
),
);
}
When you set the sizeUnit as logical pixel, the pointer will be moved to the provided logical pixel value.
If the sizeUnit is specified as factor, the factor value will be multiplied with the axis radius. For example,
if you set pointerOffset as 0.1, then the pointer offset is considered as 10% of axis radius.
Range
Gauge range is a visual element that helps to quickly visualize where a value falls on the axis. The text
can be easily annotated in range to improve the readability.
Setting start and end value
The start and end values of ranges are set using the startValue and endValue properties.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
ranges: <GaugeRange>[GaugeRange(startValue: 30, endValue: 65)]
)
],
)
),
);
}
Range Customization
The following properties are used for the range customization:
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
ranges: <GaugeRange>[GaugeRange(startValue: 30, endValue: 65,
startWidth: 5, endWidth: 20
)]
)
],
)
),
);
}
When the sizeUnit is set as logical pixels, the range will be rendered based on the provided logical pixel
values in startWidth and endWidth
If the sizeUnit is set as factor, the provided factor value in the start width and end width will be
multiplied with the axis radius, respectively. The factor value ranges from 0 to 1.
Gradient support
The gradient property of range allows to specify the smooth color transition to pointer by specifying the
different colors based on provided factor value.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
ranges: <GaugeRange>[
GaugeRange(startValue: 30,
endValue: 65,
gradient: const SweepGradient(
colors: <Color>[Color(0xFFBC4E9C), Color(0xFFF80759)],
stops: <double>[0.25, 0.75]),
startWidth: 5,
endWidth: 20
)
]
)
],
)
),
);
}
Position customization
The range can be moved far or near to the axis line with using the rangeOffset property. The property
can be specified either in the logical pixels or the factor value.
If the sizeUnit is set as logical pixels, then the range will be moved based on the provided logical pixel
value.
If the sizeUnit is set as factor, the factor value will be multiplied with the axis radius.Then the pointer
will be moved to the corresponding value
The sizeUnit property is common for the rangeOffset, startWidth and the endWidth properties. The
default value of sizeUnit is logicalPixel.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
ranges: <GaugeRange>[GaugeRange(startValue: 30, endValue: 65,
rangeOffset: 50,
)]
)
],
)
),
);
}
Range label
A text can be displayed on range using the label property. The provided text can be customized using the
labelStyle property.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes:<RadialAxis>[
RadialAxis(showLabels: false, showAxisLine: false, showTicks: false,
minimum: 0, maximum: 99,
ranges: <GaugeRange>[GaugeRange(startValue: 0, endValue: 33,
color: Color(0xFFFE2A25), label: 'Slow',
sizeUnit: GaugeSizeUnit.factor,
labelStyle: GaugeTextStyle(fontFamily: 'Times', fontSize: 20),
startWidth: 0.65, endWidth: 0.65
),GaugeRange(startValue: 33, endValue: 66,
color:Color(0xFFFFBA00), label: 'Moderate',
labelStyle: GaugeTextStyle(fontFamily: 'Times', fontSize: 20),
startWidth: 0.65, endWidth: 0.65, sizeUnit: GaugeSizeUnit.factor,
),
GaugeRange(startValue: 66, endValue: 99,
Annotation
Radial axis allows you to add multiple widgets such as text and image as an annotation to a specific point
of interest in radial gauge.
The following properties are available in annotation to customizes the position and alignment of
annotation widget
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
annotations: <GaugeAnnotation>[
GaugeAnnotation(axisValue: 50, positionFactor: 0.4,
widget: Text('50.0', style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 20),))]
)
],
)
)
);
}
Positioning annotation
The annotation can be positioned either using the angle or axis value. When providing both the angle
and the axis value, priority will be provided to the angle value. The following example shows how to
position the annotation widget using angle.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
pointers: <GaugePointer>[NeedlePointer(value: 90)],
annotations: <GaugeAnnotation>[
GaugeAnnotation(angle: 90, positionFactor: 0.5,
widget: Text('90.0', style: TextStyle(fontWeight: FontWeight.bold,
fontSize: 20),))])],)
),
);
The following code example shows how to position the annotation using axis value
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
annotations: <GaugeAnnotation>[
GaugeAnnotation(axisValue: 50, positionFactor: 0.4,
widget: Text('50.0', style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 20),))]
)],)
);
}
PositionFactoris used to move the annotation widget from the center of axis to the edge of the axis. For
example, when you specify the positionFactor as 0.5, the annotation widget will be moved from the
center towards the corresponding direction with the distance of half of the radius value of axis.
By default, the value of positionFactor is 0.
Setting image for annotation
Annotations provide options to add any image over the gauge control with respect to its offset position.
You can add multiple images in a single control.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis( interval: 10,
startAngle: 0, endAngle: 360, showTicks: false,
showLabels: false,
axisLineStyle: AxisLineStyle(thickness: 20),
pointers: <GaugePointer>[RangePointer(value: 73,
width: 20, color: Color(0xFFFFCD60),
enableAnimation: true,
cornerStyle: CornerStyle.bothCurve)],
annotations: <GaugeAnnotation>[
GaugeAnnotation(widget: Column(children: <Widget>[Container(
width: 50.00 ,
height: 50.00,
decoration: new BoxDecoration(
image: new DecorationImage(
image: ExactAssetImage('images/sun.png'),
fit: BoxFit.fitHeight,
),
)),
Padding(padding: EdgeInsets.fromLTRB(0, 2, 0, 0),
child: Container(child:Text('73°F',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25)) ,),)
],) , angle: 270, positionFactor: 0.1)]
)])
);
}
Alignment of annotation
Annotation can be aligned to center, near and far using the horizontalAlignment and verticalAlignment
properties of annotation.
The following code example demonstrates how to set the horizontalAlignment for annotation
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
annotations: <GaugeAnnotation>[
GaugeAnnotation(axisValue: 50, positionFactor: 0.4,
horizontalAlignment: GaugeAlignment.far,
widget: Text('50.0', style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 20),))]
)],)
);
}
The following code example demonstrates how to set verticalAlignment for annotation,
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
annotations: <GaugeAnnotation>[
GaugeAnnotation(axisValue: 50, positionFactor: 0.4,
verticalAlignment: GaugeAlignment.far,
widget: Text('50.0', style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 20),))]
)],)
);
}
Animation
Initial animation
The radial gauge allows all of its elements to be animated with enableLoadingAnimation property. The
default value for this property is false. The duration of the animation can be controlled by
animationDuration property of the gauge.
DART
override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
enableLoadingAnimation: true, animationDuration: 4500,
axes: <RadialAxis>[
RadialAxis(minimum: 0,maximum: 150,
ranges: <GaugeRange>[
GaugeRange(startValue: 0,endValue: 50,color: Colors.green,startWidth:
10,endWidth: 10),
GaugeRange(startValue: 50,endValue: 100,color: Colors.orange,startWidth:
10,endWidth: 10),
GaugeRange(startValue: 100,endValue: 150,color: Colors.red,startWidth:
10,endWidth: 10)],
pointers: <GaugePointer>[NeedlePointer(value:90, )],
annotations: <GaugeAnnotation>[
GaugeAnnotation(widget: Container(child:
Text('90.0',style: TextStyle(fontSize: 25,fontWeight:FontWeight.bold))),
angle: 90,positionFactor: 0.5)]
)]
),
),
);
}
Pointer Animation
The enableAnimation property of pointer allows to enable or disable animation for pointer. The gauge
pointer has the following animation type:
• bounceOut
• ease
• easeInCir
• easeOutBack
• elasticOut
• linear
• slowMiddle
The animation type can be changed using the animationTypeproperty of pointer. By default, the
animation type is linear.
DART
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(
axes: <RadialAxis>[RadialAxis(
axisLineStyle: AxisLineStyle(thickness: 30), showTicks: false,
pointers: <GaugePointer>[NeedlePointer(value: 60, enableAnimation: true,
needleStartWidth: 0,
needleEndWidth: 5, needleColor: Color(0xFFDADADA),
knobStyle: KnobStyle(color: Colors.white, borderColor: Color(0xFFDADADA),
knobRadius: 0.06,
borderWidth: 0.04),