I am creating a piechart using chart.js. I have a json data like
[
{
"Subcontractor": "C1",
"Deficiency": 67
},
{
"Subcontractor": "C2",
"Deficiency": 25
},
{
"Subcontractor": "C3",
"Deficiency": 12
},
{
"Subcontractor": "C5",
"Deficiency": 7
},
{
"Subcontractor": "C4",
"Deficiency": 5
},
{
"Subcontractor": "C6",
"Deficiency": 1
}
]
I want to use the Subcontractor
value as the pie chart label and the Deficiency
value as the chart value.
How to pass this dynamically into the pie chart in chart.js?
Also, when I click on a particular slice I want to reload/refresh the pie chart with different data.