I'm trying to create a Doughnut chart that has outer labels for each datapoint, showing its value. The labels have been customized using a builder.
Unfortunately, many of the labels are completely hidden, even though it looks like at least some of them should have no problems fitting inside the available space:
These are my chart label settings:
DataLabelSettings(
overflowMode: OverflowMode.shift,
labelIntersectAction: LabelIntersectAction.shift,
margin: EdgeInsets.all(0),
isVisible: true,
textStyle: TextStyle(
fontSize: 10,
),
borderWidth: 0,
labelPosition:
ChartDataLabelPosition
.outside,
connectorLineSettings:
ConnectorLineSettings(
// Type of the connector line
type:
ConnectorType.line),
builder: (dynamic data, dynamic point, dynamic series, int pointIndex, int seriesIndex) {
return Text(
getInvestmentAsString(point.y),
overflow: TextOverflow.ellipsis,
softWrap: false,
style: kDistributionChartLabelTextStyle);
}
),
As you can see, both the 'overflow' and the 'label intersection' settings are set to 'shift', and inside the builder I've also set the text overflow setting to 'ellipsis' and the softWrap to 'false', just in case.
I've played around a lot with all of these settings, but none of them seem to make any difference.
The chart is nested as follows:
Card -> Padding (15.0) -> Column -> SfCircularChart
It looks to me like the space used by the labels themselves is just not considered when dimensioning the whole chart widget. But even if that cannot be fixed, I wish I had the option to force the labels to stay in place, even if they overflow slightly, or at the very least have them clipped/trimmed rather than hidden.
In this case, it would be perfectly acceptable to have the labels slightly invading the padding of the card, but it seems they're removed no matter which settings I choose.
Workarounds that I've tried:
Thanks so much for the quick solution!
Will give it a try and let you know if I find any problems.
Best regards,
Víctor.