Bar Charts
Learn how to draw bar charts for data visualisation in D3.
We'll cover the following...
Bar charts
A bar chart is a visual representation using either horizontal or vertical bars to show comparisons between discrete categories. There are a number of variations of bar charts including stacked, grouped, horizontal, and vertical.
We will work through a simple vertical bar chart that uses a value on the y-axis and a category in the form of a name on the x-axis.
The end result will look like this:
The data
The data for this example will be sourced from an external (purely fictional) CSV file named sales.csv
. It consists of a column of names and “sales.” Its contents looks as follows:
salesperson,sales
Bob,33
Robin,12
...
The code
The full code listing for the example we are going to work through is ...