-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[take 2] Implement scatter cliponaxis: false
#1861
Changes from 8 commits
c28b26a
8f72d1f
1909034
4b5c4bb
d46cae7
7228d5d
fe1f889
89ee533
e4d7889
091473b
9becb7c
62ab845
0496144
7b62b73
02b9fbc
1c85de6
e44aa4d
e84701f
e234827
6f494c6
bbb31f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,8 +69,8 @@ drawing.setRect = function(s, x, y, w, h) { | |
*/ | ||
drawing.translatePoint = function(d, sel, xa, ya) { | ||
// put xp and yp into d if pixel scaling is already done | ||
var x = d.xp || xa.c2p(d.x), | ||
y = d.yp || ya.c2p(d.y); | ||
var x = d.xp = xa.c2p(d.x); | ||
var y = d.yp = ya.c2p(d.y); | ||
|
||
if(isNumeric(x) && isNumeric(y) && sel.node()) { | ||
// for multiline text this works better | ||
|
@@ -86,10 +86,28 @@ drawing.translatePoint = function(d, sel, xa, ya) { | |
return true; | ||
}; | ||
|
||
drawing.translatePoints = function(s, xa, ya, trace) { | ||
drawing.translatePoints = function(s, xa, ya) { | ||
s.each(function(d) { | ||
var sel = d3.select(this); | ||
drawing.translatePoint(d, sel, xa, ya, trace); | ||
drawing.translatePoint(d, sel, xa, ya); | ||
}); | ||
}; | ||
|
||
drawing.hideOutsideRangePoint = function(d, sel, xa, ya) { | ||
sel.attr( | ||
'visibility', | ||
xa.isPtWithinRange(d) && ya.isPtWithinRange(d) ? null : 'hidden' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. possibly better to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Would be nice to benchmark these things, but you make a good argument for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in 9becb7c |
||
); | ||
}; | ||
|
||
drawing.hideOutsideRangePoints = function(points, subplot) { | ||
if(!subplot._hasClipOnAxisFalse) return; | ||
|
||
var xa = subplot.xaxis; | ||
var ya = subplot.yaxis; | ||
|
||
points.each(function(d) { | ||
drawing.hideOutsideRangePoint(d, d3.select(this), xa, ya); | ||
}); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,14 @@ | |
var d3 = require('d3'); | ||
var isNumeric = require('fast-isnumeric'); | ||
|
||
var Drawing = require('../drawing'); | ||
var subTypes = require('../../traces/scatter/subtypes'); | ||
|
||
module.exports = function plot(traces, plotinfo, transitionOpts) { | ||
var isNew; | ||
|
||
var xa = plotinfo.xaxis, | ||
ya = plotinfo.yaxis; | ||
var xa = plotinfo.xaxis; | ||
var ya = plotinfo.yaxis; | ||
|
||
var hasAnimation = transitionOpts && transitionOpts.duration > 0; | ||
|
||
|
@@ -60,6 +61,11 @@ module.exports = function plot(traces, plotinfo, transitionOpts) { | |
.style('opacity', 1); | ||
} | ||
|
||
errorbars.call( | ||
Drawing.setClipUrl, | ||
plotinfo._hasClipOnAxisFalse ? plotinfo.clipId : null | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps it would simplify things if when we calculate Also a debatable style point, I've started avoiding |
||
|
||
errorbars.each(function(d) { | ||
var errorbar = d3.select(this); | ||
var coords = errorCoords(d, xa, ya); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,24 +294,8 @@ function makeSubplotData(gd) { | |
} | ||
|
||
function makeSubplotLayer(plotinfo) { | ||
var plotgroup = plotinfo.plotgroup, | ||
id = plotinfo.id; | ||
|
||
// Layers to keep plot types in the right order. | ||
// from back to front: | ||
// 1. heatmaps, 2D histos and contour maps | ||
// 2. bars / 1D histos | ||
// 3. errorbars for bars and scatter | ||
// 4. scatter | ||
// 5. box plots | ||
function joinPlotLayers(parent) { | ||
joinLayer(parent, 'g', 'imagelayer'); | ||
joinLayer(parent, 'g', 'maplayer'); | ||
joinLayer(parent, 'g', 'barlayer'); | ||
joinLayer(parent, 'g', 'carpetlayer'); | ||
joinLayer(parent, 'g', 'boxlayer'); | ||
joinLayer(parent, 'g', 'scatterlayer'); | ||
} | ||
var plotgroup = plotinfo.plotgroup; | ||
var id = plotinfo.id; | ||
|
||
if(!plotinfo.mainplot) { | ||
var backLayer = joinLayer(plotgroup, 'g', 'layer-subplot'); | ||
|
@@ -354,7 +338,10 @@ function makeSubplotLayer(plotinfo) { | |
} | ||
|
||
// common attributes for all subplots, overlays or not | ||
plotinfo.plot.call(joinPlotLayers); | ||
|
||
for(var i = 0; i < constants.layers.length; i++) { | ||
joinLayer(plotinfo.plot, 'g', constants.layers[i]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
} | ||
|
||
plotinfo.xlines | ||
.style('fill', 'none') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow,
||
is 4 years old there... but it doesn't look to me like.xp
and.yp
are used anywhere except https://github.com/plotly/plotly.js/blob/master/src/traces/scatter/plot.js#L489 which is a near copy of this routine. Take it out? Must have been a perf optimization that we did long ago but is now mostly gone.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 62ab845