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-bumps-chart

v1.1.1

Published

Draw bumps charts

Downloads

44

Readme

d3-bumps-chart

Build Status

Draw Bumps charts using d3.

See a demo here.

Installing

If you use NPM, npm install d3-bumps-chart. Otherwise, download the latest release. AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3 global is exported:

<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="../build/d3-bumps-chart.js"></script>

<script>
  d3.json("./results.json").then(function (events) {
    var gender = d3.GENDER.WOMEN;
    var set = d3.SET.TORPIDS;
    var el = document.getElementById('bumps-chart');

    var chart = d3.bumpsChart();

    chart
      .year({ start: 2014, end: 2017 })
      .windowWidth(window.document.body.clientWidth)
      .on("selectYear", (start, end) => console.log(start + '-' + end))
      .on("highlightCrew", crew => console.log(crew))
      .on("toggleSelectedCrew", crew => console.log(crew));

    var transformedEvents = events
      .filter(e => e.gender.toLowerCase() === gender.toLowerCase())
      .filter(e => e.set === set)
      .sort((a, b) => a.year - b.year)
      .map(event => d3.transformData(event));

    var data = d3.joinEvents(transformedEvents, set, gender);

    d3.select(el).datum(data).call(chart);
  });
</script>

API Reference

# d3.bumpsChart() <>

Constructs a new bumps chart generator with the default settings.

# bumpsChart(selection) <>

Render the bumps chart to the given selection.

# bumpsChart.on(typenames, [listener]) <>

If listener is specified, sets the event listener for the specified typenames and returns the bumps chart. If an event listener was already registered for the same type and name, the existing listener is removed before the new listener is added. If listener is null, removes the current event listeners for the specified typenames, if any. If listener is not specified, returns the first currently-assigned listener matching the specified typenames, if any. When a specified event is dispatched, each listener will be invoked with the same context and arguments as selection.on listeners: the current datum d and index i, with the this context as the current DOM element.

The typenames is a string containing one or more typename separated by whitespace. Each typename is a type, optionally followed by a period (.) and a name, such as drag.foo and drag.bar; the name allows multiple listeners to be registered for the same type. The type must be one of the following:

  • selectYear - after the year range has changed.
  • toggleSelectedCrew - after a crew's selected status has been toggled.
  • highlightCrew - after the highlighted crew has changed.

See dispatch.on for more.