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

429
Visualizações
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 Respostas
Responde à pergunta

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