/** * Return drawing steps * @ parameter range min to max [0,50] * @ parameter tick count (numeric) */ getstep:function (domain, m) { if (m = = N ull) m = ten; var = khelpers.scaleextent (domain), span = extent[1]-extent[0], step = Math.pow (extent, Math.floor (Math.log (span/m) /math.ln10)), err = M/span * STEP; if (Err <=.) Step *= 10; else if (Err <=.) Step *= 5; else if (Err <=.) Step *= 2; Extent[0] = Math.ceil (extent[0]/step) * STEP; EXTENT[1] = Math.floor (extent[1]/Step) * Step + step *. 5; EXTENT[2] = step; return step; }, scaleextent:function (domain) { var start = domain[0], stop = domain[domain.length-1];
return Start < stop? [Start, stop]: [Stop, start]; },
The idea is to get the step, then recalculate the maximum, the minimum, and the final draw is the full scale
Reprint please specify the copyright and reprint address
A workaround that causes the scale to be d3js when drawing an axis with a