#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: | [email protected]… |
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
Note: See
TracTickets for help on using
tickets.
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