-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Introduce global contexts #2159
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
Changes from 8 commits
e6fcbf5
f711cf1
0838c31
348e170
07ea384
1517ece
f7fc8cb
384b577
8346ce4
b8b8951
4efe21e
83b7589
de9b1aa
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 |
---|---|---|
|
@@ -569,15 +569,29 @@ plots.createTransitionData = function(gd) { | |
|
||
// helper function to be bound to fullLayout to check | ||
// whether a certain plot type is present on plot | ||
// or trace has a category | ||
plots._hasPlotType = function(category) { | ||
// check plot | ||
|
||
var basePlotModules = this._basePlotModules || []; | ||
var i; | ||
|
||
for(var i = 0; i < basePlotModules.length; i++) { | ||
for(i = 0; i < basePlotModules.length; i++) { | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. brilliant ✨ |
||
|
||
for(i = 0; i < modules.length; i++) { | ||
var _ = modules[i]; | ||
if(_.categories && _.categories.indexOf(category) >= 0) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
|
@@ -595,6 +609,16 @@ plots.cleanPlot = function(newFullData, newFullLayout, oldFullData, oldFullLayou | |
|
||
var hasPaper = !!oldFullLayout._paper; | ||
var hasInfoLayer = !!oldFullLayout._infolayer; | ||
var hadGl = oldFullLayout._has && oldFullLayout._has('gl'); | ||
var hasGl = newFullLayout._has && newFullLayout._has('gl'); | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. oldFullLayout._glcontainer.selectAll('.gl-canvas').remove() should suffice. |
||
oldFullLayout._glcontainer.remove(); | ||
oldFullLayout._glcanvas = null; | ||
} | ||
} | ||
|
||
oldLoop: | ||
for(i = 0; i < oldFullData.length; i++) { | ||
|
@@ -1308,7 +1332,11 @@ plots.purge = function(gd) { | |
// a new plot, and may have been set outside of our scope. | ||
|
||
var fullLayout = gd._fullLayout || {}; | ||
if(fullLayout._glcontainer !== undefined) fullLayout._glcontainer.remove(); | ||
if(fullLayout._glcontainer !== undefined) { | ||
fullLayout._glcontainer.selectAll('.gl-canvas').data([]).exit().remove(); | ||
fullLayout._glcontainer.remove(); | ||
fullLayout._glcanvas = null; | ||
} | ||
if(fullLayout._geocontainer !== undefined) fullLayout._geocontainer.remove(); | ||
|
||
// remove modebar | ||
|
@@ -1326,6 +1354,9 @@ plots.purge = function(gd) { | |
} | ||
} | ||
|
||
// remove any planned throttles | ||
Lib.clearThrottle(); | ||
|
||
// data and layout | ||
delete gd.data; | ||
delete gd.layout; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ var d3 = require('d3'); | |
var Plots = require('../../plots/plots'); | ||
var parcoordsPlot = require('./plot'); | ||
var xmlnsNamespaces = require('../../constants/xmlns_namespaces'); | ||
var c = require('./constants'); | ||
|
||
exports.name = 'parcoords'; | ||
|
||
|
@@ -28,9 +27,6 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) | |
var hasParcoords = (newFullLayout._has && newFullLayout._has('parcoords')); | ||
|
||
if(hadParcoords && !hasParcoords) { | ||
oldFullLayout._paperdiv.selectAll('.parcoords-line-layers').remove(); | ||
oldFullLayout._paperdiv.selectAll('.parcoords-line-layers').remove(); | ||
oldFullLayout._paperdiv.selectAll('.parcoords').remove(); | ||
oldFullLayout._paperdiv.selectAll('.parcoords').remove(); | ||
oldFullLayout._glimages.selectAll('*').remove(); | ||
} | ||
|
@@ -41,22 +37,20 @@ exports.toSVG = function(gd) { | |
var imageRoot = gd._fullLayout._glimages; | ||
var root = d3.select(gd).selectAll('.svg-container'); | ||
var canvases = root.filter(function(d, i) {return i === root.size() - 1;}) | ||
.selectAll('.parcoords-lines.context, .parcoords-lines.focus'); | ||
.selectAll('.gl-canvas-context, .gl-canvas-focus'); | ||
|
||
function canvasToImage(d) { | ||
function canvasToImage() { | ||
var canvas = this; | ||
var imageData = canvas.toDataURL('image/png'); | ||
var image = imageRoot.append('svg:image'); | ||
var size = gd._fullLayout._size; | ||
var domain = gd._fullData[d.model.key].domain; | ||
|
||
image.attr({ | ||
xmlns: xmlnsNamespaces.svg, | ||
'xlink:href': imageData, | ||
x: size.l + size.w * domain.x[0] - c.overdrag, | ||
y: size.t + size.h * (1 - domain.y[1]), | ||
width: (domain.x[1] - domain.x[0]) * size.w + 2 * c.overdrag, | ||
height: (domain.y[1] - domain.y[0]) * size.h, | ||
x: 0, | ||
y: 0, | ||
width: canvas.width, | ||
height: canvas.height, | ||
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. Lovely cleanup ❤️ |
||
preserveAspectRatio: '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.
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-2fad23de82bf8c7625ea8e11436233b7R290I 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 viaextendFlat
, 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.