Search code examples
anychart

Force to show all labels


I have an Doughnut chart with chart.labels().position("outside");

It's showing the percentage fine for the fields with a lot of data. Is it possible to "force" show all of them ?

Even when I go to full screen, it's not showing.

I attached image on my chart with missing labels

Looking for "Force show" or Min/Max settings for labels.


Solution

  • You have to tweak outsideLabelsCriticalAngle.

    anychart.onDocumentLoad(() => {
      let data = [
        { x: "A", value: 93.3 },
        { x: "B", value: 5.9 },
        { x: "C", value: 0.5 },
        { x: "D", value: 0.3 }
      ];
    
      let chart = anychart.pie(data);
    
      chart.container("container");
      chart.innerRadius("80%");
      chart.outsideLabelsCriticalAngle(100); // <--- HERE
      chart.labels().position("outside");
      chart.draw();
    });
    #container {
      width: 350px;
      height: 350px;
    }
    <script src="https://cdn.anychart.com/releases/8.11.0/js/anychart-core.min.js"></script>
    <script src="https://cdn.anychart.com/releases/8.11.0/js/anychart-pie.min.js"></script>
    
    <div id="container"></div>