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-arrow

v0.0.25

Published

Attach arrowheads to SVG elements.

Downloads

692

Readme

d3-arrow

Attach arrowheads to SVG elements. This module is in alpha, so use with caution.

Installing

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

<script src="https://unpkg.com/[email protected]/dist/d3-arrow.min.js"></script>
<script>

const arrow = d3.arrow1();

</script>

API Reference

The API is based on the list of arrows in Adobe Illustrator v24.1.2. To add an arrowhead to an SVG element, you must first add the arrowhead generator to your SVG using selection.call. Then, pass the generator's id to the element's "marker-end" attribute:

const svg = d3.select("body").append("svg")
    .attr("width", 60)
    .attr("height", 20);

const arrow = d3.arrow1()
    .id("my-arrow")
    .attr("fill", "steelblue")
    .attr("stroke", "steelblue");

svg.call(arrow);

svg.append("polyline")
    .attr("marker-end", "url(#my-arrow)")
    .attr("points", [[5, 10], [55, 10]])
    .attr("stroke", "steelblue")
    .attr("stroke-width", 2);

# d3.arrow1() · Source, Example

Creates a new arrow generator with an id of "d3-arrow-1" and a scale of 1.

# d3.arrow2() · Source, Example

Creates a new arrow generator with an id of "d3-arrow-2" and a scale of 1.

# d3.arrow3() · Source, Example

Creates a new arrow generator with an id of "d3-arrow-3" and a scale of 1.

# d3.arrow5() · Source, Example

Creates a new arrow generator with an id of "d3-arrow-5" and a scale of 1.

# d3.arrow10() · Source, Example

Creates a new arrow generator with an id of "d3-arrow-10" and a scale of 1.

# d3.arrow11() · Source, Example

Creates a new arrow generator with an id of "d3-arrow-11" and a scale of 1.

# d3.arrow13() · Source, Example

Creates a new arrow generator with an id of "d3-arrow-13" and a scale of 1.

# arrow(context) · Source, Example

Add the arrow generator to the given context, which should be a selection of SVG elements.

# arrow.id([id]) · Source, Example

Sets or gets the arrow's unique id string, which you'll reference when setting the element's "marker-end" attribute.

# arrow.scale([scale]) · Source, Example

Sets or gets the arrow's scale number.

# arrow.attr(key[, value]) · Source, Example

Sets or gets an appearance attribute's value.