Slides: bit.ly/d3-v4
By Mike Bostock
var p = d3.select("body").append('p');
p.html('hello');
var p = d3.select("body").append('p').data([42, 34, 54, 65, 75]);
p.text(function(d){ return 'hello ' + d;})
Fiddle
var p = d3.select("body").append('p').data([42, 34, 54, 65, 75]);
p.enter().append()
.text(function(d){ return 'hello ' + d;})
Fiddle
hello 42
;
var p = d3.select("body").selectAll('p')
.append('p').data([42, 34, 54, 65, 75]);
p.enter().append('p')
.text(function(d){ return 'hello ' + d;})
.style('color', 'red')
Fiddle
var els = d3.select("body")
.selectAll("p")
.data(data, function(d) { return d; });// UPDATE
var updating = els.style("color", "red");
var entering = els.enter().append("p")// ENTER
.text(String)
.style("color", "blue")
var exiting = els.exit().style("color", "lightgrey");//EXIT
var merged = els.merge(entering)// ENTER + UPDATE
.style("color", "green");
Fiddle
var exiting = els.exit()
.transition()
.duration(750)
.ease(d3.easeLinear)
.style("color", "lightgrey");//EXIT
Fiddle
x = d3.scaleLinear()
.range([0, width])
x = d3.scaleLinear()
.range([0, width])
.domain([0, 100]);
Fiddle
var xAxis = d3.axisBottom(x).ticks(12);
var xAxis = d3.axisBottom(x).ticks(12);
svg.append("g")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
render() {
setup();
populate();
}
function setUp() {
var margin = {top: 20, right: 20,bottom: 30,left: 50};
width = 800 - margin.left - margin.right,
height = 400 - margin.top - margin.bottom;
var x = d3.scaleLinear()
.range([0, width]);
var y = d3.scaleLinear()
.range([height, 0]);
}
Demo
Thank you for you attention!