Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

86
Vistas
Hide tooltip when hovering over null-values in chart.js

I am currently using a line-chart with chart.js 3.5.0 and react-chart-js 3.0.4, given two datasets.

The first dataset has data in {x,y}-format with null-values for some y. When hovering over those null-values, the tooltip jumps to the start of the second dataset. In this case, I would like to hide the tooltip, but approaching the problem with callbacks didn't work.

Has anybody experienced the same issue?

Screenshot

codesandbox

const options = {
    interaction: {
        intersect: false
    },
    maintainAspectRatio: true,
    animation: false,
    plugins: {
        tooltip: {
            mode: 'nearest',
            axis: 'x',
            position: 'average',
            yAlign: "bottom"
        },
    },
    scales: {
        y: {
            type: 'linear',
            beginAtZero: true,
            min: 0,
            grace: '20%',
        }
    },
    chartArea: {
        backgroundColor: "rgb(240,240,240)"
    }
}
8 months ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You can use mode: 'x' in your tooltip config. Together with setting pointHitRadius to 0 in both datasets makes it so you dont have duplicate values in your tooltip.

Example: https://codesandbox.io/s/hardcore-brown-1vxcjh?file=/src/components/CChart.jsx

8 months ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos