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

@redsift/d3-rs-svg

v0.8.0

Published

Creates a SVG element using D3v4.

Downloads

3,392

Readme

d3-rs-svg

d3-rs-svg is a component for creating a SVG 1.1 root element that is compatable with the D3 margin convention. This component is dependent on D3 v4 (Alpha).

Builds

Circle CI

UMD from //static.redsift.io/reusable/d3-rs-svg/latest/d3-rs-svg.umd-es2015.min.js

Usage

Browser

<script src="//static.redsift.io/reusable/d3-rs-svg/latest/d3-rs-svg.umd-es2015.min.js"></script>
<script>
	var svg = d3_rs_svg.html();
	...
</script>

ES6

import * as svg from "@redsift/d3-rs-svg";
let eml = svg.html();
...

If using rollup.js for a browser target, ensure d3-rs-svg is part of the global map.

Require

var svg = require("@redsift/d3-rs-svg");
var eml = svg.html();
...

By convention, the SVG element is meant to be hosted in a HTML node, hence svg.html()

Parameters

Name|Description|Transition ----|-----------|---------- width,height|SVG viewport size, px|Y scale|SVG scaling factor, floating point|Y margin|margin convention, Object or integer px|Y classed|SVG custom class|N style|SVG CSS embed|N background|Rect background color|Y title||N role|https://www.w3.org/TR/wai-aria/roles#img|N

Parameters that support transition can be animated and chained.

d3.select('#elm')
	.call(svg)					// draw the SVG at default (1x) scale
.transition().duration(1000)
	.call(svg.scale(2.0))		// scale the SVG by 2x
.transition().duration(333)
	.call(svg.scale(1.0))		// bounce back after 333ms

Note, this form of chaining does not work for parameters that do not support transition. Use the on('end', ... event for them.

var el = d3.select('#elm')
	.call(svg.style('rect{fill: yellow;}'));

el.select(svg.self()).select(svg.child())
  	.append('rect')				// add a rect to the SVG we can paint with CSS
    	.attr('width', svg.childWidth())
    	.attr('height', svg.childHeight());

el.transition().delay(1000).duration(0).on('end', function() {
	 el.transition().duration(1000).delay(500)
      	.call(svg.scale(2.0).style('rect{fill: green;}'));	// this green is applied after 1s of delay but 500ms before the scale changes
});

Accessible features

This module implements some of the features described here.