anychart.onDocumentReady(function () {
{x: "A single long label", value: 637166},
var chart = anychart.pie(data);
let longestLabelChars = 0
chart.labels().position("outside").format(function(e){
if(longestLabelChars < e.x.length){
longestLabelChars = e.x.length
console.log(`Before draw - ${longestLabelChars}`)
chart.connectorStroke({color: "#595959", thickness: 2, dash:"2 2"});
const resizeObserver = new ResizeObserver((entries) => {
const currentContainerWidth = entries[0].contentRect.width;
const radiusBreakPoint = longestLabelChars+200;
if (chart.getPixelRadius() < currentContainerWidth*0.1 ) {
console.log("switch labels position to INSIDE")
chart.labels().position("inside")
chart.title("Pie Chart: Inner Labels")
else if(currentContainerWidth > radiusBreakPoint && chart.getPixelRadius() > radiusBreakPoint){
console.log("switch labels position to OUTSIDE")
chart.labels().position("outside")
chart.title("Pie Chart: Outer Labels")
resizeObserver.observe(document.getElementById("container"));
chart.title("change container size to change labels position");
chart.container("container");
console.log(`After draw - ${longestLabelChars}`)