Animated radial and pie charts for Flutter

Overview

pub package

Flutter Circular Chart

A library for creating animated circular chart widgets with Flutter, inspired by Zero to One with Flutter.

Overview

Create easily animated pie charts and radial charts by providing them with data objects they can plot into charts and animate between.

animated_random_radial_chart

animated pie chart animated radial chart

Check the examples folder for the source code for the above screenshots.

Contents:

Installation

Install the latest version from pub.

Getting Started

Import the package:

import 'package:flutter_circular_chart/flutter_circular_chart.dart';

Create a GlobalKey to be able to access the chart and update its data:

final GlobalKey<AnimatedCircularChartState> _chartKey = new GlobalKey<AnimatedCircularChartState>();

Create chart data entry objects:

List<CircularStackEntry> data = <CircularStackEntry>[
  new CircularStackEntry(
    <CircularSegmentEntry>[
      new CircularSegmentEntry(500.0, Colors.red[200], rankKey: 'Q1'),
      new CircularSegmentEntry(1000.0, Colors.green[200], rankKey: 'Q2'),
      new CircularSegmentEntry(2000.0, Colors.blue[200], rankKey: 'Q3'),
      new CircularSegmentEntry(1000.0, Colors.yellow[200], rankKey: 'Q4'),
    ],
    rankKey: 'Quarterly Profits',
  ),
];

Create an AnimatedCircularChart, passing it the _chartKey and initial data:

@override
Widget build(BuildContext context) {
  return new AnimatedCircularChart(
    key: _chartKey,
    size: const Size(300.0, 300.0),
    initialChartData: data,
    chartType: CircularChartType.Pie,
  );
}

Call updateData to animate the chart:

void _cycleSamples() {
  List<CircularStackEntry> nextData = <CircularStackEntry>[
    new CircularStackEntry(
      <CircularSegmentEntry>[
        new CircularSegmentEntry(1500.0, Colors.red[200], rankKey: 'Q1'),
        new CircularSegmentEntry(750.0, Colors.green[200], rankKey: 'Q2'),
        new CircularSegmentEntry(2000.0, Colors.blue[200], rankKey: 'Q3'),
        new CircularSegmentEntry(1000.0, Colors.yellow[200], rankKey: 'Q4'),
      ],
      rankKey: 'Quarterly Profits',
    ),
  ];
  setState(() {
    _chartKey.currentState.updateData(nextData);
  });
}

Customization

Hole Label:

Property Default
holeLabel null
labelStyle Theme.of(context).textTheme.body2

Example:

new AnimatedCircularChart(
  key: _chartKey,
  size: _chartSize,
  initialChartData: <CircularStackEntry>[
    new CircularStackEntry(
      <CircularSegmentEntry>[
        new CircularSegmentEntry(
          33.33,
          Colors.blue[400],
          rankKey: 'completed',
        ),
        new CircularSegmentEntry(
          66.67,
          Colors.blueGrey[600],
          rankKey: 'remaining',
        ),
      ],
      rankKey: 'progress',
    ),
  ],
  chartType: CircularChartType.Radial,
  percentageValues: true,
  holeLabel: '1/3',
  labelStyle: new TextStyle(
    color: Colors.blueGrey[600],
    fontWeight: FontWeight.bold,
    fontSize: 24.0,
  ),
)

hole label example screenshot


Segment Edge Style:

Property Default
edgeStyle SegmentEdgeStyle.flat
SegmentEdgeStyle Description
flat (default) Segments begin and end with a flat edge.
round Segments begin and end with a semi-circle.

Example:

new AnimatedCircularChart(
  key: _chartKey,
  size: _chartSize,
  initialChartData: <CircularStackEntry>[
    new CircularStackEntry(
      <CircularSegmentEntry>[
        new CircularSegmentEntry(
          33.33,
          Colors.blue[400],
          rankKey: 'completed',
        ),
        new CircularSegmentEntry(
          66.67,
          Colors.blueGrey[600],
          rankKey: 'remaining',
        ),
      ],
      rankKey: 'progress',
    ),
  ],
  chartType: CircularChartType.Radial,
  edgeStyle: SegmentEdgeStyle.round,
  percentageValues: true,
)

round segment edge example screenshot

Details

Chart data entries:

Charts expect a list of CircularStackEntry objects containing the data they need to be drawn.

Each CircularStackEntry corresponds to a complete circle in the chart. For radial charts that is one of the rings, for pie charts it is the whole pie.

Radial charts with multiple CircularStackEntrys will display them as concentric circles.

Each CircularStackEntry is composed of multiple CircularSegmentEntrys containing the value of a data point. In radial charts a segment corresponds to an arc segment of the current ring, for pie charts it is an individual slice.

Comments
  • How to create GlobalKey?

    How to create GlobalKey?

    I have no idea how to create final GlobalKey _chartKey; It is not clearly mentioned in the document. I am new to Dart + Flutter

    Without even passing this object my chart is rendered properly. What am I missing then?

    opened by zarub2k 3
  • Dart Version 2.1 is not compatible with Circular_Chart

    Dart Version 2.1 is not compatible with Circular_Chart

    I updated my Flutter and your package ist not working with the Dart Version 2.1. See the Screenshot in the extentions. Please fix the Dart SDK Constraints 💃 unbenannt

    opened by stefanschaller 2
  • Does not work with Flutter 0.6.0

    Does not work with Flutter 0.6.0

    When upgrading the library to flutter 0.6.0, the library fails to solve versions:

    The current Dart SDK version is 2.1.0-dev.0.0.flutter-be6309690f.
    
    Because flutter_circular_chart 0.0.3 requires SDK version >=1.19.0 <2.0.0 and no versions of flutter_circular_chart match >0.0.3 <0.1.0, flutter_circular_chart ^0.0.3 is forbidden.
    So, because flutter_example depends on flutter_circular_chart ^0.0.3, version solving failed.
    pub get failed (1)
    
    
    opened by agrosner 2
  • Support Flutter 0.6.0

    Support Flutter 0.6.0

    1. Updates dart dependency to go >=2.0.0 and <2.2.0. This is to enforce Dart2 in newer flutter versions.
    2. Update version to 0.0.4.

    This is related to: https://github.com/xqwzts/flutter_circular_chart/pull/13 but that MR does not support Dart 2.1.0, required by Flutter 0.6.0.

    opened by agrosner 1
  • Remove `flutter:` section from pubspec.yaml

    Remove `flutter:` section from pubspec.yaml

    As shown here: https://github.com/flutter/flutter/issues/14008 the flutter: section in pubspec.yaml leads to an error when building. Removing it should fix this.

    opened by raffomania 1
  • holeLabel should be painted last to be visible on pie charts

    holeLabel should be painted last to be visible on pie charts

    When using holeLabel with chartType: CircularChartType.Pie it is not visible. Because it it painted first it is later overwritten by the chart. Changing painting order solves it.

    opened by lindroth 0
  • Enable rouned segment ends

    Enable rouned segment ends

    Adds an edgeStyle property to AnimatedCircularChart which takes a SegmentEdgeStyle: an enum with flat and round as valid options.

    • SegmentEdgeStyle,flat is the default value: produces edges that are flat lines.
    • SegmentEdgeStyle.round produces edges that are semi-circles.

    Closes #11

    opened by xqwzts 0
  • Fix deprecated syntax

    Fix deprecated syntax

    Please accept this PR, since my old project using this plugin.

    In this PR I just change some deprecated syntax, since ancestorStateOfType was already deprecated in the current flutter.

    opened by afandiyusuf 0
  • Update animated_circular_chart.dart

    Update animated_circular_chart.dart

    ancestorStateOfType has been depreciated. final AnimatedCircularChartState result = context.ancestorStateOfType(const TypeMatcher()); becomes: final AnimatedCircularChartState result = context.findAncestorStateOfType();

    opened by locrianmark 0
  • Issue since FLUTTER 2.0 upgrade

    Issue since FLUTTER 2.0 upgrade

    Filename: .../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_circular_chart-0.1.0/lib/src/animated_circular_chart.dart

    The below line is giving error while building app: line 121, 122: final AnimatedCircularChartState result = context .ancestorStateOfType(const TypeMatcher());

    ERROR: _The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.

    • 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/framework.dart'). Try correcting the name to the name of an existing method, or defining a method named 'ancestorStateOfType'. context.ancestorStateOfType(const TypeMatcher());

    FAILURE: Build failed with an exception.

    • Where: Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

    • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.

    Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

    • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    • Get more help at https://help.gradle.org

    BUILD FAILED in 20s Running Gradle task 'assembleDebug'...
    Running Gradle task 'assembleDebug'... Done 21.9s Exception: Gradle task assembleDebug failed with exit code 1_

    opened by vigshrav 7
  • Make it possible to center label inside the Chart when using multiline label

    Make it possible to center label inside the Chart when using multiline label

    Basically if you use \n and create a new line it will not be centered instead if will be aligned to the left like the default text. Would be really great if it would be possible to center the label

    opened by oskarsh 3
Owner
Victor Choueiri
Victor Choueiri
Tiny charts 🤏 - Sparkline charts for fast data visualization on Flutter apps

Tiny charts ?? - Sparkline charts for fast data visualization on Flutter apps

rows 15 Dec 10, 2022
A powerful Flutter chart library, currently supporting Line Chart, Bar Chart, Pie Chart, Scatter Chart and Radar Chart.

FL Chart ?? A library to draw fantastic charts in Flutter ?? Chart Types LineChart BarChart PieChart Read More Read More Read More ScatterChart RadarC

Iman khoshabi 5.2k Dec 27, 2022
:bar_chart: [wip] Create beautiful, responsive, animated charts using a simple and intuitive API.

fcharts A work-in-progress chart library for Flutter. Until version 1.0.0 the API is subject to change drastically. Needless to say, fcharts is not pr

Keenan Thompson 323 Dec 21, 2022
Flutter Pie chart with animation

Pie Chart This Flutter package provides a Pie Chart Widget with cool animation. Live Demo: https://apgapg.github.io/pie_chart/ ?? Try LIVE Demo Live D

Ayush P Gupta 161 Dec 24, 2022
A simple radial chart for Flutter

A simple radial chart for Flutter

null 2 Jun 2, 2022
Elegant OHLC Candlestick and Trade Volume charts for @Flutter

flutter_candlesticks Elegant OHLC Candlestick and Trade Volume charts for Flutter Usage Install for Flutter with pub. Property Description data Requir

Trent Piercy 402 Dec 21, 2022
Flutter chart library contains depth charts supporting various indicators and zooming

flutter_k_chart 介绍 一个仿火币的flutter图表库包含深度图,支持各种指标及放大缩小、平移等操作 webdemo演示 Demo v0.1.0:下载 APK 演示 简单用例 1.在 pubspec.yaml 中添加依赖 本项目数据来自火币openApi,火币的接口可能需要翻墙,接口

gwh 259 Dec 30, 2022
Charts Library for Flutter, written in Dart with Flutter.

Table of Contents New in the current release Illustration of the new "iterative auto layout" feature Autolayout step 1 Autolayout step 2 Autolayout st

Milan Zimmermann 225 Dec 25, 2022
Beautiful sparkline charts for Flutter

flutter_sparkline Beautiful sparkline charts for Flutter. Installation Install the latest version from pub. Quick Start Import the package, create a S

Victor Choueiri 255 Dec 21, 2022
A library to draw fantastic bar charts race in Flutter

bar_chart_race The first library to draw fantastic bar charts race in Flutter Usage Let's get started add the dependencies to your app: dependencies:

Mimene Younes 6 Jun 24, 2022
A flutter package which makes it easier to plot different types of charts with lots of customization, made purely in dart

multi_charts It is a library that provides different types of charts to plot data points. Currently it supports only Radar Chart, but will support mor

Intkhab Ahmed 28 Nov 9, 2022
Flutter package for creating simple yet modern looking charts

A package for creating simple yet modern looking charts. Five chart types Bar Gauge Line Pie Radar Canvas + DOM modern_charts combines Canvas and DOM

Man Hoang 68 Nov 4, 2022
Flutter Cryptocurrency Charts application based on Clean Architecture.

About the project The purpose of this project is to develop the best Cryptocurrency, markets data and charts experience. This project has been built u

null 25 Jan 1, 2023
Charts [2148⭐] - By Google Team.

Charts is a general charting library, currently enabled for the Flutter mobile UI framework. See the online gallery for supported chart types and exam

Google 2.8k Dec 31, 2022
In this project you will see how to generate charts with the data from the Firestore.

FlutterChartFirestore Flutter Tutorial - Flutter Charts+Firestore Video series can be watched here https://youtu.be/HGkbPrTSndM Getting Started In thi

Whatsupcoders 49 Oct 21, 2022
kg_charts icon library. At present, there are only radar charts

kg_charts icon library. At present, there are only radar charts. Other types of charts may be added later

zhonghua 10 Oct 25, 2022
Animated line chart for flutter

fl_animated_linechart An animated chart library for flutter. Support for datetime axis Multiple y axis, supporting different units Highlight selection

null 51 Sep 25, 2022
A beautiful bezier line chart widget for flutter that is highly interactive and configurable.

Bezier Chart A beautiful bezier line chart widget for flutter that is highly interactive and configurable. Features Multi bezier lines Allow numbers a

Aeyrium 428 Dec 21, 2022
[reborned barcode_scan] A flutter plugin for reading 2D barcodes and QR codes.

Reborned ?? Original barcode_scan was discontinued, so barcode_scan2 was borned with sound null safety support ?? barcode_scan2 A flutter plugin for s

Masayuki Ono (mono) 61 Jan 6, 2023