Monday, 15 February 2010

javascript - Is it possible to find the distance between ticks in D3.js? -


Is there any way to detect the distance between the tick marks on the X axis? I am using gradient scale with range-band, in which I tell that there is no tick function in it.

  var x = d3.scale.ordinal () Range Points ([_ margin.left, cWidth]); X.domain (['' December, 'Jan']); Var testTicks = x.ticks (2);   

This fixes the axis (can not post an image), but how can I get the distance

(Edit: Added x. Domain)

  var data = [45, 31, 23], // whatever your The data is GraphHeight = 400, // However, if you want to set many numbers TicksY = 4, // set y scale // (hardcoded domain for minimum and maximum data vals in this example; you use d3.max real life Should do) y = D3.scale.linear (). Category (Graphite, 0)) Domain (23, 45), yAxis = d3.svg.axis (). Scale (y). Invalid ("left"). Ticks (numberTicksY), // Example returns - & gt; [20, 30, 40, 50] tickArr = y.ticks (numberTicksY), // To determine the positions, the last 2 ticks with the y scale FN (if the Seal has used the first 2) have been used by tickDistance = Y (tickArr [tickArr.length - 1]) - Y (Teeker [tickr. Length - 2]);    

No comments:

Post a Comment