Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time scale marks customization #226

Closed
deantheiceman opened this issue Oct 3, 2019 · 22 comments · Fixed by #386
Closed

Time scale marks customization #226

deantheiceman opened this issue Oct 3, 2019 · 22 comments · Fixed by #386
Assignees
Labels
enhancement Feature requests, and general improvements.
Milestone

Comments

@deantheiceman
Copy link

Currently there is no support to customise the time scale with even at least formatting.

I have two problems:

  • My trade data is now showing random intervals of 12:32 and 13:34 rather than just 12:30 and 13:30
  • There doesn't seem to be a way to localise the timescale and convert unix timestamp to local times

Any chance we can get this soon?

@eugene-korobko
Copy link
Contributor

Hello!

I can customize time formatting, plese refer here

@deantheiceman
Copy link
Author

@eugene-korobko this is only for the popup? but how about the timescale axis labels?

Changing the time format of the time scale labels is not available currently but we intend to roll this out in the future.

@timocov
Copy link
Contributor

timocov commented Oct 16, 2019

Yes, currently we don't have support of this customization and there is some reasons (at least that every label should have certain width to look pretty and to don't overlap each other). But we need to provide API to modify it (I don't know how at the moment).

@timocov timocov added enhancement Feature requests, and general improvements. need more feedback Requires more feedback. need proposal Requires a detailed proposal before more further. labels Oct 16, 2019
@timocov
Copy link
Contributor

timocov commented Oct 16, 2019

There doesn't seem to be a way to localise the timescale and convert unix timestamp to local times

@deantheiceman Meantime, can you please provide a bit more information regard what do you want to achieve/trying to fix? I hope it might help us to make correct decision about the fix.

@timocov timocov changed the title Time scale customisation Time scale marks customization Oct 16, 2019
@deantheiceman
Copy link
Author

Sorry for the delay, I was experimenting with alternative options in the mean time but find myself coming back to lightweight charts as the best solution for what I need

Essentially if my server returns data and I send the data to the chart as a Unix timestamp on the client side I want to be able to display the timestamps in the client side time

Previously I used to just do a simple offset and calculation before passing it into the chart. But that doesn't seem to be possible when using unix timestamps to pass through the data

@IvanhoeGrozni

This comment has been minimized.

@timocov

This comment has been minimized.

@IvanhoeGrozni

This comment has been minimized.

@timocov
Copy link
Contributor

timocov commented Mar 17, 2020

lightweight charts as the best solution for what I need

Meantime you can share your feedback and thoughts in #362 if you wish (we do really appreciate every feedback) 🙂

@timocov timocov removed the need more feedback Requires more feedback. label Mar 17, 2020
@timocov
Copy link
Contributor

timocov commented Mar 17, 2020

Another use case why we need to have a way to customize it is seasonality chart (see #377).

@timocov timocov self-assigned this Apr 2, 2020
@timocov timocov removed the need proposal Requires a detailed proposal before more further. label Apr 2, 2020
@timocov timocov added this to the 3.0 milestone Apr 2, 2020
@maxbethke
Copy link

maxbethke commented Dec 9, 2021

Some time has passed since you closed this ticket @timocov, and I still cant see a way to custimize the tickmarks of the time scale to stick to specific points on the scale.

Im my case I want the labels to only apear at full hours, but sometimes they appear on 1 min after the full hour.

grafik

Another problem I have not found a real solution for is to prevent the last label (20:00 in this case) to not be cut off because the scale ends) The only solution I found to that was to use the rightOffset property on the timeScale (https://github.com/tradingview/lightweight-charts/blob/v3.6.1/docs/time-scale.md), but then the whole chart would have that padding. Also Its measured in bars, and bar widths change througt my app, to the offset would be a diffrent size in pixels on tge charts, depending on the data.
What I would want is the time scale labels to overlap this canvas
grafik

I am running v3.6.1, but as far as I can see in the changelog for the latest v3.7.0, this problem was not solved.

@timocov
Copy link
Contributor

timocov commented Dec 9, 2021

Im my case I want the labels to only apear at full hours, but sometimes they appear on 1 min after the full hour.

@maxbethke we didn't provide a feature to change the algorithm of generating tick marks though, because it looks pretty low-level and it is needed for a few users probably. Instead, I'd say that we need to improve our internal algorithm to avoid such situations. I had an idea that we could ignore tick marks lower (in terms of their weight) than the weight of the majority of tick marks. Let's say if you need to display 4 hour labels and 2 sub-hour ones (minutes, seconds) then just drop these 2 sub-hour labels because they won't have any sense in comparison to other labels. Probably you will have other ideas how to improve it. I believe it should be done somewhere here or here.

Another problem I have not found a real solution for is to prevent the last label (20:00 in this case) to not be cut off because the scale ends)

Can you provide an example please? It seems that this issue was fixed in case when you're unable to scroll behind the last/first point, i.e. when fixLeftEdge or fixRightEdge is enabled. Probably we could extend this behaviour on other points as well, but we need to specify a condition for that.

@maxbethke
Copy link

maxbethke commented Dec 9, 2021

Can you provide an example please? It seems that this issue was fixed in case when you're unable to scroll behind the last/first point, i.e. when fixLeftEdge or fixRightEdge is enabled. Probably we could extend this behaviour on other points as well, but we need to specify a condition for that.

Here is a codesandbox that should make both problems clear. As you can see, the 13:00 label gets cut of at the very right end of the time scale @timocov

https://codesandbox.io/s/unruffled-benz-z9f5p

@timocov
Copy link
Contributor

timocov commented Dec 10, 2021

handleScale: false,
handleScroll: false,

Interesting, I didn't think about this case. @maxbethke could create a separate ticket for this please? It is pretty similar to #835, but with the only difference that instead of fixing edges you disallow scrolling and scaling. It seems that we need to do the same logic for case when a scroll is disabled (disabled scaling is fine I believe).

@maxbethke
Copy link

maxbethke commented Dec 20, 2021

Thats for the second problem @timocov, but for my first problem, I recall:
I want the labels to only apear at full hours, but sometimes they appear on 1 min after the full hour.
I cant wrap my head around your approach
I had an idea that we could ignore tick marks lower (in terms of their weight) than the weight of the majority of tick marks. Let's say if you need to display 4 hour labels and 2 sub-hour ones (minutes, seconds) then just drop these 2 sub-hour labels because they won't have any sense in comparison to other labels
right now. Also at the moment, I am just a 'user' of this charting library and do not fiddle with its internals.
At some point in time, I might be able to look into it and help with solving the problem, but for now my takeaway is that you wont provide a solution for it in the near future.
Aforesaid would be perfectly fine to me, I just need to know because my project might need to steer into a diffrent direction then.

@timocov
Copy link
Contributor

timocov commented Jan 4, 2022

I want the labels to only apear at full hours, but sometimes they appear on 1 min after the full hour

@maxbethke could you please create a jsfiddle/codesandbox example of the issue? I'll create a ticket to improve tick marks for this case (at least we can try).

@maxbethke
Copy link

The above mentioned codesandbox should explain the issue. It does not show occasions where the tickmark is displayed exactly 1 min after the full hour, but it shows 3, 4, 9 and 19 mins, which is the exact same problem in my mind.
image
I would like to only see labels at full hours, so in this case at 09:00, 10:00, 11:00, 12:00 and 13:00.

Does that clarify the issue for you @timocov?

@timocov
Copy link
Contributor

timocov commented Jan 17, 2022

I would like to only see labels at full hours, so in this case at 09:00, 10:00, 11:00, 12:00 and 13:00.

@maxbethke So do you want to display 09:00 for data which has 09:04 time? Is there a reason why you might want this instead of correcting the date of your bars? It looks strange for me to be honest and I don't think that the library will do this (display wrong time). I thought that you faced a bug where you have 09:00 and 09:04 bars but the library displays 09:04 instead of 09:00, but now it seems that the library works correctly.

@maxbethke
Copy link

maxbethke commented Jan 18, 2022

So do you want to display 09:00 for data which has 09:04 time?

No!

I thought that you faced a bug where you have 09:00 and 09:04 bars but the library displays 09:04 instead of 09:00

Yes! That is exactly it.
There are bars from 09:00 through 13:00 with a resolution of 1 min, and I want to display tick marks at full hours, where the bar for a full hour is. This is just a tick mark placement/prioritization issue.

The way they get displayed right now pose a UI issue for me and my customer

@timocov
Copy link
Contributor

timocov commented Jan 18, 2022

No!

But on your example above I don't see a bar at 09:00 in the data, instead I see a bar at 09:04 which is displayed on the time scale.

Yes! That is exactly it.

So, can you provide an example of such case, where you provide a bar with time 09:00 but the library displays it as 09:04 please?

@mqklin
Copy link

mqklin commented Nov 5, 2024

hi @timocov ! I have the same request, but another use case:
We show history chart data, and there are two points are important - start point and end point:
image

So we need to show ticks only for these 2 points, so user can understand that this chart is related to some time in the past (like 2020/01/12 - 2023/02/11).

Is it possible to show only 2 exact ticks on the time scale?

@mqklin
Copy link

mqklin commented Nov 5, 2024

In the end we would like to achieve something like this:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests, and general improvements.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants