Skip to content

Commit 7249153

Browse files
committed
stack helpers
1 parent f6ef585 commit 7249153

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export {Line, line, lineX, lineY} from "./marks/line.js";
1111
export {Link, link} from "./marks/link.js";
1212
export {Rect, rect, rectX, rectY} from "./marks/rect.js";
1313
export {RuleX, RuleY, ruleX, ruleY} from "./marks/rule.js";
14+
export {stackAreaX, stackAreaY, stackBarX, stackBarY} from "./marks/stack.js";
1415
export {Text, text, textX, textY} from "./marks/text.js";
1516
export {TickX, TickY, tickX, tickY} from "./marks/tick.js";
1617
export {bin1, bin2} from "./transforms/bin.js";

src/marks/stack.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {stackX, stackY} from "../transforms/stack.js";
2+
import {areaX, areaY} from "./area.js";
3+
import {barX, barY} from "./bar.js";
4+
5+
export function stackAreaX(data, options) {
6+
return areaX(...stackX(data, options));
7+
}
8+
9+
export function stackAreaY(data, options) {
10+
return areaY(...stackY(data, options));
11+
}
12+
13+
export function stackBarX(data, options) {
14+
return barX(...stackX(data, options));
15+
}
16+
17+
export function stackBarY(data, options) {
18+
return barY(...stackY(data, options));
19+
}

test/plots/industry-unemployment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default async function() {
88
grid: true
99
},
1010
marks: [
11-
Plot.areaY(...Plot.stackY(data, {x: "date", y: "unemployed", fill: "industry"})),
11+
Plot.stackAreaY(data, {x: "date", y: "unemployed", fill: "industry"}),
1212
Plot.ruleY([0])
1313
]
1414
});

0 commit comments

Comments
 (0)