team-moeller / better-access-charts

Better charts for Access with chart.js
MIT License
38 stars 14 forks source link

No chart when Datalabels are activated in pie chart #182

Closed team-moeller closed 6 months ago

team-moeller commented 6 months ago

When you choose a pie chart and activate datalabels the chart is not drawn

team-moeller commented 6 months ago

This is the generated code, the problematic lines are commented out

var myChart = new Chart(ctx, {
    type: 'pie',
    data: {
        labels: ['Berlin','London','Paris','Rome','Lisbon','Madrid',],
        datasets: [
           {label: 'Data' ,
            data: [2,13,7,9,12,5],
            borderWidth: 1}
         ]
    },
    options: {
        aspectRatio:  1.6,
        plugins: {
            title: {
                display: true,
                position: 'top',
                text: 'I love Better Access Charts'
            },
            subtitle: {
                display: false,
            },
            legend: {
                display: true,
                position: 'right'
            },
            datalabels: {
                <!--color: (context) => {-->
                    <!--const x = context.chart.scales.x;-->
                    <!--if (context.dataIndex >= x.min && context.dataIndex <= x.max) {-->
                        <!--return ;-->
                    <!--} else {-->
                        <!--return 'transparent';-->
                    <!--}-->
                <!--}-->
            },
            autocolors: {
                mode: 'data'
            }
        }
    }
});
team-moeller commented 6 months ago

Chart types Radar, Doughnut and PolarArea are also affected

team-moeller commented 6 months ago

Released with version 4.20.01