I saw this question answered multiple times but I haven't find a solution. I won't put everything inside the chart because Its a pretty long function and it works perfectly, so I don't think the problem is there, please help :´(
JS: I know some '}' are missing, i just copied the important part
var ctx = document.getElementById("myChart").getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(20, 20, 150, 100);
var myChart = new Chart(ctx, {
type: 'scatter',
data: {
datasets: [{
label: 'Tiempo-Hole',
borderColor: window.chartColors.red,
fill: false,
pointRadius: 0,
data: storage,
showLine: true,
},
options: {
bezierCurve : false,
animation: {
onComplete: done
},
}
}
}); ```
function done(){
alert("haha");
var chartR = document.getElementById("myChart");
var img = chartR.toDataURL("image/png");
document.getElementById('base64').value = img;
}
PHP/HTML: This goes inside some divs, etc...
<img name="base64" id="base64" src="">
<canvas id="myChart"></canvas>