question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chart bugged when using equal date values

See original GitHub issue

Lightweight Charts Version: standalone.production

Steps/code to reproduce:

fetch("/api/tradehistory")
  .then(function(response) {
    return response.json();
  })
  .then(function(data,response) {    
    console.log("Data loaded ")
    lineSeries.setData(data.map(line => {
    	return { time: line.time, value: line.price };
    }));
  })

This happens since I’m assigning equal time values with different price values

Sample data being fed through tradehistory endpoint { "maker_order": "98ab5a24-d113-495c-9d8d-fc2cafb4551a", "pair": "ETHUSD", "price": 110, "quantity": 1, "taker_order": "7d718a29-b1d5-4a61-a11e-0849f3047c6e", "time": 1595258908, "trade_id": "d9e14353-7d37-4906-b2ee-97e2beb60fbe" }, { "maker_order": "e0790be7-4688-4710-974d-d64df1a478da", "pair": "ETHUSD", "price": 100, "quantity": 1, "taker_order": "7d718a29-b1d5-4a61-a11e-0849f3047c6e", "time": 1595258908, "trade_id": "ded10223-bd48-477e-a299-b52b832c698a" }

Actual behavior:

Chart upon loading has very strange lines

Example below:

image image

Right now it shows the chart like this: image

But after ~500ms of loading it turns into how it should show image

Expected behavior:

As seen above, if the same date value has 2 difference prices it should show an horizontal line for that time

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
timocovcommented, Jul 21, 2020

I guess it’s related to some overlapping internally. When you set data for series, we prepare it internally (you can see in https://github.com/tradingview/lightweight-charts/blob/master/src/api/data-layer.ts), there is a map of data item by time point. I think that there is some overlapping with is fixed somehow after the next setting data. When you set data, we try to do less and generate “inremental” update whenever it’s possible, so I guess that something is cached from the previous setting a data and is used in the next one. Anyway, every data item must have unique time points and all items must be ordered in asc order.

1reaction
timocovcommented, Jul 20, 2020

Your bin has been blocked. Please contact us at https://jsonbin.io/contact to unblock.

🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

Horizontal date axis incorrect on Excel line chart with ...
No, a line chart treats dates as dates. However, if the dates are not correctly specified as the X values for a series,...
Read more >
Why are my dates not populating the chart correctly?
On the Design tab of the ribbon (under Chart Tools), click Select Data. Click on Edit under Horiontal (Category) Axis Labels.
Read more >
Date Comparison Not Working - Amplitude Community
Now I'm noticing that if I look at each user individually with the user search, all of these new fields appear with the...
Read more >
chart problem (dates are all messed up) please help! - Mr. Excel
I'm helping my brother with a presentation for school. The problem is when I enter the dates in the form they are ok...
Read more >
Javascript comparing dates - bug in d3.js chart - Stack Overflow
The problem seems to be that chart.call(yAxis).selectAll(".tick") has one less result than your arrayofDates , then there won't be a match in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found