D3 Tutorial
✓ Published0🌍 Public
JJamestiberiuseanes
Last edited Jan 26, 2016
Created on Jan 24, 2016
This example shows a simple bar chart built with D3, where 25 randomly generated numbers between 0 and 30 are each represented as a teal vertical bar. The chart uses `d3.select`, `.data()`, `.enter()`, and `.append("div")` to create the bars, with the `height` style set via a scaling factor of 5. The data is produced with JavaScript’s `Math.random()` in a loop, and the bars are styled with CSS classes. The page also includes a static R version of a barplot created with `barplot(data)` for comparison.
AI-generated descriptionBuilt with blockbuilder.org
Here is the image of the simple bar chart in R:

Here is the code used to create the chart (also shown in the image):
data <- c(5, 10, 15, 20, 25)
barplot(data)