Go to file
2017-11-03 05:06:42 +02:00
example Add examples 2017-11-03 03:57:39 +02:00
lib Initial commit 2017-11-03 01:54:40 +02:00
screenshots Add screenshots 2017-11-03 03:57:50 +02:00
test Initial commit 2017-11-03 01:54:40 +02:00
.gitignore Initial commit 2017-11-03 01:54:40 +02:00
CHANGELOG.md Initial commit 2017-11-03 01:54:40 +02:00
flutter_circular_chart.iml Initial commit 2017-11-03 01:54:40 +02:00
LICENSE Update LICENSE 2017-11-03 03:50:20 +02:00
pubspec.yaml Add author and homepage to pubspec 2017-11-03 04:11:54 +02:00
README.md Add Installation and Getting Started guides 2017-11-03 05:06:42 +02:00

Flutter Circular Chart

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

Installation

Note: This is a WIP early implementation, use at your own risk. You can install it by including this git repository in your package dependencies:

  dependencies:
      flutter_circular_chart:
        git:
          url: git://github.com/xqwzts/flutter_circular_chart.git

Getting Started

Import the package:

import 'package:flutter_circular_chart/flutter_circular_chart.dart';

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:

@override
Widget build(BuildContext context) {
  return new AnimatedCircularChart(
    key: _chartKey,
    size: const Size(300, 300),
    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);
  });
}