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-gauge-x

v0.2.1

Published

Gauge visualization built on top of d3.

Downloads

7

Readme

d3-gauge

Gauge visualization built on top of d3.

demo

var d3gauge = require('d3-gauge');

var gauge = d3gauge(document.getElementById('simple-gauge'));
gauge.write(39);

Note: please make sure to include the appropriate css in your page, otherwise all you'll see is a big black circle.

Installation

npm install d3-gauge

Try it

npm explore d3-gauge
npm run demo

API

####gauge (el[, opts])*

Creates a gauge appended to the given DOM element.

@name Gauge @function params:

  • el DOMElement to which the gauge is appended
  • opts Object gauge configuration with the following properties all of which have sensible defaults:
    • label {String} that appears in the top portion of the gauge
    • clazz {String} class to apply to the gauge element in order to support custom styling
    • size {Number} the over all size (radius) of the gauge
    • preserveAspectRatio {String} default 'xMinYMin meet', see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio
    • min {Number} the minimum value that the gauge measures
    • max {Number} the maximum value that the gauge measures
    • majorTicks {Number} the number of major ticks to draw
    • minorTicks {Number} the number of minor ticks to draw in between two major ticks
    • needleWidthRatio {Number} tweaks the gauge's needle width
    • needleConatinerRadiusRatio {Number} tweaks the gauge's needle container circumference
    • transitionDuration {Number} the time in ms it takes for the needle to move to a new position
    • zones {Array[Object]} each with the following properties
      • clazz {String} class to apply to the zone element in order to style its fill
      • from {Number} between 0 and 1 to determine zone's start
      • to {Number} between 0 and 1 to determine zone's end

returns:

Object the gauge with a write method

Note: have a look at the default opts

###gauge.write = function(value, transitionDuration)

Writes a value to the gauge and updates its state, i.e. needle position, accordingly. @name write @function params:

  • value Number the new gauge value, should be in between min and max
  • transitionDuration Number (optional) transition duration, if not supplied the configured duration is used

Styling

d3-gauge can be custom styled and none of the features are visible if no style is included at all.

Please have a look at the styles included here in order to get an idea of what parts you can tweak to your liking.

Kudos

This implementation was highly inspired by this post.

Although lots of work went into cleaning the code up and making the gauge configurable and stylable, the main idea came from there.

License

MIT