From: Dan Vanderkam Date: Mon, 14 Dec 2009 22:12:22 +0000 (-0500) Subject: Incorporate base 2 patch from ComSubVie and update combined X-Git-Tag: v1.0.0~778 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=f09e46d424089c099b1bdeaf015d5b486ddcf9db;p=dygraphs.git Incorporate base 2 patch from ComSubVie and update combined --- diff --git a/dygraph-combined.js b/dygraph-combined.js index cb9d779..439c978 100644 --- a/dygraph-combined.js +++ b/dygraph-combined.js @@ -1143,11 +1143,19 @@ return self.GetXAxis(_206,_207,_208); } }; Dygraph.numericTicks=function(minV,maxV,self){ +if(self.attr_("labelsKMG2")){ +var _212=[1,2,4,8]; +}else{ var _212=[1,2,5]; +} var _213,low_val,high_val,nTicks; var _214=self.attr_("pixelsPerYLabel"); for(var i=-10;i<50;i++){ +if(self.attr_("labelsKMG2")){ +var _215=Math.pow(16,i); +}else{ var _215=Math.pow(10,i); +} for(var j=0;j<_212.length;j++){ _213=_215*_212[j]; low_val=Math.floor(minV/_213)*_213; diff --git a/dygraph.js b/dygraph.js index 473e55d..193f0f8 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1064,12 +1064,20 @@ Dygraph.numericTicks = function(minV, maxV, self) { // Try labels every 1, 2, 5, 10, 20, 50, 100, etc. // Calculate the resulting tick spacing (i.e. this.height_ / nTicks). // The first spacing greater than pixelsPerYLabel is what we use. - var mults = [1, 2, 5]; + if (self.attr_("labelsKMG2")) { + var mults = [1, 2, 4, 8]; + } else { + var mults = [1, 2, 5]; + } var scale, low_val, high_val, nTicks; // TODO(danvk): make it possible to set this for x- and y-axes independently. var pixelsPerTick = self.attr_('pixelsPerYLabel'); for (var i = -10; i < 50; i++) { - var base_scale = Math.pow(10, i); + if (self.attr_("labelsKMG2")) { + var base_scale = Math.pow(16, i); + } else { + var base_scale = Math.pow(10, i); + } for (var j = 0; j < mults.length; j++) { scale = base_scale * mults[j]; low_val = Math.floor(minV / scale) * scale;