project-nv / night-vision

Highly customizable charting library, created for professional traders
https://nightvision.dev
MIT License
237 stars 54 forks source link

fix display of candle remaining time #97

Open mariusvigariu opened 10 months ago

mariusvigariu commented 10 months ago

candle remaining time is kinda broken, see 1w timeframe for an example .. i propose computing the remaining time based on the last close time from the data set and the current timestamp .. if the dataset is not up to date, no remaining time will be shown even if it's set to true in the settings

it also adds some extra timeframes in the mix

netlify[bot] commented 10 months ago

Deploy Preview for shiny-selkie-5e063f ready!

Name Link
Latest commit 80c4568817bf66427bc53f3658bc8787fe9d33c5
Latest deploy log https://app.netlify.com/sites/shiny-selkie-5e063f/deploys/653b84d6aab34f0008420acc
Deploy Preview https://deploy-preview-97--shiny-selkie-5e063f.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

C451 commented 10 months ago

Tbh, I like a solution that doesn't depend on the data. Makes it more robust. Yeah, the 1W & 1M are wrong rn. I'll think about it later (btw, will your algo work if data.length === 0 ?)

mariusvigariu commented 10 months ago

I see what you mean and think about remaining time of a candle only makes sense when it is relative to the current one. And as a user I dont wanna see remaining time of an hourly candle from yesterday if the data is not up to date. I think its bad UX

The function is not even called if data is empty

C451 commented 10 months ago

Ok, let's make indentation consistent (4 spaces) and I'll test this & add.

mariusvigariu commented 10 months ago

Regarding the indentation, I wouldn't say it is consistent. I've seen mixed indentation across the code, three spaces, tabs, etc

I've also seen files with dos and unix format.

I want to bring it up again as I believe it is super important to make this project easier to maintain and improve in the future. Have a look on my eslint branch here

I ran autofix with the recommended settings in the last commit ... clone it then run npx eslint src and see how many issues still require attention, this is just a part of all of them:

image

C451 commented 10 months ago

I agree, it needs to be done at some point. Right now, I'm busy with different tasks. If you'd like, you can fix the indentation everywhere. That would be a good starting point, and I'd appreciate the effort.