Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
Get y point from x given point hightcharts

I would like to get y point from a given x point. x point will not necesary be a point in chart, it can be between two points. x point is a constant value, so is not clicked or seleted

enter image description here

In my case the given points for draw the graph are the red ones , but i would like to get green one knowing x value

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can loop through points and try to find the one by searching x value. If the point is not found, calculate y value based on the next and the previous ones. The below algorithm should work fine for line series:

const x = 3;

const chart = Highcharts.chart('container', {...});

const points = chart.series[0].points;
let prevX, nextX;
let prevY, nextY;
let y;

points.forEach((point, index) => {
  if (point.x === x) {
    y = point.y;
  }

  if (point.x > x && !prevX) {
    nextX = point.x;
    prevX = points[index - 1].x;

    nextY = point.y;
    prevY = points[index - 1].y;
  }
});

if (!y) {
  const xDiff = nextX - prevX;
  const yDiff = nextY - prevY;

  const unit = yDiff / xDiff;

  y = (x - prevX) * unit + prevY;
}

console.log(y);

Live demo: http://jsfiddle.net/BlackLabel/uavrmLhk/

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda