From 70e36134d60b3508a891644cb63b202867d021d9 Mon Sep 17 00:00:00 2001 From: "olau@iola.dk" Date: Thu, 10 Feb 2011 15:07:01 +0000 Subject: [PATCH] Add support for Infinity/-Infinity by hacking it into +/- Number.MAX_VALUE (closes issue 444) git-svn-id: https://flot.googlecode.com/svn/trunk@294 1e0a6537-2640-0410-bfb7-f154510ff394 --- NEWS.txt | 2 ++ jquery.flot.js | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index e77a13b..6273bf6 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -78,6 +78,8 @@ Changes: types (sponsored by Utility Data Corporation). - Resize plugin for automatically redrawing when the placeholder changes size, e.g. on window resizes (sponsored by Novus Partners). +- Support Infinity/-Infinity for plotting asymptotes by hacking it + into +/-Number.MAX_VALUE (reported by rabaea.mircea). - New hooks: drawSeries diff --git a/jquery.flot.js b/jquery.flot.js index 52cbe82..356980f 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -500,6 +500,7 @@ function processData() { var topSentry = Number.POSITIVE_INFINITY, bottomSentry = Number.NEGATIVE_INFINITY, + fakeInfinity = Number.MAX_VALUE, i, j, k, m, length, s, points, ps, x, y, axis, val, f, p; @@ -513,9 +514,9 @@ } function updateAxis(axis, min, max) { - if (min < axis.datamin) + if (min < axis.datamin && min != -fakeInfinity) axis.datamin = min; - if (max > axis.datamax) + if (max > axis.datamax && max != fakeInfinity) axis.datamax = max; } @@ -579,6 +580,10 @@ val = +val; // convert to number if (isNaN(val)) val = null; + else if (val == Infinity) + val = fakeInfinity; + else if (val == -Infinity) + val = -fakeInfinity; } if (val == null) {