Coder Social home page Coder Social logo

Comments (2)

SlicedSilver avatar SlicedSilver commented on August 15, 2024 1

Thank you for the JSFiddle example which clearly shows the issue.
I'm adding the 'needs investigation' label because we will need to discuss internally whether a change to this behaviour should be the default and expected behaviour going forward, or whether we should put the new behaviour behind an option.

I can see a benefit to both approaches. Additionally, the fact that the behaviour is different for the past (left) direction compared to the future direction is unexpected.

from lightweight-charts.

drgarlic avatar drgarlic commented on August 15, 2024

One solution to this is to have all of the area that you want scrollable as whitespace data and the very last data a line data with a NaN value.

Like so:

const whitespaceStartDate = "1970-01-01";
const whitespaceEndDate = "2100-01-01";
const whitespaceDateDataset: ((WhitespaceData | SingleValueData) & Numbered)[] =
  new Array(
    getNumberOfDaysBetweenTwoDates(
      new Date(whitespaceStartDate),
      new Date(whitespaceEndDate),
    ),
  );
// Hack to be able to scroll freely
// Setting them all to NaN is much slower
for (let i = 0; i < whitespaceDateDataset.length; i++) {
  const date = new Date(whitespaceStartDate);
  date.setUTCDate(date.getUTCDay() + i);

  const number = date.valueOf() / ONE_DAY_IN_MS;
  const time = dateToString(date);

  if (i === whitespaceDateDataset.length - 1) {
    whitespaceDateDataset[i] = {
      number,
      time,
      value: NaN,
    };
  } else {
    whitespaceDateDataset[i] = {
      number,
      time,
    };
  }
}

from lightweight-charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.