general update
This commit is contained in:
1 parent
6755e96f06
commit
43a1d9b47d
13 files changed
+158
-191
No files matched your search
@@ -1,42 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_circular_chart/flutter_circular_chart.dart';
|
||||
import 'package:flutter_circular_chart_two/flutter_circular_chart.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
home: new AnimatedPieChartExample(),
|
||||
runApp(MaterialApp(
|
||||
home: AnimatedPieChartExample(),
|
||||
));
|
||||
}
|
||||
|
||||
final List<List<CircularStackEntry>> _quarterlyProfitPieData = [
|
||||
<CircularStackEntry>[
|
||||
new CircularStackEntry(
|
||||
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'),
|
||||
CircularSegmentEntry(500.0, Colors.red[200], rankKey: 'Q1'),
|
||||
CircularSegmentEntry(1000.0, Colors.green[200], rankKey: 'Q2'),
|
||||
CircularSegmentEntry(2000.0, Colors.blue[200], rankKey: 'Q3'),
|
||||
CircularSegmentEntry(1000.0, Colors.yellow[200], rankKey: 'Q4'),
|
||||
],
|
||||
rankKey: 'Quarterly Profits',
|
||||
),
|
||||
],
|
||||
<CircularStackEntry>[
|
||||
new CircularStackEntry(
|
||||
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'),
|
||||
CircularSegmentEntry(1500.0, Colors.red[200], rankKey: 'Q1'),
|
||||
CircularSegmentEntry(750.0, Colors.green[200], rankKey: 'Q2'),
|
||||
CircularSegmentEntry(2000.0, Colors.blue[200], rankKey: 'Q3'),
|
||||
CircularSegmentEntry(1000.0, Colors.yellow[200], rankKey: 'Q4'),
|
||||
],
|
||||
rankKey: 'Quarterly Profits',
|
||||
),
|
||||
],
|
||||
<CircularStackEntry>[
|
||||
new CircularStackEntry(
|
||||
CircularStackEntry(
|
||||
<CircularSegmentEntry>[
|
||||
new CircularSegmentEntry(1800.0, Colors.red[200], rankKey: 'Q1'),
|
||||
new CircularSegmentEntry(2900.0, Colors.green[200], rankKey: 'Q2'),
|
||||
new CircularSegmentEntry(4000.0, Colors.blue[200], rankKey: 'Q3'),
|
||||
new CircularSegmentEntry(7000.0, Colors.yellow[200], rankKey: 'Q4'),
|
||||
CircularSegmentEntry(1800.0, Colors.red[200], rankKey: 'Q1'),
|
||||
CircularSegmentEntry(2900.0, Colors.green[200], rankKey: 'Q2'),
|
||||
CircularSegmentEntry(4000.0, Colors.blue[200], rankKey: 'Q3'),
|
||||
CircularSegmentEntry(7000.0, Colors.yellow[200], rankKey: 'Q4'),
|
||||
],
|
||||
rankKey: 'Quarterly Profits',
|
||||
),
|
||||
@@ -45,13 +45,11 @@ final List<List<CircularStackEntry>> _quarterlyProfitPieData = [
|
||||
|
||||
class AnimatedPieChartExample extends StatefulWidget {
|
||||
@override
|
||||
_AnimatedPieChartExampleState createState() =>
|
||||
new _AnimatedPieChartExampleState();
|
||||
_AnimatedPieChartExampleState createState() => _AnimatedPieChartExampleState();
|
||||
}
|
||||
|
||||
class _AnimatedPieChartExampleState extends State<AnimatedPieChartExample> {
|
||||
final GlobalKey<AnimatedCircularChartState> _chartKey =
|
||||
new GlobalKey<AnimatedCircularChartState>();
|
||||
final GlobalKey<AnimatedCircularChartState> _chartKey = GlobalKey<AnimatedCircularChartState>();
|
||||
final _chartSize = const Size(300.0, 300.0);
|
||||
int sampleIndex = 0;
|
||||
|
||||
@@ -65,20 +63,20 @@ class _AnimatedPieChartExampleState extends State<AnimatedPieChartExample> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Quarterly Profit'),
|
||||
),
|
||||
body: new Center(
|
||||
child: new AnimatedCircularChart(
|
||||
body: Center(
|
||||
child: AnimatedCircularChart(
|
||||
key: _chartKey,
|
||||
size: _chartSize,
|
||||
initialChartData: _quarterlyProfitPieData[0],
|
||||
chartType: CircularChartType.Pie,
|
||||
),
|
||||
),
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
child: new Icon(Icons.refresh),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: Icon(Icons.refresh),
|
||||
onPressed: _cycleSamples,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_circular_chart/flutter_circular_chart.dart';
|
||||
import 'package:flutter_circular_chart_two/flutter_circular_chart.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
home: new AnimatedRadialChartExample(),
|
||||
runApp(MaterialApp(
|
||||
home: AnimatedRadialChartExample(),
|
||||
));
|
||||
}
|
||||
|
||||
class AnimatedRadialChartExample extends StatefulWidget {
|
||||
@override
|
||||
_AnimatedRadialChartExampleState createState() =>
|
||||
new _AnimatedRadialChartExampleState();
|
||||
_AnimatedRadialChartExampleState createState() => _AnimatedRadialChartExampleState();
|
||||
}
|
||||
|
||||
class _AnimatedRadialChartExampleState
|
||||
extends State<AnimatedRadialChartExample> {
|
||||
final GlobalKey<AnimatedCircularChartState> _chartKey =
|
||||
new GlobalKey<AnimatedCircularChartState>();
|
||||
class _AnimatedRadialChartExampleState extends State<AnimatedRadialChartExample> {
|
||||
final GlobalKey<AnimatedCircularChartState> _chartKey = GlobalKey<AnimatedCircularChartState>();
|
||||
final _chartSize = const Size(200.0, 200.0);
|
||||
|
||||
double value = 50.0;
|
||||
@@ -48,9 +45,9 @@ class _AnimatedRadialChartExampleState
|
||||
labelColor = dialColor;
|
||||
|
||||
List<CircularStackEntry> data = <CircularStackEntry>[
|
||||
new CircularStackEntry(
|
||||
CircularStackEntry(
|
||||
<CircularSegmentEntry>[
|
||||
new CircularSegmentEntry(
|
||||
CircularSegmentEntry(
|
||||
value,
|
||||
dialColor,
|
||||
rankKey: 'percentage',
|
||||
@@ -63,9 +60,9 @@ class _AnimatedRadialChartExampleState
|
||||
if (value > 100) {
|
||||
labelColor = Colors.green[200];
|
||||
|
||||
data.add(new CircularStackEntry(
|
||||
data.add(CircularStackEntry(
|
||||
<CircularSegmentEntry>[
|
||||
new CircularSegmentEntry(
|
||||
CircularSegmentEntry(
|
||||
value - 100,
|
||||
Colors.green[200],
|
||||
rankKey: 'percentage',
|
||||
@@ -80,20 +77,17 @@ class _AnimatedRadialChartExampleState
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
TextStyle _labelStyle = Theme
|
||||
.of(context)
|
||||
.textTheme
|
||||
.title
|
||||
.merge(new TextStyle(color: labelColor));
|
||||
TextStyle _labelStyle =
|
||||
Theme.of(context).textTheme.headline6.merge(TextStyle(color: labelColor));
|
||||
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Percentage Dial'),
|
||||
),
|
||||
body: new Column(
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
child: new AnimatedCircularChart(
|
||||
Container(
|
||||
child: AnimatedCircularChart(
|
||||
key: _chartKey,
|
||||
size: _chartSize,
|
||||
initialChartData: _generateChartData(value),
|
||||
@@ -104,17 +98,17 @@ class _AnimatedRadialChartExampleState
|
||||
labelStyle: _labelStyle,
|
||||
),
|
||||
),
|
||||
new Row(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
new RaisedButton(
|
||||
RaisedButton(
|
||||
onPressed: _decrement,
|
||||
child: const Icon(Icons.remove),
|
||||
shape: const CircleBorder(),
|
||||
color: Colors.red[200],
|
||||
textColor: Colors.white,
|
||||
),
|
||||
new RaisedButton(
|
||||
RaisedButton(
|
||||
onPressed: _increment,
|
||||
child: const Icon(Icons.add),
|
||||
shape: const CircleBorder(),
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_circular_chart/flutter_circular_chart.dart';
|
||||
import 'package:flutter_circular_chart_two/flutter_circular_chart.dart';
|
||||
import 'dart:math' as Math;
|
||||
|
||||
import 'color_palette.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
home: new RandomizedRadialChartExample(),
|
||||
runApp(MaterialApp(
|
||||
home: RandomizedRadialChartExample(),
|
||||
));
|
||||
}
|
||||
|
||||
class RandomizedRadialChartExample extends StatefulWidget {
|
||||
@override
|
||||
_RandomizedRadialChartExampleState createState() =>
|
||||
new _RandomizedRadialChartExampleState();
|
||||
_RandomizedRadialChartExampleState createState() => _RandomizedRadialChartExampleState();
|
||||
}
|
||||
|
||||
class _RandomizedRadialChartExampleState
|
||||
extends State<RandomizedRadialChartExample> {
|
||||
final GlobalKey<AnimatedCircularChartState> _chartKey =
|
||||
new GlobalKey<AnimatedCircularChartState>();
|
||||
class _RandomizedRadialChartExampleState extends State<RandomizedRadialChartExample> {
|
||||
final GlobalKey<AnimatedCircularChartState> _chartKey = GlobalKey<AnimatedCircularChartState>();
|
||||
final _chartSize = const Size(300.0, 300.0);
|
||||
final Math.Random random = new Math.Random();
|
||||
final Math.Random random = Math.Random();
|
||||
List<CircularStackEntry> data;
|
||||
|
||||
@override
|
||||
@@ -41,13 +38,13 @@ class _RandomizedRadialChartExampleState
|
||||
|
||||
List<CircularStackEntry> _generateRandomData() {
|
||||
int stackCount = random.nextInt(10);
|
||||
List<CircularStackEntry> data = new List.generate(stackCount, (i) {
|
||||
List<CircularStackEntry> data = List.generate(stackCount, (i) {
|
||||
int segCount = random.nextInt(10);
|
||||
List<CircularSegmentEntry> segments = new List.generate(segCount, (j) {
|
||||
List<CircularSegmentEntry> segments = List.generate(segCount, (j) {
|
||||
Color randomColor = ColorPalette.primary.random(random);
|
||||
return new CircularSegmentEntry(random.nextDouble(), randomColor);
|
||||
return CircularSegmentEntry(random.nextDouble(), randomColor);
|
||||
});
|
||||
return new CircularStackEntry(segments);
|
||||
return CircularStackEntry(segments);
|
||||
});
|
||||
|
||||
return data;
|
||||
@@ -55,19 +52,19 @@ class _RandomizedRadialChartExampleState
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Randomized radial data'),
|
||||
),
|
||||
body: new Center(
|
||||
child: new AnimatedCircularChart(
|
||||
body: Center(
|
||||
child: AnimatedCircularChart(
|
||||
key: _chartKey,
|
||||
size: _chartSize,
|
||||
initialChartData: data,
|
||||
chartType: CircularChartType.Radial,
|
||||
),
|
||||
),
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _randomize,
|
||||
child: const Icon(Icons.refresh),
|
||||
),
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ColorPalette {
|
||||
static final ColorPalette primary = new ColorPalette(<Color>[
|
||||
static final ColorPalette primary = ColorPalette(<Color>[
|
||||
Colors.blue[400],
|
||||
Colors.blue[200],
|
||||
Colors.red[400],
|
||||
|
||||
Reference in new issue
Block a user