Skip to main content
100%

Letter Count Bar Chart

✓ Published0🌍 Public
SShuangjiaoHu
Last edited Aug 27, 2018
Created on Aug 24, 2018

This interactive bar chart visualizes the frequency of each letter in the text of *Peter Piper*. The visualization loads a text file asynchronously using `d3.text`, counts letter occurrences with JavaScript, and renders the results as an SVG bar chart using D3.js v4. The chart updates dynamically with each keystroke in a textarea, utilizing `d3.scaleLinear`, `d3.scaleBand`, and `d3.axisBottom`/`d3.axisLeft` for scales and axes. The code demonstrates D3’s enter/update/exit pattern for animated transitions between data states.

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 v4.

This is meant to be an introductory demo to expose students to HTML, CSS, JavaScript, D3.js, bl.ocks.org, and blockbuilder.org for the first time.

References

This is based off the following example:

http://bl.ocks.org/sjengle/e8c0d6abc0a8d52d4b11

It has been updated for D3.js v4 based on the following updated bar chart example:

https://bl.ocks.org/mbostock/3885304

Please see the original examples for videos and additional references.

forked from <a href='http://bl.ocks.org/sjengle/'>sjengle</a>'s block: <a href='http://bl.ocks.org/sjengle/1e23258249638a508426470a48ff2924'>Letter Count Bar Chart (d3v4)</a>

forked from <a href='http://bl.ocks.org/alark/'>alark</a>'s block: <a href='http://bl.ocks.org/alark/78ae4d0395be9900e7b88c33bcb5a208'>Letter Count Bar Chart (d3v4)</a>

mit Licensed

Similar vizzes