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

patternfly-timeline

v1.0.7

Published

A time based / event series interactive visualization using d3.js. Use drag and zoom to navigate in time.

Downloads

23

Readme

patternfly-timeline

A time based/event series interactive visualization using d3.js. Use drag and zoom to navigate in time. View the demo here.

Based on the EventDrops timeline.

Usage

Include the src/timeline.js script in your page after d3:

<script src="path/to/d3.js"></script>
<script src="src/timeline.js"></script>

In the HTML source, create a new timeline chart, bind data to a DOM element, then call the chart on the element. Important: In order for the zoom slider to work correctly, the placeholder element must have position: relative or position: absolute styling.

var timelineChart = d3.chart.timeline();
d3.select('#chart_placeholder')
  .datum(data)
  .call(timelineChart);

The data must be an array of named time series with an optional details payload. For instance:

var json = [
  {
    "name":"Power Activity",
    "data":[
      {"date": "2016-04-08T15:07:37.374Z", "details": {"event": "vmPowerOn", "object": "vmName"}},
      {"date": "2016-04-08T15:07:37.374Z", "details": {"event": "vmPowerOn", "object": "vmName"}},
      {"date": "2016-04-15T21:04:16.247Z", "details": {"event": "vmPowerOn", "object": "vmName"}}
    ]
  },
  {
    "name":"Alarm/Error",
    "data":[
      {"date": "2016-04-21T01:06:19.126Z", "details": {"event": "vmPowerOn", "object": "vmName"}},
      {"date": "2016-04-16T13:07:15.205Z", "details": {"event": "vmPowerOff", "object": "hostName"}},
      {"date": "2016-04-07T22:35:41.145Z", "details": {"event": "vmPowerOff", "object": "hostName"}}
    ]
  }
];

Configuration

Patternfly-timeline follows the d3.js reusable charts pattern to let you customize the chart at will:

var timelineChart = d3.chart.timeline()
  .width(1200)
  .context(false)

Configurable values:

  • start: start date of the scale. Defaults to new Date(0).
  • end: end date of the scale. Defaults to new Date()
  • minScale: The minimum scaling (zoom out), default to 0.
  • maxScale: The maximum scaling (zoom in), default to Infinity.
  • width: width of the chart in pixels. Responsive by default.
  • padding: paddings of the graph in pixels. Defaults to { top: 30, left: 40, bottom: 40, right: 40 }
  • lineHeight: The height of each row in the chart, default to 40.
  • contextHeight: The height of the context viewport below the char, default to 50.
  • locale: locale used for the X axis labels. See d3.locale for the expected format. Defaults to null (i.e. d3 default locale).
  • axisFormat: function receiving the d3 axis object, to customize tick number and size.
  • tickFormat: tickFormat for the X axis. See d3.timeFormat.multi() for expected format.
  • eventHover: function to be called when hovering an event in the chart. Receives the DOM element hovered (uses event delegation).
  • eventZoom: function to be called when done zooming on the chart. Receives the d3 scale at the end of the zoom.
  • eventClick: function to be called on click event of data-point (circle). Receives the DOM element hovered (uses event delegation).
  • eventLineColor: The color of the event line. Accepts a color (color name or #ffffff notation), or a function receiving the eventData and returning a color.
  • eventColor: The color of the event. Accepts a color (color name or #ffffff notation), or a function receiving the eventData and returning a color. Defaults to null. EventLineColor will be ignored if this is used.
  • eventShape: The shape of the event. Accepts unicode characters, including icon fonts.
  • eventPopover: The contents of the event's popover.
  • marker: true by default. Enable current time/date marker under mouse pointer.
  • context: true by default. Enable context viewport beneath chart.
  • slider: true by default. Enable zoom slider and buttons to right of chart.
  • eventGrouping: 60000(one minute) by default. The number of milliseconds within which events will be considered to have happened at the same time.

Styling

You can style all elements of the chart in CSS. Check the source to see the available selectors.

Extending / Development

First, install the dependencies:

npm install

For development purpose, you can use the following command:

npm start

It serves the demo at http://localhost:8080.

When your changes are done, ensure that all tests pass with:

npm test

Finally, if everything is fine, you can rebuild the library using:

npm run build

License

Patternfly Timeline is released under the MIT License