-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Replace _has<PlotType> variables with '_has()' fullLayout method #491
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 25 commits
88f552a
525e3c7
876ce4b
f45ffec
4e0c6da
93493a6
e63ba4a
b655cb0
f476e05
1c41c2e
313150e
392619c
3787d47
68b12c4
a41427c
a48d071
a78521c
aa2ec8b
77fb7e2
a141d78
dc297ca
e3f72f0
c59a960
9f94494
9837d8b
0c7b2f8
5e6759b
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 |
---|---|---|
|
@@ -335,6 +335,23 @@ lib.noneOrAll = function(containerIn, containerOut, attrList) { | |
} | ||
}; | ||
|
||
/** | ||
* Fill with unique items | ||
* | ||
* @param {array} array | ||
* array to be filled | ||
* @param {any} item | ||
* item to be or not to be inserted | ||
* @return {array} | ||
* ref to array (now possibly containing one more item) | ||
* | ||
*/ | ||
lib.fillUnique = function(array, item) { | ||
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. Maybe inconsequential, but what do you think of In my head, 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. Or perhaps 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. +1 |
||
if(item && array.indexOf(item) === -1) array.push(item); | ||
|
||
return array; | ||
}; | ||
|
||
lib.mergeArray = function(traceAttr, cd, cdAttr) { | ||
if(Array.isArray(traceAttr)) { | ||
var imax = Math.min(traceAttr.length, cd.length); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,7 +205,7 @@ Plotly.plot = function(gd, data, layout, config) { | |
if(!recalc) return; | ||
|
||
var subplots = Plots.getSubplotIds(fullLayout, 'cartesian'), | ||
modules = gd._modules; | ||
modules = fullLayout._modules; | ||
|
||
// position and range calculations for traces that | ||
// depend on each other ie bars (stacked or grouped) | ||
|
@@ -250,11 +250,12 @@ Plotly.plot = function(gd, data, layout, config) { | |
|
||
// Now plot the data | ||
function drawData() { | ||
var calcdata = gd.calcdata; | ||
var calcdata = gd.calcdata, | ||
i; | ||
|
||
// in case of traces that were heatmaps or contour maps | ||
// previously, remove them and their colorbars explicitly | ||
for(var i = 0; i < calcdata.length; i++) { | ||
for(i = 0; i < calcdata.length; i++) { | ||
var trace = calcdata[i][0].trace, | ||
isVisible = (trace.visible === true), | ||
uid = trace.uid; | ||
|
@@ -272,18 +273,11 @@ Plotly.plot = function(gd, data, layout, config) { | |
} | ||
} | ||
|
||
var plotRegistry = Plots.subplotsRegistry; | ||
|
||
if(fullLayout._hasGL3D) plotRegistry.gl3d.plot(gd); | ||
if(fullLayout._hasGeo) plotRegistry.geo.plot(gd); | ||
if(fullLayout._hasGL2D) plotRegistry.gl2d.plot(gd); | ||
if(fullLayout._hasCartesian || fullLayout._hasPie) { | ||
plotRegistry.cartesian.plot(gd); | ||
// loop over the base plot modules present on graph | ||
var basePlotModules = fullLayout._basePlotModules; | ||
for(i = 0; i < basePlotModules.length; i++) { | ||
basePlotModules[i].plot(gd); | ||
} | ||
if(fullLayout._hasTernary) plotRegistry.ternary.plot(gd); | ||
|
||
// clean up old scenes that no longer have associated data | ||
// will this be a performance hit? | ||
|
||
// styling separate from drawing | ||
Plots.style(gd); | ||
|
@@ -1660,10 +1654,12 @@ Plotly.restyle = function restyle(gd, astr, val, traces) { | |
axlist, | ||
flagAxForDelete = {}; | ||
|
||
// for now, if we detect gl or geo stuff, just re-do the plot | ||
if(fullLayout._hasGL3D || fullLayout._hasGeo || fullLayout._hasGL2D) { | ||
doplot = true; | ||
} | ||
// At the moment, only cartesian, pie and ternary plot types can afford | ||
// to not go through a full replot | ||
var doPlotWhiteList = ['cartesian', 'pie', 'ternary']; | ||
fullLayout._basePlotModules.forEach(function(_module) { | ||
if(doPlotWhiteList.indexOf(_module.name) === -1) doplot = true; | ||
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. In if(fullLayout._hasGL3D || fullLayout._hasGeo || fullLayout._hasGL2D) doplot = true; in an effort to support custom |
||
}); | ||
|
||
// make a new empty vals array for undoit | ||
function a0() { return traces.map(function() { return undefined; }); } | ||
|
@@ -2308,7 +2304,7 @@ Plotly.relayout = function relayout(gd, astr, val) { | |
if(p.parts[0].indexOf('scene') === 0) doplot = true; | ||
else if(p.parts[0].indexOf('geo') === 0) doplot = true; | ||
else if(p.parts[0].indexOf('ternary') === 0) doplot = true; | ||
else if(fullLayout._hasGL2D && | ||
else if(fullLayout._has('gl2d') && | ||
(ai.indexOf('axis') !== -1 || p.parts[0] === 'plot_bgcolor') | ||
) doplot = true; | ||
else if(ai === 'hiddenlabels') docalc = true; | ||
|
@@ -2581,9 +2577,6 @@ function makePlotFramework(gd) { | |
var gd3 = d3.select(gd), | ||
fullLayout = gd._fullLayout; | ||
|
||
// TODO - find a better place for 3D to initialize axes | ||
if(fullLayout._hasGL3D) Plots.subplotsRegistry.gl3d.initAxes(gd); | ||
|
||
// Plot container | ||
fullLayout._container = gd3.selectAll('.plot-container').data([0]); | ||
fullLayout._container.enter().insert('div', ':first-child') | ||
|
@@ -2658,7 +2651,7 @@ function makePlotFramework(gd) { | |
makeSubplots(gd, subplots); | ||
} | ||
|
||
if(fullLayout._hasCartesian) makeCartesianPlotFramwork(gd, subplots); | ||
if(fullLayout._has('cartesian')) makeCartesianPlotFramwork(gd, subplots); | ||
|
||
// single ternary layer for the whole plot | ||
fullLayout._ternarylayer = fullLayout._paper.append('g').classed('ternarylayer', 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.
The
!!
shouldn't be necessary here anymore, correct?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.
correct. nice catch.