Я хочу передать значения массива в поля данных. Я извлекаю данные json и храню их в массиве.
var data = JSON.parse('<?=$json;?>');
// Labels
data.forEach(function (entry) {
console.log(entry.month + ' ' + entry.year);
});
// Data
data.forEach(function (entry) {
console.log(entry.cnt);
});
Теперь я хочу использовать эти значения чтобы построить диаграмму
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: [], // ???
type: 'line',
defaultFontFamily: 'Poppins',
datasets: [{
data: [], // ???
label: "Количество заявок",
backgroundColor: 'rgba(0,103,255,.15)',
borderColor: 'rgba(0,103,255,0.5)',
borderWidth: 3.5,
pointStyle: 'circle',
pointRadius: 5,
pointBorderColor: 'transparent',
pointBackgroundColor: 'rgba(0,103,255,0.5)',
},]
},