From c4a1115d27233f6f08fb683c072cfc4447a2298c Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Thu, 22 Mar 2012 17:44:36 -0400 Subject: [PATCH] Fix Issue 299: option labelsKMG2 doesn't support anything after terabyte (T) --- dygraph-tickers.js | 8 ++++---- tests/labelsKMB.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dygraph-tickers.js b/dygraph-tickers.js index b91b82f..41e60e4 100644 --- a/dygraph-tickers.js +++ b/dygraph-tickers.js @@ -170,12 +170,12 @@ Dygraph.numericTicks = function(a, b, pixels, opts, dygraph, vals) { var k_labels = []; if (opts("labelsKMB")) { k = 1000; - k_labels = [ "K", "M", "B", "T" ]; + k_labels = [ "K", "M", "B", "T", "Q" ]; } if (opts("labelsKMG2")) { if (k) Dygraph.warn("Setting both labelsKMB and labelsKMG2. Pick one!"); k = 1024; - k_labels = [ "k", "M", "G", "T" ]; + k_labels = [ "k", "M", "G", "T", "P", "E" ]; } var formatter = opts('axisLabelFormatter'); @@ -190,8 +190,8 @@ Dygraph.numericTicks = function(a, b, pixels, opts, dygraph, vals) { if (k_labels.length > 0) { // TODO(danvk): should this be integrated into the axisLabelFormatter? // Round up to an appropriate unit. - var n = k*k*k*k; - for (j = 3; j >= 0; j--, n /= k) { + var n = Math.pow(k, k_labels.length); + for (j = k_labels.length - 1; j >= 0; j--, n /= k) { if (absTickV >= n) { label = Dygraph.round_(tickV / n, opts('digitsAfterDecimal')) + k_labels[j]; diff --git a/tests/labelsKMB.html b/tests/labelsKMB.html index 2be418e..dd4899e 100644 --- a/tests/labelsKMB.html +++ b/tests/labelsKMB.html @@ -33,7 +33,7 @@ }; var data = []; - for (var i = 0, n = 1; i < 43; i++, n *= 2) { + for (var i = 0, n = 1; i < 63; i++, n *= 2) { data.push([i, n]); } -- 2.7.4