Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
Obtener y punto de x puntos dados hightcharts

Me gustaría obtener el punto y de un punto x dado. El punto x no será necesariamente un punto en el gráfico, puede estar entre dos puntos. el punto x es un valor constante, por lo que no se hace clic ni se selecciona

ingrese la descripción de la imagen aquí

En mi caso, los puntos dados para dibujar el gráfico son los rojos, pero me gustaría obtener uno verde sabiendo el valor de x

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede recorrer los puntos e intentar encontrar uno buscando el valor x . Si no se encuentra el punto, calcule el valor de y en función del siguiente y del anterior. El siguiente algoritmo debería funcionar bien para series de line :

 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);

Demostración en vivo: http://jsfiddle.net/BlackLabel/uavrmLhk/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!