Using the simple array of numbers only, create a bar chart.
var dataOnly = [2500, 4000, 400, 25000, 45000];
var data = [
{name: "panda", population: 2500},
{name: "tiger", population: 4000},
- reverse linear scale output (range)
- set starting y coordinate of rectangle to be length height of reversed rectangle
- adjust height of each rectangle in bar chart
var y = d3.scaleLinear()
.domain([0, max2])
.range([400, 0]);
.attr("y", function(d){
return y(d.population);
})
.attr("height", function(d){
var height = 450 - y(d.population);
console.log(height)
return height;
})
group is the "g" tag. transform moves things translate moves in x, y direction rotate
var svg = d3.select("#canvas")
.append("g")
.attr("transform", "translate(200, 0)");
- change x and y translation values
Hint: transform, rotate(degrees, x, y)









