Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

229
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda