How can get values of DataSet in legend label please with Chart js on Angular ?
In legend Like :
centre1 55
centre2 25
centre3 20
export class DoughnutChartComponent {
doughnutChartLabels: Label[] = ['Centre1', 'Centre2', 'Centre3'];
doughnutChartData: MultiDataSet = [
[55, 25, 20]
];
doughnutChartOptions: ChartOptions = { legend: {
display: true,
position: 'right',
fullWidth:false,
labels: {
usePointStyle: true,
boxWidth: 10,
padding: 7,
fontSize: 18,
fontColor: '#003457',
fontStyle: 'bold'
},
},
cutoutPercentage: 70,
};
doughnutChartType: ChartType = 'doughnut';
doughnutChartColor: Colors[] = [{
backgroundColor: [
'#2E9FE0',
'#9CCA32',
'#255FCC',
]
}] ;
}
I tried to add legenTemplate but don't working.
Thank for your help
Make your labels array like this:
doughnutChartLabels: Label[] = ['Centre1 55', 'Centre2 25', 'Centre3 20'];Instead of doing it hardcoded like this you would need to do this in a loop beforehand