score:4

Accepted answer

yes! that's absolutely possible.

though you could create your own plugin but, i would suggest using a chartjs plugin called chart.piecelabel.js , which makes it much more easier to accomplish.

usage add the following in your chart options

piecelabel: {
    mode: 'value'
}

var randomscalingfactor = function() {
    return math.round(math.random() * 100);
};
var ctx = document.getelementbyid("chart-area").getcontext("2d");
var mydoughnut = new chart(ctx, {
    type: 'doughnut',
    data: {
        labels: ["january", "february", "march", "april", "may"],
        datasets: [{
            data: [
                randomscalingfactor(),
                randomscalingfactor(),
                randomscalingfactor(),
                randomscalingfactor(),
                randomscalingfactor(),
            ],
            backgroundcolor: ['#ff3d67', '#ff9f40', '#ffcd56', '#4bc0c0', '#999999'],
            bordercolor: 'white',
            borderwidth: 5,
        }]
    },
    showdatapoints: true,
    options: {
        tooltips: {
            enabled: false
        },
        piecelabel: {
            mode: 'value'
        },
        responsive: true,
        legend: {
            position: 'bottom',
        },
        title: {
            display: true,
            text: 'idades',
            fontsize: 20
        },
        animation: {
            animatescale: true,
            animaterotate: true
        }
    }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.5.0/chart.min.js"></script>
<script src="https://cdn.rawgit.com/emn178/chart.piecelabel.js/master/build/chart.piecelabel.min.js"></script>
<canvas id="chart-area"></canvas>


Related Query

More Query from same tag