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

chord-illustrator

v2.1.4

Published

SVG-based library, which illustrates finger positions of a guitar chord on a fretboard.

Downloads

47

Readme

chord-illustrator NPM version

SVG-based library, which illustrates finger positions of a guitar chord on a fretboard.

  • Blazingly fast and blazingly small 🚀
  • No dependencies
  • Works on browser & Node.js
  • Minified: 2.4 kB
  • Minified + gzipped: 1 kB

Installation

$ npm install --save chord-illustrator

Usage in browser

illustrates B minor

import ChordIllustrator from 'chord-illustrator';

// insert it into any HTML element
ChordIllustrator.setContainer(document.body);

// or get output directly
const svg = ChordIllustrator.make({
  name: 'Bm',
  mutedStrings: ['yes'],
  fingering: [
    { fret: 2, barre: { from: 1, to: 5 } },
    { fret: 3, string: 2, finger: 2 },
    { fret: 4, string: 3, finger: 4 },
    { fret: 4, string: 4, finger: 3 },
  ],
});
console.log('HTML output', svg);

looks like this

sometext

the fretboard will expand automatically based on chord length

Usage in Node.js

The library is tightly coupled with window.document. To use it on Node.js, you may want to import something like jsdom.

import { JSDOM } from 'jsdom';
import ChordIllustrator from 'chord-illustrator';

// create some html
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);

// set missing dom
ChordIllustrator.setDocument(dom.window.document);

const svg = ChordIllustrator.make({
  name: 'C',
  mutedStrings: ['yes'],
  fingering: [
    { fret: 1, string: 2, finger: 1 },
    { fret: 2, string: 4, finger: 2 },
    { fret: 3, string: 5, finger: 3 },
  ],
});
console.log('HTML output', svg);

API docs

.setContainer(container: HTMLElement)

  • set the container where the output renders.

.setDocument(document: DOM)

  • override the default window.document with your own.

.setHeight(height: number)

  • specify the SVG height. The width will adjust automatically.

.make({ name: string, fingering: array, mutedStrings: array, fretboardRange: object, labels: object })

  • specify the chord options by passing an object. Only fingering property is mandatory, and others are optional.
@param(name: string)

The title is displayed at the top. Omit the property to hide.

name: 'Am';
@param(fingering: array)

Mandatory property detailing the chord fingering:

fingering: [
  { fret: 2, barre: { from: 1, to: 5 } },
  { fret: 3, string: 2, finger: 2 },
];
@param(mutedStrings: array)

An array of 6 items filled with ”yes/no/open”. If not specified, values will default to “no”.

mutedStrings: ['yes', 'no', 'no', 'no', 'no', 'open'];
@param(fretboardRange: object)

The fretboard will expand automatically based on chord length. You may override the generated fretboard like this:

fretboardRange: { from: 1, to: 12 }
@param(labels: object)

The fret number label is shown at the bottom left. You can hide this label or customize the prefix:

labels: {
  title: { style: { show: false, fill: 'blue', opacity: 1 } },
  fretNumber: { style: { show: false, fill: 'red', opacity: 1 } },
}

You can customize the whole SVG fretboard using this object.

fretboard: {
  fret: { style: { stroke: 'red', fill: 'red' } },
  string: { style: { stroke: 'green', fill: 'green' } },
  neck: { style: { stroke: 'blue', fill: 'blue' } },
  barre: { style: { stroke: 'gray', fill: 'gray' } },
  finger: { style: { stroke: 'yellow', fill: 'yellow' } },
  fingerText: { style: { stroke: 'orange', fill: 'orange' } },
}
@param(vertical: boolean)

Display the chord vertically.

vertical: true,

Support

Tested on Chrome & Node.js v17.6.0

License

MIT © Alexandru Calin

inspired by guitar-js (Fomin Sergey)