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 🙏

© 2026 – Pkg Stats / Ryan Hefner

d3-shotchart

v0.0.2

Published

d3-shotchart is a plugin for easily visualizing basketball shotchart data in a fun, interactive way

Readme

d3-shotchart

Basketball fans are paying attention to stats and advanced metrics more than ever. There exists few open source tools to help facilitate the display and distribution of the data fans care about. With d3-shotchart, you can easily build a visualization that enables fans to interact with NBA shot data (publicly available elsewhere).

Installing

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

Dependencies

d3-shotchart depends on d3-tip and d3-hexbin Be sure to include these dependencies above d3-shotchart in your code.

Data Requirements

Minimum requirements

The bare minimum data requirements for the plugin to display data are:

  1. x coordinate with a value betweeon 0-50
  2. y coordinate with a value between 0-47

Example format:

[ 
  {
    "x": 19.5,
    "y": 28.45
  }
]

Tooltip requirements

To take full advantage of the tooltip functionality, your data should include a few other publicly available data points:

  • "Action Type"
  • "Shot Distance"

Example format:

[ 
  {
    "x": 19.5,
    "y": 28.45,
    "action_type": "Jump Shot",
    "shot_distance": 24,
  }
]

Demo

Here is an interactive visualization of Philadelphia 76ers data that takes advantage of most of d3-shotchart's configuration options.

Example usage

<div id="shot-chart"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.4.0/d3.min.js"></script> 
<script src="https://d3js.org/d3-hexbin.v0.2.min.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3-tip/0.7.1/d3-tip.min.js"></script>
<script src="d3-shotchart.js" ></script>
<script src="shots.js" ></script>

<script> 
    var courtSelection = d3.select("#shot-chart");
    var court = d3.court().width(600);
    var shots = d3.shots().shotRenderThreshold(1).displayToolTips(true).displayType("hexbin");
    courtSelection.call(court);
    courtSelection.datum(data).call(shots);
</script>

API Reference

# court()

Constructs a new default court generator.

# court.width([width])

If width is specified, sets the courth width to the specified number and returns the court generator. If width is not specified, returns the current court width accessor, which defaults to:

function width() {
  return 500;
}

Court height is always automatically generated as a function of court width. Default NBA half-court dimensions are 50 x 47 feet. As such, the height of the court is always equal to .94 * court width.

# shots()

Constructs a new default shots generator.

# shots.displayType([displayType])

displayType can only be one of two values:

  1. "scatter"
  2. "hexbin"

If displayType is specified, sets shot display type to the specified value and returns the shots generator. If displayType is not specified, returns the current shot displayType accessor, which defaults to:

function displayType() {
  return "scatter";
}

# shots.shotRenderThreshold([shotRenderThreshold])

shotRenderThreshold can be any integer greater than 0

If shotRenderThreshold is specified, sets the minimum number of shots required for a hexbin to display and returns the shots generator. If displayType is not specified, returns the current shot displayType accessor, which defaults to:

function shotRenderThreshold() {
  return 1;
}

# shots.displayToolTips([displayToolTips])

displayToolTips can only be set to true or false

If displayToolTips is specified, sets the tool tip display to the specified value and returns the shots generator. If displayToolTips is not specified, returns the current shot displayToolTips accessor, which defaults to:

function shotRenderThreshold() {
  return false;
}