<html>
<body>
<p>...</p>
<p>
<em>...</em>
</p>
<p>...</p>
</body>
</html>





One exception:

<svg>
<rect x="200" y="50" width="400" height="100"
fill="none" stroke="red">
</rect>
</svg>
<svg>
<path d="..." />
</svg>
Turtle graphics command language for arbitrary shapes:
D3 Selections
d3.select( "svg" )
First <svg> in document.
d3.selectAll( "circle" )
All <circle> elements
in document.
d3.select("svg") .selectAll("circle")All <circle> elements
in first <svg> in document.
d3.select("svg:first circle")d3.select("svg") .selectAll("circle")
d3.select( "svg" )
.select( "circle" )
.attr( "fill", "red" );
d3.select( "svg" )
.selectAll( "circle" )
.attr( "fill", "red" );
ds = [ "red", "yellow", "green" ];
d3.select( "svg" )
.selectAll( "circle" )
.data( ds )
.attr( "fill",
function(d) { return d } );
ds = [ [ 125, "red" ],
[ 175, "yellow" ],
[ 225, "green" ] ];
d3.select( "svg" )
.selectAll( "circle" )
.data( ds )
.attr( "cx", d=>d[0] )
.attr( "fill", d=>d[1] );
ds = [ [ 100, "red" ],
[ 200, "yellow" ],
[ 300, "green" ] ];
d3.select( "svg" )
.selectAll( "circle" )
.data( ds )
.enter()
.append( "circle" )
.attr( "r", 20 )
.attr( "cx", 175 )
.attr( "cy", d=>d[0] )
.attr( "fill", d=>d[1] );
The General D3 Pattern
d3.select( "#id" )
.selectAll( "circle" )
.data( dataset )
.enter()
.append( "circle" )
.attr( ..., ... )
.attr( ..., ... )
More D3
Events and Interactivity
d3.select( "svg" )
.selectAll( "circle" )
.on( "mouseenter",
function() {
d3.select(this)
.attr( "fill", "red" ) } )
.on( "mouseleave",
function() {
d3.select(this)
.attr( "fill", "blue" ) } )
d3.select( "svg" )
.selectAll( "circle" )
.on( "mouseenter",
function() {
d3.select( "text" )
.text(
d3.select(this)
.attr( "fill" ) ) } )
.on( "mouseleave",
function() {
d3.select( "text" )
.text( "none" ) } )
function onmove() {
var pt = d3.mouse( svg );
center.each( function(d, i) {
data[i][3] = Math.hypot( pt[0]-data[i][0],
pt[1]-data[i][1] ); } );
left.attr( "fill", (d,i) => scL( data[i][3] ) );
center.attr( "fill", (d,i) => scC( data[i][3] ) );
right.attr( "fill", (d,i) => scR( data[i][3] ) );
} )
var scC = d3.scaleLinear().domain( [0,50] )
.range( ["red", "blue"] );
I don't think we know yet!
What is D3?
What is D3?