Chartjs-Who know how to put down the title of pie in ionic 2

0👍

You can achieve this by setting the label / legend ‘s position.

options: {
    legend: {
        position: 'bottom'
    }
}

The full code would be like this …

this.pieChart = new Chart(this.pieCanvas.nativeElement, {
    type: 'pie',
    data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
            label: '# of Votes',
            data: [12, 19, 3, 5, 2, 3],
            backgroundColor: [
                    "#ff0000",
                    "#0000ff",
                    "#ffff00",
                    "#008000",
                    "#800080",
                    "#ffa500"
                ]
            }]
    },
    options: {
        legend: {
            position: 'bottom'
        }
    }
});

Leave a comment