Skip to main content
Public

Share visualization

Send this visualization to others.

Letter Count Bar Chart

Public visualization

By sjengle on VizHub

LinkedIn caption

LinkedIn cannot prefill the post text. Copy the caption, then paste it in LinkedIn. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code

The embed preserves the visualization's visibility and project dataset permissions.

Download & exportHTML, source ZIP and authorized project data

Source ZIP contains editable visualization files; it does not include project datasets. Standalone HTML is available where authorized and packages readable referenced data for offline use. Dataset ZIP requires project read permission.

Standalone HTMLSource ZIP
Publishing & handoffCopy a client maintenance summary

Includes the canonical link, visibility, and available export formats. Confirm dataset attribution, licensing and maintenance responsibilities with the publisher.

Letter Count Bar Chart

1 star1Public
SSophie Engle
Last edited Jan 27, 2020
Created on Jan 18, 2020
Forked from HTML Starter

This example demonstrates a bar chart that visualizes the frequency of each letter in a text excerpt from the Peter Piper nursery rhyme. It asynchronously loads the text file via `d3.text`, counts letters using JavaScript `Map` objects, and renders the chart with SVG rectangles. The visualization uses D3 v5 scales (`scaleLinear`, `scaleBand`) and axes (`axisBottom`, `axisRight`) to map counts to bar heights, with interactive updates triggered by `keyup` events on a textarea.

AI-generated description

Letter Count Bar Chart

In this demo, we asynchronously load a text file, use JavaScript to count the number of times each letter appears in that file, and generate a bar chart showing the letter count in D3.js v5.

This is meant to be an introductory demo to expose students to HTML, CSS, SVG, JavaScript, D3, Bl.ocks, Blockbuilder, and VizHub for the first time.

References

This example can be found at: Gist, Bl.ocks, Blockbuilder, VizHub

The starter template for this example can be found at: Gist

See the Wikipedia page Peter Piper Nursery Rhyme for the origins behind the text used in this example.

Inspirations

This example has undergone multiple iterations:

Below you can find videos related to an older version of this example. Please note that some content was discussed in-class only:

The original inspirations come from the following excellent tutorials on creating a bar chart in D3 for the first time:

  • D3 Bar Chart by Mike Bostock, Observable Notebook using D3v5, published on November 2017.

  • Let's Make a Bar Chart by Mike Bostock, Blog Post using D3v3, published on November 2013.

  • Making a Bar Chart by Scott Murray, Blog Post using D3v3, updated on December 2018.

Comments

Sign in to join the discussion.

MIT Licensed