title: Having Pie-Chart with Data points in the Legend section
body: <p>i am trying to have some datapoints show in the legends section however, since the new update on chart.js im not able to do it. All the youtube videos and help are in lower version which i dont want to use.</p>
  <p>these are the resources i used which is in 2.9.x but doesnt work with 3.x.x</p>
  <p><a href="https://i.stack.imgur.com/UMn8v.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>i have tried looking at other stackedoverflow but cant find the one i want like above.</p>
  <p><a href="https://www.youtube.com/watch?v=c54SB6wVnQw&amp;t=862s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=c54SB6wVnQw&amp;t=862s</a></p>
  <p><a href="https://giselamirandadifini.com/creating-a-custom-chart.js-legend-style" rel="nofollow noreferrer">https://giselamirandadifini.com/creating-a-custom-chart.js-legend-style</a></p>
  <p>Please could you help me?</p>
  <p>my code below</p>
  <pre><code>    &lt;div class=&quot;chart1&quot;&gt;
              &lt;canvas id=&quot;dougnut1&quot;&gt;&lt;/canvas&gt;
            &lt;/div&gt;
  
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // START OF DOUGHNUT CHART
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  const doughnutLabels = [];
  const doughnutData = [];
  function handleHover(evt, item, legend) {
    legend.chart.data.datasets[0].backgroundColor.forEach(
      (color, index, colors) =&gt; {
        colors[index] =
          index === item.index || color.length === 9 ? color : color + &quot;4D&quot;;
      }
    );
    legend.chart.update();
  }
  
  function handleLeave(evt, item, legend) {
    legend.chart.data.datasets[0].backgroundColor.forEach(
      (color, index, colors) =&gt; {
        colors[index] = color.length === 9 ? color.slice(0, -2) : color;
      }
    );
    legend.chart.update();
  }
  
  async function showDoughnutChart() {
    await getDataDoughnutGraph();
    const doughnutChart = document.getElementById(&quot;dougnut1&quot;).getContext(&quot;2d&quot;);
  
    let chart3a = new Chart(doughnutChart, {
      type: &quot;doughnut&quot;,
      data: {
        labels: doughnutLabels,
        datasets: [
          {
            label: &quot;Some metric&quot;,
            backgroundColor: [
              &quot;#619E98&quot;,
              &quot;#4164BE&quot;,
              &quot;#7D35CA&quot;,
              &quot;#B2A44D&quot;,
              &quot;#946B76&quot;,
              &quot;#6C9D62&quot;,
              &quot;#C6B139&quot;,
              &quot;#2688D9&quot;,
              &quot;#D62963&quot;,
              &quot;#CCBF33&quot;,
              &quot;#adff2f&quot;,
              &quot;#B6495D&quot;,
            ],
            borderWidth: 1,
            borderRadius: 5,
            cutout: &quot;50%&quot;,
            data: doughnutData,
          },
        ],
      },
      options: {
        plugins: {
          legend: {
            display: true,
            position: &quot;right&quot;,
            onHover: handleHover,
            onLeave: handleLeave,
          },
          title: {
            display: true,
            text: &quot;Tag Distrubution by Class&quot;,
            color: &quot;black&quot;,
          },
        },
        layout: {
          padding: 10,
        },
        maintainAspectRatio: false,
        responsive: true,
      },
    });
  }
  
  async function getDataDoughnutGraph() {
    const responseLine = await fetch(
      &quot;stats/Stats_Tags_Total_Yesterday_By_Category.csv&quot;
    );
    const chart3el = document.getElementById(&quot;dougnut1&quot;).getContext(&quot;2d&quot;);
    const data = await responseLine.text();
    const table = data.split(&quot;\n&quot;).slice(0);
    table.forEach((row) =&gt; {
      const columns = row.split(&quot;,&quot;);
      const perDay = columns[0];
      doughnutLabels.push(perDay);
      const numbOfDocPerClass = columns[1];
      doughnutData.push(numbOfDocPerClass);
    });
  }
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // END OF DOUGHNUT CHART
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  </code></pre>