Reputation: 4214
I am drawing a simple (4 options) radar chart with d3. But even with manualy defined scale my axis draws on domain [0,1] both in terms of pixel size (length) and labeled numbers.
Here is the code:
var scl = d3.scale.linear().domain([0, 100]).range([0, 100]);
var x1Axis = d3.svg.axis(scl);
d3.select('#radarWrapper svg')
.append('g')
.attr("class", "axis")
.attr("transform", "translate(" + (width/2) + "," + (height/2) + ")")
.call(x1Axis);
this draws a stupid one-point scale in the center of svg, without any relation to defined scale:
Upvotes: 0
Views: 70
Reputation: 109282
The scale to use is not set as an argument to the constructor to d3.svg.axis()
(it doesn't take any arguments), but through the .scale()
method:
var x1Axis = d3.svg.axis().scale(scl);
Complete demo here.
Upvotes: 2