Skip to content

Commit 383a47f

Browse files
committed
fix #16
(cherry picked from commit b2a6831)
1 parent 5940057 commit 383a47f

File tree

2 files changed

+14
-31
lines changed

2 files changed

+14
-31
lines changed

RectangularGauge.js

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -116,46 +116,28 @@ define(["dojo/_base/declare", "./GaugeBase", "dojox/gfx/matrix"], function(decla
116116
// tags:
117117
// private
118118
if(elements.length == 0){
119-
return {
120-
x: 0,
121-
y: 0,
122-
w: 0,
123-
h: 0
124-
};
119+
return {x: 0, y: 0, w: 0, h: 0};
125120
}
126-
var res = {
127-
x: -Infinity,
128-
y: -Infinity,
129-
w: 0,
130-
h: 0
131-
};
132121
var bbox = null;
122+
var minX, minY, maxX, maxY;
123+
minX = minY = +Infinity;
124+
maxX = maxY = -Infinity;
133125
for(var i = 0; i < elements.length; i++){
134126
bbox = this._computeBoundingBox(elements[i]._gfxGroup);
135-
if(!bbox){
136-
continue;
127+
if(minX > bbox.x){
128+
minX = bbox.x;
137129
}
138-
if(res.x < bbox.x){
139-
res.x = bbox.x;
130+
if(minY > bbox.y){
131+
minY = bbox.y;
140132
}
141-
if(res.w < bbox.width){
142-
res.w = bbox.width;
133+
if(maxX < bbox.x + bbox.width){
134+
maxX = bbox.x + bbox.width;
143135
}
144-
if(res.y < bbox.y){
145-
res.y = bbox.y;
136+
if(maxY < bbox.y + bbox.height){
137+
maxY = bbox.y + bbox.height;
146138
}
147-
if(res.h < bbox.height){
148-
res.h = bbox.height;
149-
}
150-
}
151-
if(res.x == -Infinity){
152-
res.x = 0;
153139
}
154-
if(res.y == -Infinity){
155-
res.y = 0;
156-
}
157-
158-
return res;
140+
return {x: minX, y:minY, w: maxX-minX, h: maxY-minY};
159141
},
160142

161143
refreshRendering: function(){

tests/gauges/SimpleRectangularGauge.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ define(["dojo/_base/lang", "dojo/_base/declare", "dojox/dgauges/RectangularGauge
5656
}),
5757
labelPosition: "trailing",
5858
paddingTop: 15
59+
5960
});
6061
this.addElement("scale", scale);
6162

0 commit comments

Comments
 (0)