-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Subplot registration #193
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
Subplot registration #193
Changes from all commits
77a5464
b0ff48c
ba8cbab
970abc2
f1d4490
aa8db38
1007c8a
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 |
---|---|---|
|
@@ -41,7 +41,7 @@ plots.fontWeight = 'normal'; | |
*/ | ||
plots.register = function(_module, thisType, categoriesIn, meta) { | ||
if(modules[thisType]) { | ||
console.warn('type ' + thisType + ' already registered'); | ||
console.log('type ' + thisType + ' already registered'); | ||
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. Bringing in @bpostlethwaite and @alexcjohnson Should we warn (or spit out a console.log) when users register the same plot module twice? I'd vote for doing nothing at all. @mdtusz If I'm no mistaken, every time a user registers two or more trace modules that rely on the same plot module e.g. var PlotlyBar = require('plotly.js/lib/bar');
var PlotlyBox = require('plotly.js/lib/box');
Plotly.register([PlotlyBar, PlotlyBox]); would split out a log. 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. Fyi I switched log --> warn out of (perhaps bad) habit, from when I had a project that needed to support ie8 😦 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. Oh boy. No way plotly.js works in ie8 |
||
return; | ||
} | ||
|
||
|
@@ -132,32 +132,12 @@ plots.registerSubplot = function(_module) { | |
var plotType = _module.name; | ||
|
||
if(subplotsRegistry[plotType]) { | ||
throw new Error('plot type' + plotType + ' already registered'); | ||
} | ||
|
||
var attr = _module.attr, | ||
idRoot = _module.idRoot; | ||
|
||
var regexStart = '^', | ||
regexEnd = '([2-9]|[1-9][0-9]+)?$', | ||
hasXY = (plotType === 'cartesian' || subplotsRegistry === 'gl2d'); | ||
|
||
function makeRegex(mid) { | ||
return new RegExp(regexStart + mid + regexEnd); | ||
console.log('plot type ' + plotType + ' already registered'); | ||
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. Ooops the above comment (https://github.com/plotly/plotly.js/pull/193/files#r50156440) was supposed to be placed here. 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. It would, but there's a check in the |
||
return; | ||
} | ||
|
||
// not sure what's best for the 'cartesian' type at this point | ||
subplotsRegistry[plotType] = _module; | ||
|
||
// register the regex representing the set of all valid attribute names | ||
subplotsRegistry[plotType].attrRegex = hasXY ? | ||
{ x: makeRegex(attr[0]), y: makeRegex(attr[1]) } : | ||
makeRegex(attr); | ||
|
||
// register the regex representing the set of all valid attribute ids | ||
subplotsRegistry[plotType].idRegex = hasXY ? | ||
{ x: makeRegex(idRoot[0]), y: makeRegex(idRoot[1]) } : | ||
makeRegex(idRoot); | ||
}; | ||
|
||
// TODO separate the 'find subplot' step (which looks in layout) | ||
|
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 right here, we make the check to see if the plot was registered.
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.
haha. Nice!