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

Relative time on X-axis #9

Open
MaciejMalczyk opened this issue Oct 24, 2020 · 5 comments
Open

Relative time on X-axis #9

MaciejMalczyk opened this issue Oct 24, 2020 · 5 comments

Comments

@MaciejMalczyk
Copy link

I have an problem with time on axis x. When i set up baseTime to 0 and use performance.now() to generate x values time on chart starts not from 00:00, but from 01:00.
Is there any easy solution for this problem?

@huww98
Copy link
Owner

huww98 commented Oct 25, 2020

That’s because your client time zone setting is +1:00. baseTime value 0 means UTC time 1970-1-1 0:00. This behavior is from d3-scale.

I haven’t investigated how to show relative time on X-axis. But it shouldn’t be hard.

@huww98 huww98 changed the title Time signature inconsistency. Relative time on X-axis Oct 25, 2020
huww98 added a commit that referenced this issue Oct 25, 2020
@huww98
Copy link
Owner

huww98 commented Oct 25, 2020

@wujekbrezniew This is not as easy as I think. d3-scale seems not providing a scale type for time spans. Maybe I need to roll my own.

I have added a new option xScaleType in v0.5.0. Setting it to d3.scaleUtc should make X-axis start from 00:00. But since values are still interpreted as date, you may see something strange, e.g. first tick shows 1970. You may also try d3.scaleLinear, which displays just plain numbers.

@MaciejMalczyk
Copy link
Author

I tested both scaleUtc and scaleLinear. With scaleUtc time on chart starts on 12:00 but scaleLinear is sufficient for my usecase. Thank you for help.

@citron
Copy link

citron commented Apr 27, 2022

Same problem here. My data consist of 6 hours long ECGs and I need to display the time since the beginning of the recording.
Without scaleUTC, it starts at 1AM. With scaleUTC, it brings me back in the 70's :)
How could I change the x-labelling so that it displays relative HH:MM:SS and not absolute times ?
Capture d’écran 2022-04-27 161639
Thanks for this very good js library !

@huww98
Copy link
Owner

huww98 commented Apr 27, 2022

@citron The axis is rendered by D3. So anything accepted by d3-axis should work. Theoretically, you can write your own scaleRelativeTime or similar, then pass it to TimeChart. I just don't get the time to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants