April 2015
Intermediate to advanced
278 pages
5h 38m
English
Until now, we just scaled our dataset without drawing a single shape on the screen. For the next step, I want to introduce d3.svg.axis(), a built-in function to draw axes and labels. This function makes it very easy and comfortable to add an axis to a chart, as shown in the following code:
var axis = d3.svg.axis();
First, we create a new
axis object with d3.svg.axis(), which we can then configure by calling different methods on it. I will now discuss the most important of these methods:
axis.scale([scale]): This adds scaling to an axis as follows:var scale = d3.scale.linear() .domain([0, 10]) .range([0, 100]); var axis = d3.svg.axis() .scale(scale);
axis.orient([orientation]): This specifies an orientation of the ticks values relative ...Read now
Unlock full access