Reputation: 21
Im trying to make my PieChart Labels visible, but after set arcRenderDecorators it comes to
What kind of Widget I must to use to do it works. Please help.
final List<DeveloperSeries> data = [
DeveloperSeries(
year: "2017",
developers: 40000,
barColor: charts.ColorUtil.fromDartColor(Colors.blue),
),
DeveloperSeries(
year: "2019",
developers: 40000,
barColor: charts.ColorUtil.fromDartColor(Colors.blue),
),
DeveloperSeries(
year: "2020",
developers: 35000,
barColor: charts.ColorUtil.fromDartColor(Colors.blue),
),
DeveloperSeries(
year: "2021",
developers: 45000,
barColor: charts.ColorUtil.fromDartColor(Colors.blue),
),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: DeveloperChart(
data: data,
)
),
);
}
}
class DeveloperChart extends StatelessWidget {
final List<DeveloperSeries> data;
DeveloperChart({required this.data});
@override
Widget build(BuildContext context) {
List<charts.Series<DeveloperSeries, String>> series = [
charts.Series(
id: "developers",
data: data,
domainFn: (DeveloperSeries series, _) => series.year,
measureFn: (DeveloperSeries series, _) => series.developers,
colorFn: (DeveloperSeries series, _) => series.barColor,
labelAccessorFn: (DeveloperSeries row, _) => row.year,
)
];
return Container(
height: 500,
width: 500,
child: Card(
child: Padding(
padding: const EdgeInsets.all(9.0),
child: Column(
children: <Widget>[
Text(
"Yearly Growth in the Flutter Community",
style: Theme
.of(context)
.textTheme
.bodyText2,
),
Expanded(
child: charts.PieChart(series, animate: true,
defaultRenderer: charts.ArcRendererConfig(
arcRendererDecorators: [
charts.ArcLabelDecorator(
labelPosition: charts.ArcLabelPosition
.outside)
])
)
)
]
),
),
)
);
}
}```
Upvotes: 2
Views: 640
Reputation: 31
Same issue, I solved it by replacing:
charts.PieChart(
With:
charts.PieChart<String>(
Upvotes: 3