Skip to content

Commit

Permalink
Remove usage of getUsedAxes(), after the refactor of setupGrid, it's
Browse files Browse the repository at this point in the history
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
  • Loading branch information
olau@iola.dk committed Mar 14, 2011
1 parent 006708d commit 2ab5ce8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 37 deletions.
34 changes: 5 additions & 29 deletions jquery.flot.js
Expand Up @@ -175,22 +175,14 @@
};
plot.getAxes = function () {
var res = {}, i;
for (i = 0; i < xaxes.length; ++i)
res["x" + (i ? (i + 1) : "") + "axis"] = xaxes[i] || {};
for (i = 0; i < yaxes.length; ++i)
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 };

$.each(xaxes.concat(yaxes), function (_, axis) {
if (axis)
res[axis.direction + (axis.n != 1 ? axis.n : "") + "axis"] = axis;
});
return res;
};
plot.getXAxes = function () { return xaxes; };
plot.getYAxes = function () { return yaxes; };
plot.getUsedAxes = getUsedAxes; // return flat array with x and y axes that are in use
plot.c2p = canvasToAxisCoords;
plot.p2c = axisToCanvasCoords;
plot.getOptions = function () { return options; };
Expand Down Expand Up @@ -398,21 +390,6 @@
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) {
if (!axes[number - 1])
axes[number - 1] = {
Expand Down Expand Up @@ -1383,9 +1360,8 @@
}

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) {
axis = axes[i];
if (axis.direction == coord) {
Expand Down
4 changes: 2 additions & 2 deletions jquery.flot.navigate.js
Expand Up @@ -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,
min = minmax[axis.direction].min,
max = minmax[axis.direction].max,
Expand Down Expand Up @@ -267,7 +267,7 @@ Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-L
if (isNaN(delta.y))
delta.y = 0;

$.each(plot.getUsedAxes(), function (i, axis) {
$.each(plot.getAxes(), function (_, axis) {
var opts = axis.options,
min, max, d = delta[axis.direction];

Expand Down
10 changes: 4 additions & 6 deletions jquery.flot.selection.js
Expand Up @@ -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) {
var axis, from, to, axes, key;
var axis, from, to, key, axes = plot.getAxes();

axes = plot.getUsedAxes();
for (i = 0; i < axes.length; ++i) {
axis = axes[i];
for (var k in axes) {
axis = axes[k];
if (axis.direction == coord) {
key = coord + axis.n + "axis";
if (!ranges[key] && axis.n == 1)
Expand Down Expand Up @@ -235,7 +234,6 @@ The plugin allso adds the following methods to the plot object:
return { from: from, to: to, axis: axis };
}


function setSelection(ranges, preventEvent) {
var axis, range, o = plot.getOptions();

Expand Down

0 comments on commit 2ab5ce8

Please sign in to comment.