Need to display Values of the slices on the slices of the pie chart using chart.js

39 Views Asked by At

i am using the latest version of chart.js which is 4.4.0 and i cant seem to display the values of the slices of my pie chart on the slices with this build when i try it on the 2.9.3 build it works.

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src='https://cdn.jsdelivr.net/gh/emn178/chartjs-plugin-labels/src/chartjs-plugin-labels.js' </script>
<script>
        // setup AccDefChart
        const data = {
            labels: ['Accepted', 'Deficit'],
            datasets: [{
                label: 'Accepted Leads Deficit Leads',
                data: [12, 19],
                backgroundColor: [
                    'rgba(255, 99, 132, 0.2)',
                    'rgba(54, 162, 235, 0.2)',
                ],
                borderColor: [
                    'rgba(255, 99, 132, 1)',
                    'rgba(54, 162, 235, 1)'
                ],
                borderWidth: 1
            }]
        };
        // config AccDef
        const AccDef = {
            type: 'pie',
            data,
            options: {
                plugins: {
                    labels: {
                        render: 'value',
    
                    }
                }
            }
        };
        //render AccDefChart
        const myChart = new Chart(
            document.getElementById('AccDefchart'),
            AccDef
        );
</script>
    <div class="ChartBoxPie">
        <canvas id="AccDefchart"></canvas>
    </div>
0

There are 0 best solutions below