Skip to content

Commit c2c3dac

Browse files
committed
zero-dimensional rules
1 parent 1e9c866 commit c2c3dac

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/marks/rule.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class RuleX extends Mark {
2121
super(
2222
data,
2323
[
24-
{name: "x", value: x, scale: "x"},
24+
{name: "x", value: x, scale: "x", optional: true},
2525
{name: "y1", value: y1, scale: "y", optional: true},
2626
{name: "y2", value: y2, scale: "y", optional: true},
2727
{name: "z", value: z, optional: true},
@@ -36,7 +36,7 @@ export class RuleX extends Mark {
3636
I,
3737
{x, y, color},
3838
{x: X, y1: Y1, y2: Y2, z: Z, title: L, stroke: S},
39-
{marginTop, height, marginBottom}
39+
{width, height, marginTop, marginRight, marginLeft, marginBottom}
4040
) {
4141
const index = filter(I, X, Y1, Y2, S);
4242
if (Z) index.sort((i, j) => ascending(Z[i], Z[j]));
@@ -47,8 +47,8 @@ export class RuleX extends Mark {
4747
.data(index)
4848
.join("line")
4949
.call(applyDirectStyles, this)
50-
.attr("x1", i => Math.round(x(X[i])))
51-
.attr("x2", i => Math.round(x(X[i])))
50+
.attr("x1", X ? i => Math.round(x(X[i])) : (marginLeft + width - marginRight) / 2)
51+
.attr("x2", X ? i => Math.round(x(X[i])) : (marginLeft + width - marginRight) / 2)
5252
.attr("y1", Y1 ? i => y(Y1[i]) : marginTop)
5353
.attr("y2", Y2 ? (y.bandwidth ? i => y(Y2[i]) + y.bandwidth() : i => y(Y2[i])) : height - marginBottom)
5454
.attr("stroke", S && (i => color(S[i])))
@@ -74,7 +74,7 @@ export class RuleY extends Mark {
7474
super(
7575
data,
7676
[
77-
{name: "y", value: y, scale: "y"},
77+
{name: "y", value: y, scale: "y", optional: true},
7878
{name: "x1", value: x1, scale: "x", optional: true},
7979
{name: "x2", value: x2, scale: "x", optional: true},
8080
{name: "z", value: z, optional: true},
@@ -89,7 +89,7 @@ export class RuleY extends Mark {
8989
I,
9090
{x, y, color},
9191
{y: Y, x1: X1, x2: X2, z: Z, title: L, stroke: S},
92-
{width, marginLeft, marginRight}
92+
{width, height, marginTop, marginRight, marginLeft, marginBottom}
9393
) {
9494
const index = filter(I, Y, X1, X2);
9595
if (Z) index.sort((i, j) => ascending(Z[i], Z[j]));
@@ -102,8 +102,8 @@ export class RuleY extends Mark {
102102
.call(applyDirectStyles, this)
103103
.attr("x1", X1 ? i => x(X1[i]) : marginLeft)
104104
.attr("x2", X2 ? (x.bandwidth ? i => x(X2[i]) + x.bandwidth() : i => x(X2[i])) : width - marginRight)
105-
.attr("y1", i => Math.round(y(Y[i])))
106-
.attr("y2", i => Math.round(y(Y[i])))
105+
.attr("y1", Y ? i => Math.round(y(Y[i])) : (marginTop + height - marginBottom) / 2)
106+
.attr("y2", Y ? i => Math.round(y(Y[i])) : (marginTop + height - marginBottom) / 2)
107107
.attr("stroke", S && (i => color(S[i])))
108108
.call(title(L)))
109109
.node();

0 commit comments

Comments
 (0)