Chord charts
Chord charts show where to place your fingers on the fretboard to play a given chord. Chordography enables you to quickly create and download chord charts for any fretted instrument in any tuning. Or, you can download the JavaScript source-code to generate graphics directly in your own web pages.
Chart Layout
Charts have a conventional layout. Strings are drawn vertically, nut at the top, to distinguish chord charts from tablature.
- horizontal lines represent frets
- o in the header indicates an open string
- x indicates a mute, unfretted string
- dots show finger positons; optional labels suggest fingering
- the first fingered fret is numbered when the nut is not shown
- an optional footer shows the note sounded by each string
Chart Data
To create a new chart, first make changes to the four input fields: Title, Frets, Labels and Footer. Then click Update to generate the corresponding graphic and SVG attributes, and Save to download the current image.
Frets is a comma separated list of fingered fret numbers, one entry per string. Enter 0 or space for an open string, 1 for fret 1 and so on. Anything else such as x or null implies a mute string.
Labels appear inside the dots to indicate the preferred fingering. Labels for un-fretted strings are not accessed, but must be present e.g. as x, space or null
Footer is usually employed to show the note name or chord function for each string.
Null entries for Title and Footer means that these elements take up no space in the chart.
Alternative Controls
Holding down the Alt key whilst activating a button control triggers an alternative function:
Alt + Update opens up the Core Properties Editor (see
below)
Alt + Save copies the graphic script to the clipboard
Tip: Take care when beautifying your image code. While this makes the code much easier to follow, added spaces or new lines can throw text elements off-centre. Use ugly code, as is, to display the graphic
Security Issues
SVG graphics have restricted access because SVG is more than just an image format. It is a complete XML document format that can include embedded scripts, such as SVG, CSS and importantly JavaScript.
Innocent looking images can contain embedded malware that executes as soon as it loads. Chordography images are a potential concern because they are rendered as inline markup. Nevertheless they should not fall foul of security restrictions as they are locally generated. In practice, this may depend on the O/S, the browser and which version is being used.
At the time of writing, Chrome and Opera are the most reliable Windows browsers,and Copy fails in Firefox
Attributes
width and height of the graphic in screen pixels refers to the scaled image, as displayed.
size in bytes varies with the graphic's content. Typically around 1k byte, the size is minimal even by SVG standards.
width and height attributes, collectively called the viewport, tell the browser how much screen real estate it should allocate to the graphic.
After downloading the image, you can edit these values in the code to scale the image. The preserveAspectRatio attribute, value "xMidYMid meet", ensures the undistorted image is centred in the viewport using padding as necessary. Or you can set an appropriate scale factor in the Core Properties (see below) before downloading.
Tip: If you delete either the width or the height attribute, the browser will scale the viewBox to the other one. If you delete both, the browser will scale the viewBox to the width of the enclosing HTML element. Delete the viewBox attribute and no scaling will occur
Core properties
SVG images are versatile. They can be scaled without loss of quality, and colours, fonts, line and fill styles can all be controlled with CSS. Chordography goes a step further, as you can also modify the graphic's core properties.
To open up the Core Properties Editor, hold down the Alt key and click the Update button.
Property | Value | Description |
---|---|---|
barre | auto | Optional barre control |
barHeight | 9 | Barre mean height (px) |
barGirth | 3 | Barre central thickness (px) |
cellWidth | 20 | Horizontal string spacing (px) |
cellHeight | 20 | Vertical fret spacing (px) |
dotSize | 16 | Diameter of fingered dots (px) |
fontHeight | 14 | Font size (px) |
fontBaseline | 2 | Font vertical position (px) |
minSpan | 4 | Minimum vertical span (frets) |
nutHeight | 4 | Nut thickness (px) |
padding | 7 | Clear space around the chart (px) |
scale | 1 | Scale factor (any positive number) |
style | default | Pre-defined in-line style |
Notes on default core properties
- Pixel values (px) relate to the unscaled image
- A barre may be drawn if two or more fingered stages on the same fret have the same label. If one or more frets qualify, select "auto" to draw all of them, "single" to draw only the uppermost one (played with the index finger), or "none".
- cellHeight and cellWidth affect the overall chart size and aspect ratio. Both should be greater than dotSize
- fontHeight should be less than dotSize.
- fontBaseline is used to position labels precisely in the centre of fingered dots, which may be necessary if different fonts or labels are used.
- Set minSpan to 12 if you prefer to draw the whole fretboard
- The scale factor adjusts the graphic's width and height attributes relative to the full size canvas dimensions defined by viewBox.
- Inline styles make charts self-contained, usable without an external style sheet. Select "none" if you intend to use an external style sheet with your charts. The grey border and drop-shadow are not part of the inline style.
CSS
Chordography makes it easy to target styles, whether using inline styles or an external style sheet, as each major group and element is assigned a class.
group | sub group/element |
---|---|
chart | grid, text |
grid | frets, strings, dots, nut, barre | text | title, header, labels, loFret, footer |
SVG style defaults are stroke: none and fill: black, so in the absence of any CSS, text and shapes will be solid black and grid lines fail to display. The following represents the minimum CSS needed to display a chord chart, equivalent to inline style "plain":
stroke: black;
}
svg .labels {
fill: white;
}
The set of inline style examples available to the Core Properties Editor is defined in chart.data.js: see Roll your own: Downloads below
Roll your own
That's all you need to create and download chord charts in a variety of bespoke styles, shapes and sizes. But there is more. With the source code you can also generate and display your graphics directly.
JavaScript
The source-code comprises a JavaScript module to which you will need a link in your HTML <head> section. The module contains a single factory function chart() that works in two stages. The first stage optionally modifies the graphic's core data (see Core object modifier) and returns an anonymous function. The second stage executes the anonymous function to create the graphic.
The anonymous function is assigned here to addGraphic. Parameter udi (user data input) defines the chart and placeholder locates it on the page. Graphics are added to the placeholder, so existing content may need to be removed, as shown below.
udi = {
title: "C7♭9",
frets: "x,3,2,3,2,3",
labels: "x,2,1,3,1,4",
footer: ",C,E,B♭,D♭,G"
},
placeholder = document.getElementById("placeholder");
while (placeholder.hasChildNodes())
placeholder.removeChild(placeholder.lastChild);
addGraphic(udi, placeholder);
Only the frets element of udi is essential to create a chart; title, labels and footer may be null, or omitted completely
Core object modifier
Source-code module chart() optionally modifies the default core data with parameter com (core object modifier), a subset of core property values. The following example would modify cellHeight, padding, and inline style:
cellHeight: 18,
padding: 5,
style: "pretty"
},
addGraphic = chart(com);
Function addGraphic would then create all subsequent graphics with the modified parameters.
Chordography uses com to allow users to modify core data "on the fly". This will seldom be necessary in other applications, where you may prefer to modify the default core values in the data file (see Downloads, below)
HTML
In addition to a link to the source code, you will need to add a placeholder in your HTML <body> section to contain the graphic:
Downloads
Source code files can be downloaded in the table below. Download links may work as normal navigation links if the files reside on an external server and so are a potential security concern. You should be able to view the file on the linked page, and save its contents using "Save As" once you have seen what you are getting.
Filename | Description |
---|---|
chart.js | Comprises factory function chart(com), used to generate chord charts |
chart.data.js | Examples of inline styles, udi and default core properties used by chart.js |
Thanks again for the hard work. I used a lot of chordography1 in my website to render chord. I use wordpress so in case someone would like to have the wordpress plugin shortcode, you can download them here https://github.com/faniry6/chordchartWP It is already using chordography2.
ReplyDeleteThanks again
I'm very impressed that you shared this useful information with us. Thanks for informative
ReplyDeleteChord Gitar Chord Lagu Rohani Kristen
Glad you find it useful.
DeleteClive
Thank you so much for such a useful program. I have used it to annotate my lyrics for the last year or so. After the security issue at Blogger I realized how much I depend on your program. Could you please tell me how I can download it so that future issues will not deprive me of this program? Thank you so much for your help!! Uwe
ReplyDeleteI'm guessing you are entering data & downloading the images. You don't need to be online to use Chordography, so just leave the page open on your browser and get it to "continue where you left off" on startup. I hope you enjoy the new version of Chordography.
ReplyDeleteDo you publish your work?
Clive
Hi Clive! Thank you for your response and sorry I did not reply sooner. Are you the one that created this great program? Your guess is correct – I download the images. I use the reverse chord generator from Chorderator.com to determine the name of my chords, then create the chord images with Chordography, and finally put it all together on my song sheet with the lyrics and chord images on one sheet of paper for easy reference. I use Firefox and tried to save your webpage for offline usage to see if this works and preserves the program. It saves all kinds of files but nothing that is executable or allows me to work offline. When I restart Firefox I get it to load the previous session which includes your program but this is dependent on blogspot.com working properly (which did not work properly for a while which caused me to look for a solution). I thought perhaps your program would be available on GooglePlay for permanent download but don’t see it there.
ReplyDeleteI will try your new version 2.1 over the next few days. With regards to your questions about publishing my work, well it’s a long story but………………………..(short version)……….. I got back into playing acoustic guitar, discovered I enjoyed singing and writing lyrics, wrote 51 songs so far (in various degrees of completion), performed for a few friends and got good feedback, played a small concert (and got paid !!), then did a couple of songs at a small Cuban club and got a big round of applause, and finally decided to give this paid musician business a try. I call my music EAP (Edgy Ambiguity Pop) because I try to write about perhaps somewhat controversial or personal subject matters and my lyrics are designed to be interpreted differently by different listeners. Currently working on putting together my first virtual Zoom concert to put the music out there to see if it resonates the way it did with my friends. Sorry about writing a book but you asked……��. Regards, Uwe