Skip to content

Commit 3d0d16c

Browse files
committed
filter common styles
1 parent d20d5a9 commit 3d0d16c

File tree

8 files changed

+19
-18
lines changed

8 files changed

+19
-18
lines changed

src/marks/bar.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ export class AbstractBar extends Mark {
1919
}
2020
render(I, scales, channels, dimensions) {
2121
const {rx, ry} = this;
22-
const {fill: F, fillOpacity: FO, stroke: S, strokeOpacity: SO} = channels;
23-
const index = filter(I, ...this._positions(channels), F, FO, S, SO); // TODO filter standard channels
22+
const index = filter(I, ...this._positions(channels));
2423
return create("svg:g")
2524
.call(applyIndirectStyles, this)
2625
.call(this._transform, scales)

src/marks/dot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export class Dot extends Mark {
3131
channels,
3232
{width, height, marginTop, marginRight, marginBottom, marginLeft}
3333
) {
34-
const {x: X, y: Y, r: R, fill: F, fillOpacity: FO, stroke: S, strokeOpacity: SO} = channels;
35-
let index = filter(I, X, Y, F, FO, S, SO); // TODO filter standard channels
34+
const {x: X, y: Y, r: R} = channels;
35+
let index = filter(I, X, Y);
3636
if (R) index = index.filter(i => positive(R[i]));
3737
return create("svg:g")
3838
.call(applyIndirectStyles, this)

src/marks/link.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export class Link extends Mark {
3030
{x, y},
3131
channels
3232
) {
33-
const {x1: X1, y1: Y1, x2: X2 = X1, y2: Y2 = Y1, stroke: S, strokeOpacity: SO} = channels;
34-
const index = filter(I, X1, Y1, X2, Y2, S, SO); // TODO filter standard channels
33+
const {x1: X1, y1: Y1, x2: X2 = X1, y2: Y2 = Y1} = channels;
34+
const index = filter(I, X1, Y1, X2, Y2);
3535
return create("svg:g")
3636
.call(applyIndirectStyles, this)
3737
.call(applyTransform, x, y, 0.5, 0.5)

src/marks/rect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export class Rect extends Mark {
4040
this.ry = impliedString(ry, "auto");
4141
}
4242
render(I, {x, y}, channels) {
43-
const {x1: X1, y1: Y1, x2: X2, y2: Y2, fill: F, fillOpacity: FO, stroke: S, strokeOpacity: SO} = channels;
43+
const {x1: X1, y1: Y1, x2: X2, y2: Y2} = channels;
4444
const {rx, ry} = this;
45-
const index = filter(I, X1, Y2, X2, Y2, F, FO, S, SO); // TODO filter standard channels
45+
const index = filter(I, X1, Y2, X2, Y2);
4646
return create("svg:g")
4747
.call(applyIndirectStyles, this)
4848
.call(applyTransform, x, y)

src/marks/rule.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export class RuleX extends Mark {
3737
channels,
3838
{width, height, marginTop, marginRight, marginLeft, marginBottom}
3939
) {
40-
const {x: X, y1: Y1, y2: Y2, stroke: S, strokeOpacity: SO} = channels;
41-
const index = filter(I, X, Y1, Y2, S, SO); // TODO filter standard channels
40+
const {x: X, y1: Y1, y2: Y2} = channels;
41+
const index = filter(I, X, Y1, Y2);
4242
return create("svg:g")
4343
.call(applyIndirectStyles, this)
4444
.call(applyTransform, X && x, null, 0.5, 0)
@@ -84,8 +84,8 @@ export class RuleY extends Mark {
8484
channels,
8585
{width, height, marginTop, marginRight, marginLeft, marginBottom}
8686
) {
87-
const {y: Y, x1: X1, x2: X2, stroke: S, strokeOpacity: SO} = channels;
88-
const index = filter(I, Y, X1, X2, S, SO); // TODO filter standard channels
87+
const {y: Y, x1: X1, x2: X2} = channels;
88+
const index = filter(I, Y, X1, X2);
8989
return create("svg:g")
9090
.call(applyIndirectStyles, this)
9191
.call(applyTransform, null, Y && y, 0, 0.5)

src/marks/text.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ export class Text extends Mark {
5353
channels,
5454
{width, height, marginTop, marginRight, marginBottom, marginLeft}
5555
) {
56-
const {x: X, y: Y, rotate: R, text: T, fill: F, fillOpacity: FO, fontSize: FS} = channels;
56+
const {x: X, y: Y, rotate: R, text: T, fontSize: FS} = channels;
5757
const {rotate} = this;
58-
const index = filter(I, X, Y, F, FO, R).filter(i => nonempty(T[i])); // TODO filter standard channels
58+
const index = filter(I, X, Y, R).filter(i => nonempty(T[i]));
5959
const cx = (marginLeft + width - marginRight) / 2;
6060
const cy = (marginTop + height - marginBottom) / 2;
6161
return create("svg:g")

src/marks/tick.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class AbstractTick extends Mark {
1313
super(data, channels, options, defaults);
1414
}
1515
render(I, scales, channels, dimensions) {
16-
const {x: X, y: Y, stroke: S, strokeOpacity: SO} = channels;
17-
const index = filter(I, X, Y, S, SO); // TODO filter standard channels
16+
const {x: X, y: Y} = channels;
17+
const index = filter(I, X, Y);
1818
return create("svg:g")
1919
.call(applyIndirectStyles, this)
2020
.call(this._transform, scales)

src/plot.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {create} from "d3";
22
import {Axes, autoAxisTicks, autoAxisLabels} from "./axes.js";
3+
import {filter} from "./defined.js";
34
import {facets} from "./facet.js";
45
import {values} from "./mark.js";
56
import {Scales, autoScaleRange} from "./scales.js";
@@ -83,8 +84,9 @@ export function plot(options = {}) {
8384

8485
for (const mark of marks) {
8586
const channels = markChannels.get(mark);
86-
const index = markIndex.get(mark);
87-
const node = mark.render(index, scales, values(channels, scales), dimensions, axes);
87+
const scaled = values(channels, scales);
88+
const index = filter(markIndex.get(mark), scaled.fill, scaled.fillOpacity, scaled.stroke, scaled.strokeOpacity);
89+
const node = mark.render(index, scales, scaled, dimensions, axes);
8890
if (node != null) svg.appendChild(node);
8991
}
9092

0 commit comments

Comments
 (0)