Published
Edited
Jun 1, 2020
1 star
25 Apr 2020: First Bar Chart26 Apr 2020: Bar Chart Revisited27 Apr 2020: Finalising the Bar Chart28 Apr 2020: What Else I Learned From That Bar Chart29 Apr 2020: Setting up Observable30 Apr 2020: What Else Can I Do With This Bar Chart?1 May 2020: Formatting Numbers and Sorting a Bar Chart2 May 2020: Exploring More of Observable and Vega-Lite3 May 2020: Exploring More Vega-Lite4 May 2020: Vega-Lite Scatterplot and Heat Map, and More Posts on Getting Started With Data Viz5 May 2020: Vega-Lite Scatterplot continued6 May 2020: D3 Scatterplot7 May 2020: D3 Scatterplot with Legends8 May 2020: D3 Scatterplot with Tooltips9 May 2020: D3 Scatterplot with Voronoi Tooltips10 May 2020: Line charts11 May 2020: Vega-Lite Line Charts12 May 2020: D3 Line Chart13 May 2020: D3 Multi-Line Chart14 May 2020: D3 Multi-Line Chart with Annotations15 May 2020: D3 Multi-Line Chart with Shading16 May 2020: Donut Charts and Pie Charts17 May 2020: Pie Charts in Vega-Lite18 May 2020: Donut Chart in Vega-Lite19 May 2020: Donut Chart in D320 May 2020: Donut Chart in D3 with Footnotes21 May 2020: Donut Chart in D3 with Tooltips22 May 2020: Area Charts, Stacked Area Charts, Stream graphs and Ridgelines23 May 2020: Area Charts in Vega-Lite and CSV Parsing24 May 2020: Area Charts in D3 with Tooltips25 May 2020: Cumulative Area Chart in D3 with Tooltips26 May 2020: Histograms and Density Plots27 May 2020: Exploratory Histogram28 May 2020: D3 Histogram29 May 2020: D3 Histogram Styling30 May 2020: Data Tables31 May 2020: Wikipedia Data Tables
1 June 2020: Wrangling Wikipedia List Data and Summary Statistics
2 June 2020: Treemaps, Dendrograms, Sunbursts, Circle Packing, and Tree Diagrams3 June 2020: D3 Tree Diagram and D3 Hierarchy4 June 2020: D3 Clustered Dendrogram5 June 2020: D3 Radial Tidy Tree and Radial Dendrogram6 June 2020: D3 Collapsible Tidy Tree7 June 2020: D3 Collapsible Tidy Tree (Improved)8 June 2020: Designing for Touch Devices: Drag, Click, Hover, Focus, Scroll, Zoom, Delaunay, Voronoi9 June 2020: Designing for Small Screens: Responsive Data Viz, Resizing, and Aspect Ratios10 June 2020: Typography for Data Viz11 June 2020: Color in Data Viz12 June 2020: Styled Bar Chart13 June 2020: Accessible Bar Chart and Accessible Data Table14 June 2020: Line Chart with Points and Bar Chart15 June 2020: Network Diagrams16 June 2020: D3 Disjoint Force-Directed Graph17 June 2020: D3 Bar Chart with Textured Line18 June 2020: D3 Bar Chart Transitions19 June 2020: D3 Bar Chart Transitions (Improved)20 June 2020: Sketchy D3 Bar Chart Style21 June 2020: Brushing to Filter and Zoom Using D3 Brush22 June 2020: D3 Bar Chart Brush (Work In Progress)23 June 2020: Linear Regression24 June 2020: Hatched Pattern Effect Bar Chart25 June 2020: Checkerboard Fill Effect Bar Chart26 June 2020: D3 Bar Chart Brush27 June 2020: Using Textures28 June 2020: Charting Typing Speed: Data and Exploration29 June 2020: Charting Typing Speed: Data and Exploration with Vega-Lite30 June 2020: Charting Typing Speed: Data and Exploration with Vega-Lite and Datawrapper1 July 2020: Charting Typing Speed: Data and Exploration with Vega-Lite Bubble Chart2 July 2020: Charting Typing Scores: Data and Exploration with Vega-Lite3 July 2020: Journal Updates and User Testing4 July 2020: About Heatmaps5 July 2020: Data Wrangling for a Heatmap6 July 2020: D3 Heatmap Without Sorting7 July 2020: D3 Heatmap With Sorting8 July 2020: D3 Heatmap with Legend9 July 2020: D3 Heatmap Styled10 July 2020: About Bubble Charts11 July 2020: D3 Bubble Chart12 July 2020: D3 Bubble Chart with Labels on Hover13 July 2020: D3 Bubble Chart with Voronoi Labels on Hover14 July 2020: D3 Bubble Chart with Voronoi Tooltips15 July 2020: About Population Pyramids16 July 2020: Data Wrangling for Population Pyramids17 July 2020: D3 Population Pyramid18 July 2020: About Sankey, Alluvial, Parallel Sets, and Parallel Coordinates19 July 2020: Data Wrangling for a Sankey Diagram20 July 2020: D3 Sankey Diagram21 July 2020: D3 Sankey Diagram with Hovers and Percentages22 July 2020: D3 Parallel Coordinates23 July 2020: D3 Parallel Coordinates (Updates)24 July 2020: About Slope Charts25 July 2020: Data Wrangling for a Slope Chart26 July 2020: D3 Slope Chart27 July 2020: D3 Slope Chart with Color28 July 2020: D3 Slope Chart with Highlight Color and Gray Context Lines29 July 2020: D3 Slope Chart Small Multiples (Work in Progress)30 July 2020: D3 Slope Chart Small Multiples31 July 2020: About Dumbbell or Connected Dot Plots1 August 2020: D3 Dumbbell Plot2 August 2020: 100 Days of Data VizAbout TimelinesBuilding TimelinesAbout SparklinesAbout Circle PackingD3 Circle PackingD3 Circle Packing with Data Wrangling and Interactive GroupingSort by arbitrary arrayAbout Choropleth MapsAbout Map Data: GeoJSON and TopoJSON with D3
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// a_text = fetch(`https://en.wikipedia.org/w/api.php?format=json&origin=*&action=parse&prop=text&page=List_of_proverbial_phrases&section=1`).then(response => response.json())
Insert cell
Insert cell
text = FileAttachment("list-of-proverbial-phrases-a-1-Jun-2020.json").json();
Insert cell
Insert cell
text.parse.text["*"]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
phrases = phrases_list.querySelectorAll("li")
Insert cell
Insert cell
output = Array.from(phrases, r => r.textContent.trim())
Insert cell
Insert cell
clean_phrases = Array.from(phrases, r => ( // arrow function expression with a concise body
r.textContent.trim()
.replace(/\..*$/g, "") // s/A new language is a new life. Persian proverb[2]/A new language is a new life/
.replace(/\[.\]/g, "") // s/A fool and his money are soon parted[1]/A fool and his money are soon parted/
.replace(/,$/g, "") // s/April showers bring forth May flowers,/April showers bring forth May flowers/
.replace(/[()]/g,"") // s/A stitch in time (saves nine)/A stitch in time saves nine/
.replace(/\/[^ ]*/,"") // s#A watched pot/kettle never boils#A watched pot never boils#
+ "." // add trailing full stop
))
Insert cell
data = Object.assign(clean_phrases.map(d => d.length), {x: "Characters"})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
clean_phrases.slice(0,3)
Insert cell
Insert cell
clean_phrases.length
Insert cell
Insert cell
clean_phrases[0]
Insert cell
Insert cell
Insert cell
// What is the total number of characters across the dataset?
// data.reduce((sum, d) => (sum += +d), 0)
d3.sum(data)
Insert cell
Insert cell
min = d3.min(data)
Insert cell
Insert cell
max = d3.max(data)
Insert cell
Insert cell
extent = d3.extent(data)
Insert cell
Insert cell
median = d3.median(data)
Insert cell
Insert cell
mean = d3.mean(data)
Insert cell
Insert cell
stddev = d3.deviation(data)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
x = d3.scaleLinear()
.domain([0, d3.max(data)]).nice()
.range([margin.left, width - margin.right])
Insert cell
bins = d3.histogram()
.domain(x.domain())
.thresholds(14)
(data)
Insert cell
y = d3.scaleLinear()
.domain([0, d3.max(bins, d => d.length)]).nice()
.range([height - margin.bottom, margin.top])
Insert cell
xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x).ticks(10 ).tickSizeOuter(0))
.call(g => g.append("text")
.attr("x", width - margin.right + 12)
.attr("y", 8)
.attr("fill", "currentColor")
.attr("font-weight", "bold")
.attr("text-anchor", "start")
.text(data.x))
Insert cell
yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y).ticks(height / 40))
.call(g => g.select(".domain").remove())
.call(g => g.select(".tick:last-of-type text").clone()
.attr("x", 4)
.attr("fill", "currentColor")
.attr("text-anchor", "start")
.attr("font-weight", "bold")
.text(data.y))
Insert cell
height = 450
Insert cell
margin = ({top: 48, right: 72, bottom: 48, left: 24})
Insert cell
d3 = require("d3@5")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more