npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

d3-layout-timeline

v1.0.3

Published

A layout for producing band-style timelines

Downloads

107

Readme

d3.layout.timeline

Timelines come in all shapes and sizes. One of the most common and popular is the kind that represents the duration of events as bands and tries to efficiently pack them into discrete lanes (sometimes called a swimlane chart). This layout takes an array of data with start and end points and creates the data necessary to draw the data as bands on a timeline.

d3.layout.timeline

npm install d3-layout-timeline

Simple example using integers for start and end

Example showing padding, maximum band height and fixed extent

Example with dates

Example with dates, categorized to create parallel semantically meaningful timelines

Example with hierarchical data

#timeline(data) Returns an array of objects based on data with drawing instructions.

#timeline.size Sets or gets an array of [width, height] that is used to calculate the location of the timeline bands along with their start position (d.start), y-position (d.y) height (d.dy) and end (d.end). Width can be calculated by subtracting start from end for svg:rect elements.

#timeline.dateFormat Sets or gets the function that returns the values for the start and end of the bands. Defaults to function (d) {return new Date(d)}. The timeline layout can plot floats and ints for relative time (see the simple example that uses integer positions for start and end points).

#timeline.bandStart Sets or gets the function that returns the start of the band. Remember that it will also be passed through #timeline.dateFormat. Defaults to function (d) {return d.start}.

#timeline.bandEnd Sets or gets the function that returns the start of the band. Remember that it will also be passed through #timeline.dateFormat. Defaults to function (d) {return d.end}. If you want to use duration-based notation, you might try something like function (d) {return d.start + d.duration}.

#timeline.extent Sets or gets extent of the timeline. By default, the extent is set to the minimum start and maximum end, but if you have a range you'd rather set the timeline to, you can do so. This is also passed through #timeline.dateFormat.

#timeline.padding Sets or gets the distance in pixels between lanes. Defaults to 0.

#timeline.maxBandHeight Sets or gets the maximum band height. Defaults to Infinity (bands will fill the given height in the #timeline.size array minus any necessary padding).

#timeline.children Sets or gets the children accessor, for use with hierarchical timeline data. Typically children are stored in an array in .children or .values. Set to return null or false to disable hierarchical support. Hierarchical data can be a hierarchical JSON object (like the ubiquitous flare.json dataset) or an array of objects with each having child elements.

If you're looking for a more sophisticated method of visualizing temporal data, you can check out Topotime.