I need to make Doughnut chart with React-Chart-js2 . Chart should look like below
Questions:
- I have added Data(12%,10% etc) in the chart. But how to add labels (1 star, 2star)?
- How to put text (1234 Total Feedback) in the center of chart?
- Is it possible to highlight the hovered portion as mentioned in the image?
Code: const donutChart = {
labels:['1 star','2 star','3 star','4 star'],
datasets: [{
data: [10, 50, 10,40],
backgroundColor: [
'#808080',
'#808080',
'#808080',
'#808080'
],
hoverBackgroundColor: [
'#FF5733',
'#FF5733',
'#FF5733',
'#FF5733'
],
hoverBorderColor : [
'#FF5733',
'#FF5733',
'#FF5733',
'#FF5733'
],
}
]
}
function Reports() {
return (
<div>
<Doughnut
data={donutChart}
options={{
padding:"0px",
responsive:true,
maintainAspectRatio:true,
defaultFontSize:"14px",
title:{
display:true,
text:'Total Feedback',
fontSize:30,
},
legend:{
display:false,
},
plugins:{
datalabels: {
color:'red',
anchor: "start",
align:"end",
}
}
}}
/>
</div>
)
}