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

424
Views
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 answers
Answer question

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