Coder Social home page Coder Social logo

Relative time on X-axis about timechart HOT 5 OPEN

huww98 avatar huww98 commented on May 22, 2024
Relative time on X-axis

from timechart.

Comments (5)

huww98 avatar huww98 commented on May 22, 2024

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.

from timechart.

huww98 avatar huww98 commented on May 22, 2024

@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.

from timechart.

wujekbrezniew avatar wujekbrezniew commented on May 22, 2024

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.

from timechart.

citron avatar citron commented on May 22, 2024

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 !

from timechart.

huww98 avatar huww98 commented on May 22, 2024

@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.

from timechart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.