Published
Edited
Nov 16, 2019
Insert cell
md`# d3.selection.style` // opt+cmd+j to inspect element for detail
Insert cell
set_h1_style_color = d3.select("h1").style("color", "cyan")
Insert cell
access_h1_style_color = d3.select("h1").style("color")
Insert cell
set_h1_style_with_func = d3.select("h1").style("transform", function(d, i, nodes){
return `translate(100px, 0px)`;
})
Insert cell
set_all_p_style_with_func = d3.selectAll("p").style("transform", function(d, i, nodes){
return (i % 2 === 0) ? `translate(100px, 0px)`: `translate(200px, 0px)`
})
Insert cell
set_all_p_fontSize_with_func = d3.selectAll("p").style("font-size", function(d, i, nodes){
return (i % 2 === 0) ? `12px`: `18px`;
})
Insert cell
d3 = require("https://cdn.jsdelivr.net/npm/d3@5.12.0/dist/d3.js");
Insert cell
import { anchorLink } from "@embracelife/tutorial-utilities"
Insert cell
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