8000 Sanitize orphan subplot logic and 'last trace' deletion by etpinard · Pull Request #268 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Sanitize orphan subplot logic and 'last trace' deletion #268

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

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
lint
  • Loading branch information
etpinard committed Feb 19, 2016
commit f3e1c2b574c673d64311c711d32d7e4a5b457e04
5 changes: 3 additions & 2 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ Plotly.plot = function(gd, data, layout, config) {
function drawData() {
var calcdata = gd.calcdata;

// 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++) {
var trace = calcdata[i][0].trace,
isVisible = (trace.visible === true),
uid = trace.uid;

// in case of traces that were heatmaps or contour maps
// previously, remove them and their colorbars explicitly
if(!isVisible || !Plots.traceIs(trace, '2dMap')) {
fullLayout._paper.selectAll(
'.hm' + uid +
Expand Down Expand Up @@ -489,6 +489,7 @@ function cleanLayout(layout) {
if(!layout.xaxis) layout.xaxis = layout.xaxis1;
delete layout.xaxis1;
}

if(layout.yaxis1) {
if(!layout.yaxis) layout.yaxis = layout.yaxis1;
delete layout.yaxis1;
Expand Down
3 changes: 2 additions & 1 deletion src/plots/cartesian/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
var xaList = xaListCartesian.concat(xaListGl2d).sort(axSort),
yaList = yaListCartesian.concat(yaListGl2d).sort(axSort);

xaList.concat(yaList).forEach(function(axName) {
var axLetter = axName.charAt(0),
axLayoutIn = layoutIn[axName] || {},
axLayoutOut = {},
Expand Down Expand Up @@ -132,7 +133,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {

// so we don't have to repeat autotype unnecessarily,
// copy an autotype back to layoutIn
if(!layoutIn[axName] && axLayoutIn.type!=='-') {
if(!layoutIn[axName] && axLayoutIn.type !== '-') {
layoutIn[axName] = {type: axLayoutIn.type};
}

Expand Down
22 changes: 16 additions & 6 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ plots.getSubplotIds = function getSubplotIds(layout, type) {
return subplotIds;
};

/**
* Get the data traces associated with a particular subplot.
*
* @param {object} layout plotly layout object
* (intended to be _fullLayout, but does not have to be).
* @param {string} type subplot type to look for.
*
* @return {array} array of plotly traces.
*
*/
plots.getSubplotData = function getSubplotData(data, type, subplotId) {
if(plots.subplotsRegistry[type] === undefined) return [];

Expand Down Expand Up @@ -435,12 +445,12 @@ plots.sendDataToCloud = function(gd) {
return false;
};

// fill in default values:
// gd.data, gd.layout:
// are precisely what the user specified
// gd._fullData, gd._fullLayout:
// are complete descriptions of how to draw the plot
plots.supplyDefaults = function(gd) {
// fill in default values:
// gd.data, gd.layout:
// are precisely what the user specified
// gd._fullData, gd._fullLayout:
// are complete descriptions of how to draw the plot
var oldFullLayout = gd._fullLayout || {},
newFullLayout = gd._fullLayout = {},
newLayout = gd.layout || {},
Expand Down Expand Up @@ -722,7 +732,7 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut) {
plots.supplyLayoutModuleDefaults = function(layoutIn, layoutOut, fullData) {
var i, _module;

// TODO incorporate into subplotRegistry
// TODO incorporate into subplotsRegistry
Plotly.Axes.supplyLayoutDefaults(layoutIn, layoutOut, fullData);

// plot module layout defaults
Expand Down
0