From 685220dddcce40e4fcd51152f0e1f021927b83d4 Mon Sep 17 00:00:00 2001 From: "olau@iola.dk" Date: Wed, 17 Mar 2010 13:07:36 +0000 Subject: [PATCH] More robust handling of axis from data passed in from getData git-svn-id: https://flot.googlecode.com/svn/trunk@240 1e0a6537-2640-0410-bfb7-f154510ff394 --- jquery.flot.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 73d336a..4fae3b8 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -130,7 +130,8 @@ overlay = null, // canvas for interactive stuff on top of plot eventHolder = null, // jQuery object that events should be bound to ctx = null, octx = null, - axes = { xaxis: {}, yaxis: {}, x2axis: {}, y2axis: {} }, + axes = { xaxis: { n: 1 }, yaxis: { n: 1 }, + x2axis: { n: 2 }, y2axis: { n: 2 } }, plotOffset = { left: 0, right: 0, top: 0, bottom: 0}, canvasWidth = 0, canvasHeight = 0, plotWidth = 0, plotHeight = 0, @@ -257,11 +258,13 @@ function axisSpecToRealAxis(obj, attr) { var a = obj[attr]; - if (!a || a == 1) - return axes[attr]; - if (typeof a == "number") + if (typeof a == "object") // if we got a real axis, extract number + a = a.n; + if (typeof a == "number" && a != 1) return axes[attr.charAt(0) + a + attr.slice(1)]; - return a; // assume it's OK + + // default to first axis + return axes[attr]; } function fillInSeriesOptions() {