amcharts3 icon indicating copy to clipboard operation
amcharts3 copied to clipboard

Can I truncate long legends on Pie Charts without affects in chart Labels?

Open rrubenich opened this issue 6 years ago • 1 comments

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?

rrubenich avatar Dec 26 '17 13:12 rrubenich

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.

martynasma avatar Feb 11 '18 06:02 martynasma