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

svg-dial

v1.0.8

Published

A customizable, responsive SVG dial UI element

Downloads

22

Readme

svg-dial

A customizable, responsive SVG dial UI element.

https://pbs.twimg.com/media/CFaBu2CUIAAQqJP.png

Introduction

After becoming frustrated with the lack of flexibility and support of jQuery-knob, I decided to create my own SVG dial that allowed me to customize the look and feel of the dial.

Though this element is designed to be highly customizable, it doesn't deviate from the design structure of the notch in the bottom section, the dial, etc. However, colors, font styles, sizes, and some other items are all customizable.

This may fit your needs and asthetics, it may not.

Installation

This package is available for installation via npm and bower

$ npm install svg-dial
$ bower install svg-dial

Usage

The only dependency this library has is on Snap.svg. It assumes this library is available to the module, and is configured to look for it in the AMD, CommonJS (Browserify) and global environments.

CommonJS (Browserify)

var SVGDial = require('svg-dial');

new SVGDial(document.getElementById('dial-container'), {
  onChange: function(percentage) {}
});

AMD

define(['svg-dial'], function(SVGDial) {
  new SVGDial(document.getElementById('dial-container'), {
    onChange: function(percentage) {}
  });
});

Global

...
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.3.0/snap.svg-min.js"></script>
<script type="text/javascript">
  new SVGDial(document.getElementById('dial-container'), {
    onChange: function(percentage) {}
  });
</script>
...

API

Constructor

new SVGDial(el, options);
el

Required: true
Type: HTMLElement, jQuery, String
Description: Can either be a DOM element, a jQuery object or a selector string.
Purpose: Identifies the target block element that the <svg> element will be build inside of.

options

Required: false
Type: Object
Description: The configuration options
Purpose: Defines default overrides and configuration options for the dial.

Configuration Options

Appearance/Functionality

disabled

Default: false
Type: Boolean
Purpose: If set to true, disables the manipulation of the dial.

frameBackgroundColor

Default: 'white'
Type: String
Description: Valid Hex or CSS color, or array of valid Hex or CSS colors to create a linear gradient
Purpose: Specifies the color of the frame (the rectangular container the dial is nested in)

frameSize

Default: 200
Type: Integer
Description: Number of pixels for both the width and height of the frame.
Purpose: Defines the size of the frame that the circular dial will be embedded in

ringBackgroundColor

Default: #888
Type: String, Array
Description: Valid Hex or CSS color, or array of valid Hex or CSS colors to create a linear gradient
Purpose: Specifies the color of the dial ring

innerBackgroundColor

Default: white
Type: String, Array
Description: Valid Hex or CSS color, or array of valid Hex or CSS colors to create a linear gradient
Purpose: Specifies the color of the inner circle and knob

fontFamily

Default: impact
Type: String
Description: Valid and available font family
Purpose: Uses this font family for the inner text that displays the percentage

fontSize

Default: 24
Type: Integer
Purpose: Uses this font size for the inner text that displays the percentage

fontStyle

Default: none
Type: String
Description: Valid and available font style
Purpose: Uses this font style for the inner text that displays the percentage

fontWeight

Default: none
Type: String
Description: Valid and available font weight
Purpose: Uses this font weight for the inner text that displays the percentage

Methods

onChange

Type: Function
Event: Any change in the dial setting during a drag.
Arguments:

  • percentage: percentage between 0 and 1 that the dial is currently set at.
onStart

Type: Function
Event: The mouse down event on the dial
Arguments:

  • percentage: percentage between 0 and 1 that the dial is currently set at.
onChange

Type: Function
Event: The mouse up event on the dial
Arguments:

  • percentage: percentage between 0 and 1 that the dial is currently set at.
onReady

Type: Function
Event: The dial is loaded into the DOM
Arguments: none

Public API

config()

Type: Object
Description: Same structure as the options object.
Purpose: Overrides initial settings during runtime.

setValue()

Type: Integer
Description: Number between 0 and 1.
Purpose: Sets the value and position of the dial.

Contributing