-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add registry of component modules #845
Conversation
- this will help free Plots of some circular dependencies - make sure the ref back Registry contents in Plots for backward compatibility
by: - requiring svgTextUtils in plot_api.js - moving a injected modules in to src/core.js - requiring some module directly in src/core.js instead of through src/plotly.js
- legend, annotations, shapes, images, rangeslider, rangeselector and updatemenus are now registerd in src/core.js - add 'moduleType' and 'name' properties to component modules - rename 'attributes' prop -> 'layoutAttributes' (for consistency) - rename 'supplyLayoutDefaults' -> 'handleDefaults' when component defaults are required in another default module
- so that they are called only when the range slider/selector components are registered
Legend.draw(gd); | ||
RangeSelector.draw(gd); | ||
UpdateMenus.draw(gd); | ||
Registry.getComponentMethod('legend', 'draw')(gd); |
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.
Unlike traces and plot modules, we can't simply loop over them in a given plot
step. Some components may require two draw calls per plot call, some component may not. Some components may have a calc step, some components may not etc.
So instead, we use a getter method to the component method on-demand. Note that if a given component isn't register, Registry.getComponentMethod()
will return a noop
.
@@ -498,6 +493,10 @@ module.exports = { | |||
].join(' ') | |||
}, | |||
|
|||
_nestedModules: { |
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.
this tells Plotly.PlotSchema.get
to look for the attributes in the component registry.
Okey dokes. After the conflicts are all bueno and lil change to the |
This PR introduces a new registry, this one for component modules. For those keeping track, we now have registries for trace, plot (aka subplot aka base plot), transform and component modules.
This new component registry, will allow us to remove (some, maybe all?) component modules from the core plotly.js module for 🍃 custom builds in
v2.0.0
.Internally, this PR
Plotly.register
out ofsrc/plotly.js
and intosrc/plot_api/register.js
side-by-side with itsPlotly
method friendssrc/plots/plots.js
and intosrc/registry.js
. This newregistry.js
module only depends onLib
and one attribute file which allow us to 🔪 a lot of circular dependenciesRegister.getComponentMethod
used to access method of registered component modules without having to require the module themselves.