From baae2eab6b15c3e92e208ad8d5d92ba877faefd0 Mon Sep 17 00:00:00 2001 From: Jeff Kapellas Date: Sat, 26 Jul 2014 00:20:11 -0700 Subject: [PATCH] Added Log10 y-axis number format Added Rickshaw.Fixtures.Number.formatLog10KMBT for formatting y-axis labels for use in log10 scalar graphs. --- src/js/Rickshaw.Fixtures.Number.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/js/Rickshaw.Fixtures.Number.js b/src/js/Rickshaw.Fixtures.Number.js index 85ddcf7b..56dda71c 100644 --- a/src/js/Rickshaw.Fixtures.Number.js +++ b/src/js/Rickshaw.Fixtures.Number.js @@ -22,3 +22,24 @@ Rickshaw.Fixtures.Number.formatBase1024KMGTP = function(y) { else if (abs_y === 0) { return '' } else { return y } }; + +Rickshaw.Fixtures.Number.formatLog10KMBT = function(y) { + var abs_y = Math.abs(y); + if (abs_y >= 14) { return "100T" } + else if (abs_y >= 13) { return "10T" } + else if (abs_y >= 12) { return "1T" } + else if (abs_y >= 11) { return "100B" } + else if (abs_y >= 10) { return "10B" } + else if (abs_y >= 9) { return "1B" } + else if (abs_y >= 8) { return "100M" } + else if (abs_y >= 7) { return "10M" } + else if (abs_y >= 6) { return "1M" } + else if (abs_y >= 5) { return "100K" } + else if (abs_y >= 4) { return "10K" } + else if (abs_y >= 3) { return "1000" } + else if (abs_y >= 2) { return "100" } + else if (abs_y >= 1) { return "10" } + else if (abs_y < 1 && y > 0) { return "1" } + else if (abs_y === 0) { return '' } + else { return y } +};