Skip to content

Commit f0994bb

Browse files
Filmbostock
andauthored
clip: true clips the mark to the frame (#752)
* clip: true clips the mark to the frame closes #165 related: #181 * reindex clip id * Update src/style.js Co-authored-by: Mike Bostock <[email protected]> * Update src/style.js Co-authored-by: Mike Bostock <[email protected]> * data source (the actual notebook is broken atm) * clippath => clip * reformat horizon plot; nicer heuristic for color * naming consistency * tweak horizon example (#753) * tweak horizon example * use offset, not index * nicer tick labels Co-authored-by: Mike Bostock <[email protected]>
1 parent 1f264f4 commit f0994bb

22 files changed

+6922
-22
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ All marks support the following optional channels:
647647
* **title** - a tooltip (a string of text, possibly with newlines)
648648
* **href** - a URL to link to
649649
* **ariaLabel** - a short label representing the value in the accessibility tree
650+
* **clip** - if true, the mark is clipped to the frame’s dimensions
650651

651652
The **fill**, **fillOpacity**, **stroke**, **strokeWidth**, **strokeOpacity**, and **opacity** options can be specified as either channels or constants. When the fill or stroke is specified as a function or array, it is interpreted as a channel; when the fill or stroke is specified as a string, it is interpreted as a constant if a valid CSS color and otherwise it is interpreted as a column name for a channel. Similarly when the fill opacity, stroke opacity, object opacity, stroke width, or radius is specified as a number, it is interpreted as a constant; otherwise it is interpreted as a channel.
652653

src/marks/area.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export class Area extends Mark {
3030
);
3131
this.curve = Curve(curve, tension);
3232
}
33-
render(I, {x, y}, channels) {
33+
render(I, {x, y}, channels, dimensions) {
3434
const {x1: X1, y1: Y1, x2: X2 = X1, y2: Y2 = Y1, z: Z} = channels;
3535
const {dx, dy} = this;
3636
return create("svg:g")
37-
.call(applyIndirectStyles, this)
37+
.call(applyIndirectStyles, this, dimensions)
3838
.call(applyTransform, x, y, dx, dy)
3939
.call(g => g.selectAll()
4040
.data(Z ? group(I, i => Z[i]).values() : [I])

src/marks/arrow.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Arrow extends Mark {
4444
this.insetStart = +insetStart;
4545
this.insetEnd = +insetEnd;
4646
}
47-
render(index, {x, y}, channels) {
47+
render(index, {x, y}, channels, dimensions) {
4848
const {x1: X1, y1: Y1, x2: X2 = X1, y2: Y2 = Y1, SW} = channels;
4949
const {dx, dy, strokeWidth, bend, headAngle, headLength, insetStart, insetEnd} = this;
5050
const sw = SW ? i => SW[i] : () => strokeWidth;
@@ -65,7 +65,7 @@ export class Arrow extends Mark {
6565
const wingScale = headLength / 1.5;
6666

6767
return create("svg:g")
68-
.call(applyIndirectStyles, this)
68+
.call(applyIndirectStyles, this, dimensions)
6969
.call(applyTransform, x, y, offset + dx, offset + dy)
7070
.call(g => g.selectAll()
7171
.data(index)

src/marks/bar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class AbstractBar extends Mark {
2121
render(index, scales, channels, dimensions) {
2222
const {dx, dy, rx, ry} = this;
2323
return create("svg:g")
24-
.call(applyIndirectStyles, this)
24+
.call(applyIndirectStyles, this, dimensions)
2525
.call(this._transform, scales, dx, dy)
2626
.call(g => g.selectAll()
2727
.data(index)

src/marks/dot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class Dot extends Mark {
5454
const [cx, cy] = applyFrameAnchor(this, dimensions);
5555
const circle = this.symbol === symbolCircle;
5656
return create("svg:g")
57-
.call(applyIndirectStyles, this)
57+
.call(applyIndirectStyles, this, dimensions)
5858
.call(applyTransform, x, y, offset + dx, offset + dy)
5959
.call(g => g.selectAll()
6060
.data(index)

src/marks/frame.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Frame extends Mark {
2828
const {marginTop, marginRight, marginBottom, marginLeft, width, height} = dimensions;
2929
const {insetTop, insetRight, insetBottom, insetLeft, dx, dy} = this;
3030
return create("svg:rect")
31-
.call(applyIndirectStyles, this)
31+
.call(applyIndirectStyles, this, dimensions)
3232
.call(applyDirectStyles, this)
3333
.call(applyTransform, null, null, offset + dx, offset + dy)
3434
.attr("x", marginLeft + insetLeft)

src/marks/image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class Image extends Mark {
6464
const {dx, dy} = this;
6565
const [cx, cy] = applyFrameAnchor(this, dimensions);
6666
return create("svg:g")
67-
.call(applyIndirectStyles, this)
67+
.call(applyIndirectStyles, this, dimensions)
6868
.call(applyTransform, x, y, offset + dx, offset + dy)
6969
.call(g => g.selectAll()
7070
.data(index)

src/marks/line.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ export class Line extends Mark {
3030
this.curve = Curve(curve, tension);
3131
markers(this, options);
3232
}
33-
render(I, {x, y}, channels) {
33+
render(I, {x, y}, channels, dimensions) {
3434
const {x: X, y: Y, z: Z} = channels;
3535
const {dx, dy} = this;
3636
return create("svg:g")
37-
.call(applyIndirectStyles, this)
37+
.call(applyIndirectStyles, this, dimensions)
3838
.call(applyTransform, x, y, offset + dx, offset + dy)
3939
.call(g => g.selectAll()
4040
.data(Z ? group(I, i => Z[i]).values() : [I])

src/marks/link.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export class Link extends Mark {
2828
this.curve = Curve(curve, tension);
2929
markers(this, options);
3030
}
31-
render(index, {x, y}, channels) {
31+
render(index, {x, y}, channels, dimensions) {
3232
const {x1: X1, y1: Y1, x2: X2 = X1, y2: Y2 = Y1} = channels;
3333
const {dx, dy, curve} = this;
3434
return create("svg:g")
35-
.call(applyIndirectStyles, this)
35+
.call(applyIndirectStyles, this, dimensions)
3636
.call(applyTransform, x, y, offset + dx, offset + dy)
3737
.call(g => g.selectAll()
3838
.data(index)

src/marks/rect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class Rect extends Mark {
4949
const {marginTop, marginRight, marginBottom, marginLeft, width, height} = dimensions;
5050
const {insetTop, insetRight, insetBottom, insetLeft, dx, dy, rx, ry} = this;
5151
return create("svg:g")
52-
.call(applyIndirectStyles, this)
52+
.call(applyIndirectStyles, this, dimensions)
5353
.call(applyTransform, x, y, dx, dy)
5454
.call(g => g.selectAll()
5555
.data(index)

0 commit comments

Comments
 (0)