amcharts3
amcharts3 copied to clipboard
Can I truncate long legends on Pie Charts without affects in chart Labels?
Following the sample in https://www.amcharts.com/kbase/truncating-long-legend-labels-on-pie-chart/ I can truncate the legends, but when the property labelsEnabled
is true, the same short legends are showed as labels.
I've tried to pass this function in the labelFunction:
return function(data) {
data.title = legendLimit && (legendLimit + 3) < data.title.length
? data.title.substr(0, legendLimit) + '...'
: data.title;
return `${data.title}: ${data.value}`;
};
But the behavior persists.
In Pie Charts there is a way to transform only the legends?
Oh, it's been a while. Sorry for noticing only now. We don't monitor github issues as closely as other support channels.
The solution is very simple.
In the example balloonText
is being replaced with something else to display full titles in balloon.
You can do the same with labelText
:
chart.balloonText = chart.balloonText.replace(/\[\[title\]\]/, "[["+titleField+"]]");
chart.labelText = chart.balloonText;
Hope this is still helpful.