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

225
Views
Chart.js doughnut chart insufficient height

I was working on a dashboard which has a doughnut chart on the right side of the page. While I was successful at making the the itself i've been struggling with the height of the the chart. If canvas tag is set using attributes the the whole chart stretches and the height of the chart has a default size of of (128px).

enter image description here

Here is the code below:-


    <input type="text" name="balance" value="42" id="balance" hidden>
    <div class="chartWrapper">
        <canvas id="myChart" height="180px"></canvas>
        <div class="ChartContent">
             <h2>84%</h2>
        </div>
     </div>


//START DOUGHNUT CHART

var balance = document.getElementById('balance').value;
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
    type: 'doughnut',
    data: {
        labels: ['Withdrawal Amount', 'Balance Amount'],
        datasets: [{
            data: [80, 124, balance],
            backgroundColor: [
              '#232c66',
              '#ffa5a2',
            ],
            borderColor: [
              '#232c66',
              '#ffa5a2',
            ],
            borderWidth: 2,
            hoverBorderWidth: 1,
            weight: 2,
            clip: 
            {
              left: 5, 
              top: 5, 
              right: -2, 
              bottom: 0
            }
        }]
    },
    options: {
        cutoutPercentage: 180,
        rotation    : 5,
        animation: true,
      legend: {
        position: 'chartArea',
        padding: 1
      },
      layout: {
          padding: 20
      }
    }
});


//END DOUGHNUT CHART

about 4 years ago · Juan Pablo Isaza
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!