I am working with amcharts 4 pie charts. I want to truncate labels which are long and share small percentage so they don't go outside pie chart boundaries as shown in attached image https://ibb.co/0mJnrgy
As per the amcharts documentation (https://www.amcharts.com/docs/v4/tutorials/dealing-with-piechart-labels-that-dont-fit/) I tried truncate=false but unfortunately that didn't work, Not sure why.
So I tried to achieve it using adapters. Below is what I tried so far. This is working but label as well as tooltip both getting truncated. I have gone through lot of documentation but haven't found any proper solution.
Any clue or help is very appreciated.
Demo & progress : https://codepen.io/amitpatil/pen/bGYEdXK?editors=0110
Nevermind, Managed to find the solution after wasting so many hours.
series.slices.template.adapter.add('tooltipText', (tooltipText, target) => {
const {
dataItem: {
values: {value : {percent}},
component: { dataFields : {category} }
}
} = target;
return `${target.dataItem._dataContext[category]} : ${percent}%`;
});
Here is the complete demo https://codepen.io/amitpatil/pen/jOaqJOz?editors=0010