Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Center implied position.

Previously, if both positional properties on a given dimension (e.g., left and
right) were undefined, the left and top properties were implicitly 0. Thus, the
implicit default position was the top-left corner of the panel. Now the center
of the panel is used instead. For example, now wedges can be added to panels
without needing to center them explicitly.
  • Loading branch information...
commit 49a16e37181723121cab4a41f251772d2b1403d0 1 parent 1c7334d
@mbostock mbostock authored
View
12 src/mark/Mark.js
@@ -1021,7 +1021,11 @@ pv.Mark.prototype.buildImplied = function(s) {
if (w == null) {
w = width - (r = r || 0) - (l = l || 0);
} else if (r == null) {
- r = width - w - (l = l || 0);
+ if (l == null) {
+ l = r = (width - w) / 2;
+ } else {
+ r = width - w - (l = l || 0);
+ }
} else if (l == null) {
l = width - w - (r = r || 0);
}
@@ -1031,7 +1035,11 @@ pv.Mark.prototype.buildImplied = function(s) {
if (h == null) {
h = height - (t = t || 0) - (b = b || 0);
} else if (b == null) {
- b = height - h - (t = t || 0);
+ if (t == null) {
+ b = t = (height - h) / 2;
+ } else {
+ b = height - h - (t = t || 0);
+ }
} else if (t == null) {
t = height - h - (b = b || 0);
}
View
2  tests/behavior/point-wedge.html
@@ -22,8 +22,6 @@
var wedge = vis.add(pv.Wedge)
.data(data)
- .bottom(w / 2)
- .left(w / 2)
.innerRadius(r - t)
.outerRadius(r)
.angle(a)
View
2  tests/mark/transition-wedge.html
@@ -26,8 +26,6 @@
a.domain(0, pv.sum(data));
return data;
})
- .bottom(w / 2)
- .left(w / 2)
.innerRadius(r - t)
.outerRadius(r)
.angle(a)
View
2  tests/mark/wedge-donut.html
@@ -19,8 +19,6 @@
vis.add(pv.Wedge)
.data(data)
- .bottom(w / 2)
- .left(w / 2)
.innerRadius(r - t)
.outerRadius(r)
.angle(a)
View
2  tests/mark/wedge-implied.html
@@ -13,8 +13,6 @@
vis.add(pv.Wedge)
.data(pv.range(10))
- .bottom(200)
- .left(200)
.innerRadius(function(d) (d + 2) * 15)
.outerRadius(function(d) (d + 3) * 15)
.startAngle(function(d) Math.PI / 2 + d / 10 * Math.PI)
View
2  tests/mark/wedge-pie.html
@@ -18,8 +18,6 @@
vis.add(pv.Wedge)
.data(data)
- .bottom(w / 2)
- .left(w / 2)
.outerRadius(r)
.angle(a)
.title(function(d) d)
View
2  tests/mark/wedge-ring.html
@@ -16,8 +16,6 @@
.height(h);
vis.add(pv.Wedge)
- .bottom(w / 2)
- .left(w / 2)
.innerRadius(r - t)
.outerRadius(r)
.angle(2 * Math.PI);
Please sign in to comment.
Something went wrong with that request. Please try again.