-
-
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
Introduce global contexts #2159
Conversation
Apparently there are some IE9-related issues with regl. |
src/plot_api/plot_api.js
Outdated
@@ -42,6 +42,8 @@ var enforceAxisConstraints = axisConstraints.enforce; | |||
var cleanAxisConstraints = axisConstraints.clean; | |||
var axisIds = require('../plots/cartesian/axis_ids'); | |||
|
|||
var createRegl = require('regl'); |
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.
Ha. regl
must be invoking one or many globals that IE9 doesn't support at runtime.
As this file here plot_api.js
is required in all partial bundles (even that gl-less ones), this makes the IE9 test fail.
So, I think the best to solve this would be use a Registry.getComponentMethod
-style pattern so that regl
is only required in bundles that expose regl
traces.
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.
@etpinard do I get it right that we don't have this safe-require pattern yet? What if I just require regl directly when the regl
trace type is detected?
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.
What if I just require regl directly when the regl trace type is detected?
You mean something like:
if(fullLayout._has('regl')) {
var createREGL = require('regl')
}
in plot_api.js
? That could work, but regl
would still get bundled up in all partial bundles.
src/plot_api/plot_api.js
Outdated
@@ -2754,7 +2788,7 @@ function makePlotFramework(gd) { | |||
.classed('plotly', true); | |||
|
|||
// Make the svg container | |||
fullLayout._paperdiv = fullLayout._container.selectAll('.svg-container').data([0]); | |||
fullLayout._paperdiv = fullLayout._container.selectAll('.svg-container').data([{}]); |
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.
Why change [0]
to [{}]
?
var _module = basePlotModules[i]; | ||
|
||
if(_module.name === category) return true; | ||
} | ||
|
||
// check trace | ||
var modules = this._modules || []; |
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.
brilliant ✨
x: 0, | ||
y: 0, | ||
width: canvas.width, | ||
height: canvas.height, |
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.
Lovely cleanup ❤️
src/plot_api/plot_api.js
Outdated
@@ -2765,10 +2799,13 @@ function makePlotFramework(gd) { | |||
// TODO: sort out all the ordering so we don't have to | |||
// explicitly delete anything | |||
fullLayout._glcontainer = fullLayout._paperdiv.selectAll('.gl-container') | |||
.data([0]); | |||
.data([{}]); |
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.
what about this one here?
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.
that is the way parcoords
is doing it's thing: https://github.com/plotly/plotly.js/pull/2159/files#diff-2fad23de82bf8c7625ea8e11436233b7R290
I did not really try to figure out why it is done this and not the another way. Before it used own container for storing this data. If that matters, I can try to keep this object within parcoords use.
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.
Does it work ok with data([0])
?
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.
@etpinard that is the point that parcoords puts vm
property there via extendFlat
, that is why it should be an object. Probably it is possible to find a better storage for it, I just did not figure out what.
src/plot_api/plot_api.js
Outdated
key: 'pickLayer', | ||
context: false, | ||
pick: true | ||
}]); |
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.
I think you need a key-function here to make sure to not create these canvas nodes on every hard redraw that go through drawFramework
.
Sometime like:
fullLayout._glcanvas = fullLayout._glcontainer.selectAll('.gl-canvas').data([{
/* .. as currently ... */
}], function(d) { return d.key; });
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.
This makes me wonder: we probably don't have sufficient test coverage for Plotly.restyle
calls that morph a gl-based trace types into a SVG-based. For example off the regl2d branch we should have:
Plotly.newPlot(gd, [{
type: 'scattergl',
// ...
}])
.then(function() {
d3.selectAll('canvas').size() // => 3
return Plotly.restyle(gd, 'type', 'scatter')
})
.then(function() {
d3.selectAll('canvas').size() // => 0
})
As restyling a parcoords
traces into any other trace types doesn't make much sense at the moment. You could instead try something like:
Plotly.newPlot(gd, [{
type: 'parcoords',
// ...
}])
.then(function() {
d3.selectAll('canvas').size() // => 3
return Plotly.deleteTraces(gd, [0])
})
.then(function() {
d3.selectAll('canvas').size() // => 0
})
src/plots/plots.js
Outdated
|
||
if(hadGl && !hasGl) { | ||
if(oldFullLayout._glcontainer !== undefined) { | ||
oldFullLayout._glcontainer.selectAll('.gl-canvas').data([]).exit().remove(); |
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.
oldFullLayout._glcontainer.selectAll('.gl-canvas').remove()
should suffice.
@dfcreative Good news the parcoords tests are passing again Bad news other Can you try making |
@etpinard fixed these four noCI tests, seems that others (mapbox ones) are not related to this PR but are specific to my machine. |
Yeah, those mapbox tests are pretty resource-intensive; that doesn't surprise me. Hopefully #2029 will fix those issues. Great PR. Merge away 💃 |
Excerpt from #1869.
Covers #1993 and #1989.