Skip to main content
100%

D3.js - Barchart for counting characters in text

✓ Published1🌍 Public
AAxVa 🐍 💪
Last edited Nov 16, 2024
Created on Nov 15, 2024

This example visualizes character frequency in a text area as a horizontally oriented bar chart that updates dynamically with each keystroke or paste. It counts all characters, standardizing whitespace variants to a single "\\s" label, and color-codes bars by category: lowercase, uppercase, numbers, whitespace, and other symbols. Built with D3 v7, the chart uses `d3.scaleLinear` and `d3.scaleBand` for scaling, `d3.axisTop` and `d3.axisLeft` for ticks, and `selection.join` with transitions to animate bar height and position changes. The source text is derived from Nick Morgan's JavaScript Crash Course, 2024.

AI-generated description

Write a text in the textarea to see a bartchart for counting written characters. Try out writing "Hello, my friend! 123".

This example is based on the book "JavaScript Crash Course: A Hands-On, Project-Based Introduction to Programming" by Nick Morgan, No Starch Press, 2024.

Visit also my repo https://github.com/ax-va/JavaScript-Crash-Course-Morgan-2024.

MIT Licensed

Similar vizzes