-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for div id as 1st arg to Plotly.makeTemplate
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -24,13 +24,14 @@ var dfltConfig = require('./plot_config'); | |||||||||||||||||||||||||||||||||||||
* Note: separated from the rest of templates because otherwise we get circular | ||||||||||||||||||||||||||||||||||||||
* references due to PlotSchema. | ||||||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||||||
* @param {object|DOM element} figure: The figure to base the template on | ||||||||||||||||||||||||||||||||||||||
* @param {object|DOM element|string} figure: The figure to base the template on | ||||||||||||||||||||||||||||||||||||||
* should contain a trace array `figure.data` | ||||||||||||||||||||||||||||||||||||||
* and a layout object `figure.layout` | ||||||||||||||||||||||||||||||||||||||
* @returns {object} template: the extracted template - can then be used as | ||||||||||||||||||||||||||||||||||||||
* `layout.template` in another figure. | ||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||
exports.makeTemplate = function(figure) { | ||||||||||||||||||||||||||||||||||||||
figure = Lib.isPlainObject(figure) ? figure : Lib.getGraphDiv(figure); | ||||||||||||||||||||||||||||||||||||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
etpinard
Author
Contributor
|
module.exports = function(gd) { | |
var gdElement; | |
if(typeof gd === 'string') { | |
gdElement = document.getElementById(gd); | |
if(gdElement === null) { | |
throw new Error('No DOM element with id \'' + gd + '\' exists on the page.'); | |
} | |
return gdElement; | |
} | |
else if(gd === null || gd === undefined) { | |
throw new Error('DOM element provided is null or undefined'); | |
} | |
return gd; // otherwise assume that gd is a DOM element | |
}; |
What do you think?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Is there any character that should be disqualified e.g. space, empty string, quotation, semicolon, etc.?