Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
toDataUrl() gives a blank image

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>

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!