I have two datasets coming from Express called cDate, cPrice and they have data.length elements. I want to draw these datas on a chart.I tried many things but the graphic is not updating. My final sample code is here, many thanks !
<% for(i=0; i<data.length; i++){ %>
<script>
var ctx = document.querySelector("#myChart");
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['<%= cDate[i] %>'],
datasets: [
{
data: ['<%= cPrice[i] %>'],
label: ['<%= name[0] %>'], //Constant
borderColor: "#3e95cd",
fill: false
}
]
}
});
myChart.data.datasets.push({
data: ['<%= cPrice[i] %>'],
label: ['<%= name[0] %>'],
borderColor: "#3e95cd",
fill: false
})
myChart.data.push({
labels: ['<%= cDate[i] %>']
})
</script>
<% } %>