Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
Next Next commit
plots: expose list of data / layout array containers
- to be used in relayout / restyle
  • Loading branch information
etpinard committed Oct 26, 2016
commit 133bf1af1ee38e42f82097f790c5c01d981c5b39
13 changes: 5 additions & 8 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,9 @@ plots.extendObjectWithContainers = function(dest, src, containerPaths) {
return dest;
};

plots.dataArrayContainers = ['transforms'];
plots.layoutArrayContainers = ['annotations', 'shapes', 'images', 'sliders', 'updatemenus'];

/*
* Extend a trace definition. This method:
*
Expand All @@ -1433,7 +1436,7 @@ plots.extendObjectWithContainers = function(dest, src, containerPaths) {
* The result is the original object reference with the new contents merged in.
*/
plots.extendTrace = function(destTrace, srcTrace) {
return plots.extendObjectWithContainers(destTrace, srcTrace, ['transforms']);
return plots.extendObjectWithContainers(destTrace, srcTrace, plots.dataArrayContainers);
};

/*
Expand All @@ -1446,13 +1449,7 @@ plots.extendTrace = function(destTrace, srcTrace) {
* The result is the original object reference with the new contents merged in.
*/
plots.extendLayout = function(destLayout, srcLayout) {
return plots.extendObjectWithContainers(destLayout, srcLayout, [
'annotations',
'shapes',
'images',
'sliders',
'updatemenus'
]);
return plots.extendObjectWithContainers(destLayout, srcLayout, plots.layoutArrayContainers);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it. Nice refactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I thought exposing plots.layoutArrayContainers was a nice compromise.

Next step would be to auto-generate that list using the plot-schema. (later ...)

};

/**
Expand Down