Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#3472 closed defect (wontfix)

Bug in setAxesRanges function of "dojo.charting.PlotArea"

Reported by: guest Owned by: Tom Trenka
Priority: high Milestone:
Component: Charting Version: 0.4.2
Keywords: charting PlotArea setAxesRanges Cc: cdupetit@…
Blocked By: Blocking:

Description

Hello, In charting/PlotArea.js, in the function setAxesRanges, the variable's name ranges is used two times, that causes a bug when you call it.

The code is :

setAxesRanges:function () {
	var ranges = {};
	var axes = {};
	for (var i = 0; i < this.plots.length; i++) {
		var plot = this.plots[i];
		var ranges = plot.getRanges();
		var x = ranges.x;
		var y = ranges.y;
		var ax, ay;
		if (!axes[plot.axisX.getId()]) {
			axes[plot.axisX.getId()] = plot.axisX;
			ranges[plot.axisX.getId()] = {upper:x.upper, lower:x.lower};
		}
		ax = ranges[plot.axisX.getId()];
		ax.upper = Math.max(ax.upper, x.upper);
		ax.lower = Math.min(ax.lower, x.lower);
		if (!axes[plot.axisY.getId()]) {
			axes[plot.axisY.getId()] = plot.axisY;
			ranges[plot.axisY.getId()] = {upper:y.upper, lower:y.lower};
		}
		ay = ranges[plot.axisY.getId()];
		ay.upper = Math.max(ay.upper, y.upper);
		ay.lower = Math.min(ay.lower, y.lower);
	}
	for (var p in axes) {
		axes[p].range = ranges[p];
	}
}

Must be better like this :

setAxesRanges:function () {
	var ranges = {};
	var axes = {};
	for (var i = 0; i < this.plots.length; i++) {
		var plot = this.plots[i];
		var plotRanges = plot.getRanges();
		var x = plotRanges.x;
		var y = plotRanges.y;
		var ax, ay;
		if (!axes[plot.axisX.getId()]) {
			axes[plot.axisX.getId()] = plot.axisX;
			ranges[plot.axisX.getId()] = {upper:x.upper, lower:x.lower};
		}
		ax = ranges[plot.axisX.getId()];
		ax.upper = Math.max(ax.upper, x.upper);
		ax.lower = Math.min(ax.lower, x.lower);
		if (!axes[plot.axisY.getId()]) {
			axes[plot.axisY.getId()] = plot.axisY;
			ranges[plot.axisY.getId()] = {upper:y.upper, lower:y.lower};
		}
		ay = ranges[plot.axisY.getId()];
		ay.upper = Math.max(ay.upper, y.upper);
		ay.lower = Math.min(ay.lower, y.lower);
	}
	for (var p in axes) {
		axes[p].range = ranges[p];
	}
}

Kilroy

Change History (2)

comment:1 Changed 12 years ago by Tom Trenka

Resolution: wontfix
Status: newclosed

I'll keep it in mind as I'm doing to the port of the charting engine to the DojoX project. If you're looking for a fix for this for the 0.4.x branch, it won't happen (it's a dead branch as far as we are concerned, at this point).

Thanks for pointing it out. trt

comment:2 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.