How to show duplicate axis label on the X-Axis of a BarChart in Flutter Charts?
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
.
Mohtasim
Software Engineer with a demonstrated history of working in the research industry. Skilled in C++, Java, Javascript, Dynamic Programming, Graph Theory, Algorithms, Spring-Boot, React, Flutter, React-Native, Android, SQL, Git. Strong engineering professional with a Bachelor of Science (B.Sc.) and Master of Science (M. Sc.) focused in Computer Science and Engineering from Jahangirnagar University.
Updated on December 15, 2022Comments
-
Mohtasim over 1 year
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.