Commit 2ab5ce87 authored by olau@iola.dk's avatar olau@iola.dk

Remove usage of getUsedAxes(), after the refactor of setupGrid, it's

no longer needed, and possibly misleading - hopefully, nobody else has
used it yet; also refactor getAxes() and remove annoying
backwards-compatibility stuff in it, it probably didn't help anything
and prevents one from using getAxes() in the obvious way


git-svn-id: https://flot.googlecode.com/svn/trunk@310 1e0a6537-2640-0410-bfb7-f154510ff394
parent 006708d9
...@@ -175,22 +175,14 @@ ...@@ -175,22 +175,14 @@
}; };
plot.getAxes = function () { plot.getAxes = function () {
var res = {}, i; var res = {}, i;
for (i = 0; i < xaxes.length; ++i) $.each(xaxes.concat(yaxes), function (_, axis) {
res["x" + (i ? (i + 1) : "") + "axis"] = xaxes[i] || {}; if (axis)
for (i = 0; i < yaxes.length; ++i) res[axis.direction + (axis.n != 1 ? axis.n : "") + "axis"] = axis;
res["y" + (i ? (i + 1) : "") + "axis"] = yaxes[i] || {}; });
// backwards compatibility - to be removed
if (!res.x2axis)
res.x2axis = { n: 2 };
if (!res.y2axis)
res.y2axis = { n: 2 };
return res; return res;
}; };
plot.getXAxes = function () { return xaxes; }; plot.getXAxes = function () { return xaxes; };
plot.getYAxes = function () { return yaxes; }; plot.getYAxes = function () { return yaxes; };
plot.getUsedAxes = getUsedAxes; // return flat array with x and y axes that are in use
plot.c2p = canvasToAxisCoords; plot.c2p = canvasToAxisCoords;
plot.p2c = axisToCanvasCoords; plot.p2c = axisToCanvasCoords;
plot.getOptions = function () { return options; }; plot.getOptions = function () { return options; };
...@@ -398,21 +390,6 @@ ...@@ -398,21 +390,6 @@
return res; return res;
} }
function getUsedAxes() {
var res = [], i, axis;
for (i = 0; i < xaxes.length; ++i) {
axis = xaxes[i];
if (axis && axis.used)
res.push(axis);
}
for (i = 0; i < yaxes.length; ++i) {
axis = yaxes[i];
if (axis && axis.used)
res.push(axis);
}
return res;
}
function getOrCreateAxis(axes, number) { function getOrCreateAxis(axes, number) {
if (!axes[number - 1]) if (!axes[number - 1])
axes[number - 1] = { axes[number - 1] = {
...@@ -1383,9 +1360,8 @@ ...@@ -1383,9 +1360,8 @@
} }
function extractRange(ranges, coord) { function extractRange(ranges, coord) {
var axis, from, to, axes, key; var axis, from, to, key, axes = allAxes();
axes = getUsedAxes();
for (i = 0; i < axes.length; ++i) { for (i = 0; i < axes.length; ++i) {
axis = axes[i]; axis = axes[i];
if (axis.direction == coord) { if (axis.direction == coord) {
......
...@@ -221,7 +221,7 @@ Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-L ...@@ -221,7 +221,7 @@ Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-L
} }
}; };
$.each(plot.getUsedAxes(), function(i, axis) { $.each(plot.getAxes(), function(_, axis) {
var opts = axis.options, var opts = axis.options,
min = minmax[axis.direction].min, min = minmax[axis.direction].min,
max = minmax[axis.direction].max, max = minmax[axis.direction].max,
...@@ -267,7 +267,7 @@ Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-L ...@@ -267,7 +267,7 @@ Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-L
if (isNaN(delta.y)) if (isNaN(delta.y))
delta.y = 0; delta.y = 0;
$.each(plot.getUsedAxes(), function (i, axis) { $.each(plot.getAxes(), function (_, axis) {
var opts = axis.options, var opts = axis.options,
min, max, d = delta[axis.direction]; min, max, d = delta[axis.direction];
......
...@@ -199,13 +199,12 @@ The plugin allso adds the following methods to the plot object: ...@@ -199,13 +199,12 @@ The plugin allso adds the following methods to the plot object:
} }
} }
// taken from markings support // function taken from markings support in Flot
function extractRange(ranges, coord) { function extractRange(ranges, coord) {
var axis, from, to, axes, key; var axis, from, to, key, axes = plot.getAxes();
axes = plot.getUsedAxes(); for (var k in axes) {
for (i = 0; i < axes.length; ++i) { axis = axes[k];
axis = axes[i];
if (axis.direction == coord) { if (axis.direction == coord) {
key = coord + axis.n + "axis"; key = coord + axis.n + "axis";
if (!ranges[key] && axis.n == 1) if (!ranges[key] && axis.n == 1)
...@@ -235,7 +234,6 @@ The plugin allso adds the following methods to the plot object: ...@@ -235,7 +234,6 @@ The plugin allso adds the following methods to the plot object:
return { from: from, to: to, axis: axis }; return { from: from, to: to, axis: axis };
} }
function setSelection(ranges, preventEvent) { function setSelection(ranges, preventEvent) {
var axis, range, o = plot.getOptions(); var axis, range, o = plot.getOptions();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment