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

103
Visualizações
Is there any way to show a tooltip for points which are not visible on the chart in Chart.js?

I have a line chart that has a minimum value for the Y-axis. Sometimes the data goes under this minimum value and I don't want to stretch the chart because of this one point, but I want to have the tooltip to show the data when I move my cursor to the value in the X-axis.

I've created a codepen about the problem: codepen

var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
  type: "line",
  data: {
    labels: ["R", "B", "Y", "G", "P", "O"],
    datasets: [
      {
         label: "# of Votes",
         data: [12, 13, 11, 12, 9, 13]
      }
    ]
  },
  options: {
    scales: {
      y: {
        min: 10
      },
    },
    interaction: {
      intersect: false,
      mode: 'nearest',
      axis: 'x',
    },
  }
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can define interaction.mode: 'x' as explained here.

Please take a look at your amended code below and see how it works.

new Chart('myChart', {
  type: "line",
  data: {
    labels: ["R", "B", "Y", "G", "P", "O"],
    datasets: [{
      label: "# of Votes",
      data: [12, 13, 11, 12, 9, 13]
    }]
  },
  options: {
    scales: {
      y: {
        min: 10
      }      
    },
    interaction: {
      intersect: false,
      mode: 'x'
    }
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.min.js"></script>
<canvas id="myChart" height="80"></canvas>

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