Skip to content

Commit

Permalink
Merge pull request #1324 from palantir/release-v0.36.1
Browse files Browse the repository at this point in the history
Release v0.36.1 (--> master)
  • Loading branch information
jtlan committed Nov 12, 2014
2 parents c5384e1 + f81348d commit 8368d45
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 14 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.36.0",
"version": "0.36.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.36.0",
"version": "0.36.1",
"repository": {
"type": "git",
"url": "https://github.com/palantir/plottable.git"
Expand Down
1 change: 1 addition & 0 deletions plottable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3208,6 +3208,7 @@ declare module Plottable {
_updateYDomainer(): void;
_onDatasetUpdate(): void;
_generateAttrToProjector(): AttributeToProjector;
_wholeDatumAttributes(): string[];
}
}
}
Expand Down
17 changes: 12 additions & 5 deletions plottable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Plottable 0.36.0 (https://github.com/palantir/plottable)
Plottable 0.36.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 @@ -1405,7 +1405,7 @@ var Plottable;
///<reference path="../reference.ts" />
var Plottable;
(function (Plottable) {
Plottable.version = "0.36.0";
Plottable.version = "0.36.1";
})(Plottable || (Plottable = {}));

///<reference path="../reference.ts" />
Expand Down Expand Up @@ -7993,14 +7993,21 @@ var Plottable;
StackedArea.prototype._generateAttrToProjector = function () {
var _this = this;
var attrToProjector = _super.prototype._generateAttrToProjector.call(this);
var wholeDatumAttributes = this._wholeDatumAttributes();
var isSingleDatumAttr = function (attr) { return wholeDatumAttributes.indexOf(attr) === -1; };
var singleDatumAttributes = d3.keys(attrToProjector).filter(isSingleDatumAttr);
singleDatumAttributes.forEach(function (attribute) {
var projector = attrToProjector[attribute];
attrToProjector[attribute] = function (data, i) { return data.length > 0 ? projector(data[0], i) : null; };
});
var yAccessor = this._projectors["y"].accessor;
attrToProjector["y"] = function (d) { return _this._yScale.scale(+yAccessor(d) + d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]); };
attrToProjector["y0"] = function (d) { return _this._yScale.scale(d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]); };
// Align fill with first index
var fillProjector = attrToProjector["fill"];
attrToProjector["fill"] = function (d, i) { return (d && d[0]) ? fillProjector(d[0], i) : null; };
return attrToProjector;
};
StackedArea.prototype._wholeDatumAttributes = function () {
return ["x", "y", "defined"];
};
return StackedArea;
})(Plot.AbstractStacked);
Plot.StackedArea = StackedArea;
Expand Down
6 changes: 3 additions & 3 deletions plottable.min.js

Large diffs are not rendered by default.

Binary file modified plottable.zip
Binary file not shown.
16 changes: 12 additions & 4 deletions src/components/plots/stackedAreaPlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,24 @@ export module Plot {

public _generateAttrToProjector() {
var attrToProjector = super._generateAttrToProjector();
var wholeDatumAttributes = this._wholeDatumAttributes();
var isSingleDatumAttr = (attr: string) => wholeDatumAttributes.indexOf(attr) === -1;
var singleDatumAttributes = d3.keys(attrToProjector).filter(isSingleDatumAttr);
singleDatumAttributes.forEach((attribute: string) => {
var projector = attrToProjector[attribute];
attrToProjector[attribute] = (data: any[], i: number) => data.length > 0 ? projector(data[0], i) : null;
});

var yAccessor = this._projectors["y"].accessor;
attrToProjector["y"] = (d: any) => this._yScale.scale(+yAccessor(d) + d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]);
attrToProjector["y0"] = (d: any) => this._yScale.scale(d["_PLOTTABLE_PROTECTED_FIELD_STACK_OFFSET"]);

// Align fill with first index
var fillProjector = attrToProjector["fill"];
attrToProjector["fill"] = (d, i) => (d && d[0]) ? fillProjector(d[0], i) : null;

return attrToProjector;
}

public _wholeDatumAttributes() {
return ["x", "y", "defined"];
}
}
}
}
11 changes: 11 additions & 0 deletions test/components/plots/stackedAreaPlotTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,5 +348,16 @@ describe("Plots", () => {
svg.remove();
});

it("project works correctly", () => {
renderer.project("check", "type");
var areas = renderer._renderArea.selectAll(".area");
var area0 = d3.select(areas[0][0]);
assert.strictEqual(area0.attr("check"), "a", "projector has been applied to first area");

var area1 = d3.select(areas[0][1]);
assert.strictEqual(area1.attr("check"), "b", "projector has been applied to second area");
svg.remove();
});

});
});
9 changes: 9 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3506,6 +3506,15 @@ describe("Plots", function () {
assert.strictEqual(4, domain[1], "highest area stacking is at upper limit of yScale domain");
svg.remove();
});
it("project works correctly", function () {
renderer.project("check", "type");
var areas = renderer._renderArea.selectAll(".area");
var area0 = d3.select(areas[0][0]);
assert.strictEqual(area0.attr("check"), "a", "projector has been applied to first area");
var area1 = d3.select(areas[0][1]);
assert.strictEqual(area1.attr("check"), "b", "projector has been applied to second area");
svg.remove();
});
});
});

Expand Down

0 comments on commit 8368d45

Please sign in to comment.