Notorious Pug Mafia

    spacetime-ticks

    0.4.0 • Public • Published
    spacetime-ticks

    calculate some sensible break-points between two dates, using the spacetime date library.

    npm i spacetime-ticks

    import spacetimeTicks from 'spacetime-ticks'
    
    let ticks = spacetimeTicks('June 5th 1992', 'Oct 4 2002', 5)
    // [
    // { label: "1993", epoch: 725864400000, value: 0.055 }
    // { label: "1995", epoch: 788936400000, value: 0.248 }
    // { label: "1997", epoch: 852094800000, value: 0.442 }
    // { label: "1999", epoch: 915166800000, value: 0.636 }
    // { label: "2001", epoch: 978325200000, value: 0.829 }
    // ]

    This library has some opinions:

    • ticks should always be spaced evenly, even if this means less ticks
    • a tick should appear at the start of months, years, days
    • they don't need to begin or end at the start andend.
    • less ticks are better than too-many ticks

    it was built for labelling an x-axis in a space-limited way, but you can use it for whatever weird stuff.

    See also:

    MIT

    Keywords

    none

    Install

    npm i spacetime-ticks

    DownloadsWeekly Downloads

    8

    Version

    0.4.0

    License

    MIT

    Unpacked Size

    714 kB

    Total Files

    20

    Last publish

    Collaborators

    • spencermountain