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

152
Visualizações
Canvas not showing even though the code is there

I am trying to show a Gauge on my Magic Mirror Dashboard in my module programmatically.

The below is a sample of my code:

    var indoorGauge = document.createElement('canvas');
    indoorGauge.id = 'indoorGauge';
    ...
    indoorGauge.setAttribute('data-animation-target','plate');  
    indoorPressure.appendChild(indoorGauge);        
    insideTele.appendChild(indoorPressure);
    wrapper.appendChild(insideTele);

The gauge doesn't show or render. What I'm finding odd is that when I inspect element, the canvas is all there and it works, because when I cut out the element and re-paste it, it will show up and work perfectly!

enter image description here

If I 'cut' and 'paste' the above canvas element, the gauge will show just fine.

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

According to the documentation, you should be using their API if you want to load a gauge with Javascript.

const indoorGauge = document.createElement('canvas');

indoorGauge.id = "indoorGauge"
document.body.appendChild(indoorGauge);

new LinearGauge({
  renderTo: 'indoorGauge'
}).draw();
<script src="https://unpkg.com/canvas-gauges@2.1.7/gauge.min.js"></script>

I would imagine that because you are appending the canvas with Javascript, but not using the gauge API that's why you're seeing issues with the script not picking up your dynamically created canvas element the first time you add it

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