I need your help to learn how to dynamically implement data from a json file to Chartjs. The fields that I need to fill dynamically are labels
and data
.
JSON File <<<
[
{
"EFICAZ_TAB_ITEM_ID":1,
"EFICAZ_PERCENTS":99
},
{
"EFICAZ_TAB_ITEM_ID":2,
"EFICAZ_PERCENTS":99
},
{
"EFICAZ_TAB_ITEM_ID":3,
"EFICAZ_PERCENTS":99
}
]
CHARTJS <<<
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line',
// The data for our dataset
data: {
labels: [???],
datasets: [{
label: "My First dataset",
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [???],
}]
},
// Configuration options go here
options: {}
});