Skip to content

Commit

Permalink
Merge pull request #1205 from palantir/release-0.33.1
Browse files Browse the repository at this point in the history
Release 0.33.1 - Layout hotfix (--> master)
  • Loading branch information
jtlan committed Oct 16, 2014
2 parents 56c87ff + 22a8190 commit 7e9b5f7
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 40 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plottable",
"description": "A library for creating charts out of D3",
"version": "0.33.0",
"version": "0.33.1",
"main": ["plottable.js", "plottable.css"],
"license": "MIT",
"ignore": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plottable.js",
"description": "A library for creating charts out of D3",
"version": "0.33.0",
"version": "0.33.1",
"repository": {
"type": "git",
"url": "https://github.com/palantir/plottable.git"
Expand Down
25 changes: 8 additions & 17 deletions plottable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Plottable 0.33.0 (https://github.com/palantir/plottable)
Plottable 0.33.1 (https://github.com/palantir/plottable)
Copyright 2014 Palantir Technologies
Licensed under MIT (https://github.com/palantir/plottable/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -1310,7 +1310,7 @@ var Plottable;
///<reference path="../reference.ts" />
var Plottable;
(function (Plottable) {
Plottable.version = "0.33.0";
Plottable.version = "0.33.1";
})(Plottable || (Plottable = {}));

///<reference path="../reference.ts" />
Expand Down Expand Up @@ -3242,22 +3242,13 @@ var Plottable;
}
this.xOrigin = xOrigin;
this.yOrigin = yOrigin;
var xPosition = this.xOrigin;
var yPosition = this.yOrigin;
var requestedSpace = this._requestedSpace(availableWidth, availableHeight);
xPosition += this._xOffset;
if (this._isFixedWidth()) {
xPosition += (availableWidth - requestedSpace.width) * this._xAlignProportion;
// Decrease size so hitbox / bounding box and children are sized correctly
availableWidth = Math.min(availableWidth, requestedSpace.width);
}
yPosition += this._yOffset;
if (this._isFixedHeight()) {
yPosition += (availableHeight - requestedSpace.height) * this._yAlignProportion;
availableHeight = Math.min(availableHeight, requestedSpace.height);
}
this._width = availableWidth;
this._height = availableHeight;
this._width = this._isFixedWidth() ? Math.min(availableWidth, requestedSpace.width) : availableWidth;
this._height = this._isFixedHeight() ? Math.min(availableHeight, requestedSpace.height) : availableHeight;
var xPosition = this.xOrigin + this._xOffset;
var yPosition = this.yOrigin + this._yOffset;
xPosition += (availableWidth - this.width()) * this._xAlignProportion;
yPosition += (availableHeight - requestedSpace.height) * this._yAlignProportion;
this._element.attr("transform", "translate(" + xPosition + "," + yPosition + ")");
this.boxes.forEach(function (b) { return b.attr("width", _this.width()).attr("height", _this.height()); });
};
Expand Down
4 changes: 2 additions & 2 deletions plottable.min.js

Large diffs are not rendered by default.

Binary file modified plottable.zip
Binary file not shown.
26 changes: 7 additions & 19 deletions src/components/abstractComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,15 @@ export module Component {
}
this.xOrigin = xOrigin;
this.yOrigin = yOrigin;
var xPosition = this.xOrigin;
var yPosition = this.yOrigin;
var requestedSpace = this._requestedSpace(availableWidth, availableHeight);
this._width = this._isFixedWidth() ? Math.min(availableWidth , requestedSpace.width) : availableWidth ;
this._height = this._isFixedHeight() ? Math.min(availableHeight, requestedSpace.height) : availableHeight;

var requestedSpace = this._requestedSpace(availableWidth , availableHeight);
var xPosition = this.xOrigin + this._xOffset;
var yPosition = this.yOrigin + this._yOffset;
xPosition += (availableWidth - this.width()) * this._xAlignProportion;
yPosition += (availableHeight - requestedSpace.height) * this._yAlignProportion;

xPosition += this._xOffset;
if (this._isFixedWidth()) {
xPosition += (availableWidth - requestedSpace.width) * this._xAlignProportion;

// Decrease size so hitbox / bounding box and children are sized correctly
availableWidth = Math.min(availableWidth, requestedSpace.width);
}

yPosition += this._yOffset;
if (this._isFixedHeight()) {
yPosition += (availableHeight - requestedSpace.height) * this._yAlignProportion;
availableHeight = Math.min(availableHeight, requestedSpace.height);
}

this._width = availableWidth;
this._height = availableHeight;
this._element.attr("transform", "translate(" + xPosition + "," + yPosition + ")");
this.boxes.forEach((b: D3.Selection) => b.attr("width", this.width()).attr("height", this.height()));
}
Expand Down
15 changes: 15 additions & 0 deletions test/core/componentTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,19 @@ it("components can be offset relative to their alignment, and throw errors if th

svg.remove();
});

it("Components will not translate if they are fixed width/height and request more space than offered", () => {
// catches #1188
var c: any = new Plottable.Component.AbstractComponent();
c._requestedSpace = () => {return {width: 500, height: 500, wantsWidth: true, wantsHeight: true};};
c._fixedWidthFlag = true;
c._fixedHeightFlag = true;
c.xAlign("left");
var t = new Plottable.Component.Table([[c]]);
t.renderTo(svg);

var transform = d3.transform(c._element.attr("transform"));
assert.deepEqual(transform.translate, [0, 0], "the element was not translated");
svg.remove();
});
});
15 changes: 15 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3912,6 +3912,21 @@ describe("Component behavior", function () {
assertBBoxInclusion(t.boxContainer.select(".bounding-box"), horizontalComponent._element.select(".bounding-box"));
svg.remove();
});
it("Components will not translate if they are fixed width/height and request more space than offered", function () {
// catches #1188
var c = new Plottable.Component.AbstractComponent();
c._requestedSpace = function () {
return { width: 500, height: 500, wantsWidth: true, wantsHeight: true };
};
c._fixedWidthFlag = true;
c._fixedHeightFlag = true;
c.xAlign("left");
var t = new Plottable.Component.Table([[c]]);
t.renderTo(svg);
var transform = d3.transform(c._element.attr("transform"));
assert.deepEqual(transform.translate, [0, 0], "the element was not translated");
svg.remove();
});
});

///<reference path="../testReference.ts" />
Expand Down

0 comments on commit 7e9b5f7

Please sign in to comment.