TimeChart
TimeChart copied to clipboard
Relative time on X-axis
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?
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.
@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.
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.
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 ?
Thanks for this very good js library !
@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.