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

431
Vistas
How get price from previous point Lightweight Charts?

I have a chart with tooltip There I display the date and price of the current point.

    var toolTipWidth = 125;
    var width = 600;
    var toolTip = document.createElement('div');
    toolTip.className = 'tooltip';
    chartContainer.appendChild(toolTip);

    chart.subscribeCrosshairMove(function(param) {
      if (!param.time || param.point.x < 0 || param.point.x > width || param.point.y < 0 || param.point.y > height) {
        toolTip.style.display = 'none';
        return;
      }

      let price = param.seriesPrices.get(areaSeries);    
      let date = LightweightCharts.isBusinessDay(param.time) ? businessDayToString(param.time) : new Date(param.time * 1000).toLocaleDateString();

      toolTip.innerHTML = `<div class="tooltip__price">${price}</div><div class="tooltip__time">${date}</div>`;
      let left = param.point.x - toolTipWidth / 2;
      left = Math.max(0, Math.min(width - toolTipWidth, left));

      toolTip.style.left = left + 'px';
  });

On the chart, I need to show the dynamics of growth (how much the amount has changed, whether there has been an increase or decrease, how much it is as a percentage). To do this, I need to get the previous point and compare it with the current one. But only one chart point is passed to the tooltip function. How to get the previous value?

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

0

This is not possible as for v3.7 and upcoming v3.8 versions so you need to store your data somewhere and then use that data to find a previous data point.

In the next major v4.0 update the library will include a new method ISeriesApi.dataByIndex which you could use to get a data for the logical index (see PR with changes).

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