Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter flutter logo circular chart

a library for creating animated circular chart widgets with flutter, inspired by zero to one with flutter.

create easily animated pie charts, circular chart and radial charts by providing them with data objects they can plot into charts and animate between.

animated circular chart widgets
animated_radial_chart_example_label
animated_pie_chart_example
animated circular chart widgets

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

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:

propertydefault
holelabelnull
labelstyletheme.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
animated circular chart example

segment edge style:

propertydefault
edgestylesegmentedgestyle.flat
segmentedgestyledescription
flat (default)segments begin and end with a flat edge.
roundsegments 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,
)
segment_edge_round_example

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.

download the full project for this post from the following button

this source is fully free for all time

download as zip


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Top