Reputation: 121
Is there any way to show duplicate axis label in BarChart of Flutter_chart library in the domainAxis property. I am using charts_flutter library (https://pub.dev/packages/charts_flutter#-installing-tab-).
Thanks in advance.
Upvotes: 1
Views: 815
Reputation: 1876
I know this is an old question but for anyone else looking for this, an easy workaround is to symmetrically add spaces to repeated labels. This can be done using a callable class for your domain function, so that you can keep track of repeats:
class Labeler {
final existingLabels = <String>[];
String call(Data data, int index) {
String baseLabel = data.toString();
int existingCount = existingLabels.where((element) => element == baseLabel).length;
existingLabels.add(baseLabel);
return ' ' * existingCount + baseLabel + ' ' * existingCount;
}
}
You can then create an instance and set it as your domainFn
.
Upvotes: 2