Update example to use holeLabel
This commit is contained in:
parent
a6e061feb1
commit
1c846b4e21
@ -20,6 +20,7 @@ class _AnimatedRadialChartExampleState
|
|||||||
final _chartSize = const Size(200.0, 200.0);
|
final _chartSize = const Size(200.0, 200.0);
|
||||||
|
|
||||||
double value = 50.0;
|
double value = 50.0;
|
||||||
|
Color labelColor = Colors.blue[200];
|
||||||
|
|
||||||
void _increment() {
|
void _increment() {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -44,6 +45,7 @@ class _AnimatedRadialChartExampleState
|
|||||||
} else if (value < 50) {
|
} else if (value < 50) {
|
||||||
dialColor = Colors.yellow[200];
|
dialColor = Colors.yellow[200];
|
||||||
}
|
}
|
||||||
|
labelColor = dialColor;
|
||||||
|
|
||||||
List<CircularStackEntry> data = <CircularStackEntry>[
|
List<CircularStackEntry> data = <CircularStackEntry>[
|
||||||
new CircularStackEntry(
|
new CircularStackEntry(
|
||||||
@ -59,6 +61,8 @@ class _AnimatedRadialChartExampleState
|
|||||||
];
|
];
|
||||||
|
|
||||||
if (value > 100) {
|
if (value > 100) {
|
||||||
|
labelColor = Colors.green[200];
|
||||||
|
|
||||||
data.add(new CircularStackEntry(
|
data.add(new CircularStackEntry(
|
||||||
<CircularSegmentEntry>[
|
<CircularSegmentEntry>[
|
||||||
new CircularSegmentEntry(
|
new CircularSegmentEntry(
|
||||||
@ -76,6 +80,12 @@ class _AnimatedRadialChartExampleState
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
TextStyle _labelStyle = Theme
|
||||||
|
.of(context)
|
||||||
|
.textTheme
|
||||||
|
.title
|
||||||
|
.merge(new TextStyle(color: labelColor));
|
||||||
|
|
||||||
return new Scaffold(
|
return new Scaffold(
|
||||||
appBar: new AppBar(
|
appBar: new AppBar(
|
||||||
title: const Text('Percentage Dial'),
|
title: const Text('Percentage Dial'),
|
||||||
@ -89,17 +99,27 @@ class _AnimatedRadialChartExampleState
|
|||||||
initialChartData: _generateChartData(value),
|
initialChartData: _generateChartData(value),
|
||||||
chartType: CircularChartType.Radial,
|
chartType: CircularChartType.Radial,
|
||||||
percentageValues: true,
|
percentageValues: true,
|
||||||
|
holeLabel: '$value%',
|
||||||
|
labelStyle: _labelStyle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
new Text(
|
|
||||||
'%$value',
|
|
||||||
style: Theme.of(context).textTheme.title,
|
|
||||||
),
|
|
||||||
new Row(
|
new Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new RaisedButton(onPressed: _increment, child: const Text('+10')),
|
new RaisedButton(
|
||||||
new RaisedButton(onPressed: _decrement, child: const Text('-10')),
|
onPressed: _decrement,
|
||||||
|
child: const Icon(Icons.remove),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
color: Colors.red[200],
|
||||||
|
textColor: Colors.white,
|
||||||
|
),
|
||||||
|
new RaisedButton(
|
||||||
|
onPressed: _increment,
|
||||||
|
child: const Icon(Icons.add),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
color: Colors.blue[200],
|
||||||
|
textColor: Colors.white,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user