Skip to content

Plot Area: Plot clip bug #490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 28, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2887,23 +2887,28 @@ function lsInner(gd) {
.call(Color.fill, fullLayout.plot_bgcolor);
}


// Clip so that data only shows up on the plot area.
var clips = fullLayout._defs.selectAll('g.clips'),
clipId = 'clip' + fullLayout._uid + subplot + 'plot';

clips.selectAll('#' + clipId)
.data([0])
.enter().append('clipPath')
var plotClip = clips.selectAll('#' + clipId)
.data([0]);

plotClip.enter().append('clipPath')
.attr({
'class': 'plotclip',
'id': clipId
})
.append('rect')
.append('rect');

plotClip.selectAll('rect')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done. Man, I gotta got better at noticing these as a reviewer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gotta get better at noticing these as a programmer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But really, I think it's just a symptom of the "d3 pattern". It's not explicitly clear and pretty tough to reason about what exactly each selection/block is doing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like d3 v4 will make this easier.

Taken from https://medium.com/@mbostock/what-makes-software-good-943557f8a488#.rb39u8abk

image

.attr({
'width': xa._length,
'height': ya._length
});


plotinfo.plot.attr({
'transform': 'translate(' + xa._offset + ', ' + ya._offset + ')',
'clip-path': 'url(#' + clipId + ')'
Expand Down