From 0af6e3468086533368de97dc6ea704df5ce3ef10 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 13 Dec 2009 10:58:40 -0800 Subject: [PATCH] apply patch #2 from ComSubVie --- dygraph.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dygraph.js b/dygraph.js index 08ff8ae..8d5d369 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1052,23 +1052,24 @@ Dygraph.numericTicks = function(minV, maxV, self) { var ticks = []; for (var i = 0; i < nTicks; i++) { var tickV = low_val + i * scale; + var absTickV = Math.abs(tickV); var label = self.round_(tickV, 2); if (self.attr_("labelsKMB")) { var k = 1000; - if (tickV >= k*k*k) { + if (absTickV >= k*k*k) { label = self.round_(tickV/(k*k*k), 1) + "B"; - } else if (tickV >= k*k) { + } else if (absTickV >= k*k) { label = self.round_(tickV/(k*k), 1) + "M"; - } else if (tickV >= k) { + } else if (absTickV >= k) { label = self.round_(tickV/k, 1) + "K"; } } else if (self.attr_("labelsKMG2")) { var k = 1024; - if (tickV >= k*k*k) { + if (absTickV >= k*k*k) { label = self.round_(tickV/(k*k*k), 1) + "G"; - } else if (tickV >= k*k) { + } else if (absTickV >= k*k) { label = self.round_(tickV/(k*k), 1) + "M"; - } else if (tickV >= k) { + } else if (absTickV >= k) { label = self.round_(tickV/k, 1) + "k"; } } -- 2.7.4