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-gtimeline

v1.0.1

Published

Google-like timeline chart

Downloads

20

Readme

d3-gtimeline

Google-like timeline chart. Demo.

Installing

If you use NPM, npm install d3-gtimeline. Otherwise, download the latest release.

API Reference

# d3.timeline() <>

Creates a function to generate charts on the selection. Use the standard D3 selection.call with datum.

Example below shows how to create the simple chart similar to the one from Google timeline chart manual:

const chart = d3.timeline(),
  data = [
    ["Washington", "", new Date(1789, 3, 30), new Date(1797, 2, 4)],
    ["Adams", "", new Date(1797, 2, 4), new Date(1801, 2, 4)],
    ["Jefferson", "", new Date(1801, 2, 4), new Date(1809, 2, 4)],
  ];

d3.select("div").datum(data).call(chart);

More advanced example (as well based on the data from Google timeline chart manual)

const chart = d3.timeline(),
  data = [
    ["President", "George Washington", new Date(1789, 3, 30), new Date(1797, 2, 4)],
    ["President", "John Adams", new Date(1797, 2, 4), new Date(1801, 2, 4)],
    ["President", "Thomas Jefferson", new Date(1801, 2, 4), new Date(1809, 2, 4)],
    ["Vice President", "John Adams", new Date(1789, 3, 21), new Date(1797, 2, 4)],
    ["Vice President", "Thomas Jefferson", new Date(1797, 2, 4), new Date(1801, 2, 4)],
    ["Vice President", "Aaron Burr", new Date(1801, 2, 4), new Date(1805, 2, 4)],
    ["Vice President", "George Clinton", new Date(1805, 2, 4), new Date(1812, 3, 20)],
    ["Secretary of State", "John Jay", new Date(1789, 8, 25), new Date(1790, 2, 22)],
    ["Secretary of State", "Thomas Jefferson", new Date(1790, 2, 22), new Date(1793, 11, 31)],
    ["Secretary of State", "Edmund Randolph", new Date(1794, 0, 2), new Date(1795, 7, 20)],
    ["Secretary of State", "Timothy Pickering", new Date(1795, 7, 20), new Date(1800, 4, 12)],
    ["Secretary of State", "Charles Lee", new Date(1800, 4, 13), new Date(1800, 5, 5)],
    ["Secretary of State", "John Marshall", new Date(1800, 5, 13), new Date(1801, 2, 4)],
    ["Secretary of State", "Levi Lincoln", new Date(1801, 2, 5), new Date(1801, 4, 1)],
    ["Secretary of State", "James Madison", new Date(1801, 4, 2), new Date(1809, 2, 3)],
  ];

d3.select("div").datum(data).call(chart);

# timeline.width([value]) <>

Returns or sets explicit width of the chart. If this value is null, width of the chart is adapted to the width of the parent node.

# timeline.padding([value]) <>

Returns or sets padding value for elements in the timeline.

# timeline.today([value]) <>

Returns or sets a boolean value to show/hide the today line on the timescale. Default: false.

# timeline.duration([value]) <>

Returns or sets the duration of the horizontal animation. Default: 0.

# timeline.colors([array]) <>

Returns or sets array containing colors to be used. Default colorset contains Google colors.

# timeline.reversed([boolean]) <>

If true flips the chart and shows the labels on the right side. Default value is false i.e. left side labels.