-
-
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
Refactor PlotSchema #1144
Refactor PlotSchema #1144
Conversation
- instead require attribute module into trace attribute modules directly.
- that abstraction was mostly obsolete - the only remaining 'composed-module' was Fx, simply merge its attribute into base layout attributes.
- remove _nestedModule and _composedModule handlers - find module attribute from registry (as opposed to the internal Plotly object and other obsolete methods) - add layoutNodes to better handler rangeslider and rangeselector
- and lower the max circular dep limit
- (now that this doesn't cause circular deps anymore)
- instead of simply removing the trailing 's' of the container name
- instead of relying on a hard-coded list
Commit e9f679a is a little hard to read. I'd recommend reviewing |
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.
Approving since I have no specific requirements for changes, but I think it would be nice to very briefly document a few of the parts that touch things fairly close to the surface, in particular the attribute flags and what sort of effect they have.
@@ -15,7 +15,7 @@ var extendFlat = require('../../lib/extend').extendFlat; | |||
|
|||
|
|||
module.exports = { | |||
_isLinkedToArray: true, | |||
_isLinkedToArray: 'annotation', |
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.
I've never been able to figure out quite what _isLinkedToArray
actually does. It seems to remove the key and trigger some sort of crawl with a key of length - 1 which seems like the sort of thing that would de-pluralize, but this is just a guess.
Perhaps it's a way of defining, for example, button
attrs but using a buttons
container?
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.
I've never been able to figure out quite what _isLinkedToArray
It's essentially the plot schema version of Plots.layoutArrayContainers
. With this PR, both are now united.
Giving a name to the items in the array container is (again) only relevant for plotly.py
at the moment. Previously, the item names were simply the container name minus the 's
'. This PR make item naming more robust / flexible.
@@ -105,7 +105,7 @@ function assertCircularDeps() { | |||
// as of v1.17.0 - 2016/09/08 | |||
// see https://github.com/plotly/plotly.js/milestone/9 | |||
// for more details | |||
var MAX_ALLOWED_CIRCULAR_DEPS = 34; | |||
var MAX_ALLOWED_CIRCULAR_DEPS = 17; |
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.
🎉
var IS_SUBPLOT_OBJ = '_isSubplotObj'; | ||
var IS_LINKED_TO_ARRAY = '_isLinkedToArray'; | ||
var DEPRECATED = '_deprecated'; | ||
var UNDERSCORE_ATTRS = [IS_SUBPLOT_OBJ, IS_LINKED_TO_ARRAY, DEPRECATED]; |
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.
Is it possible to document what these do, perhaps here? A general frustration regarding attribute definitions is that I make up things like role
or underscored attributes based on copying from similar examples, but I don't really have any idea what they mean or do. In particular:
_deprecated
seems like mainly just an annotation. Do the docs use this in deciding how to display things?_isLinkedToArray
seems to have something to do with pluralization and containers, but I haven't figured out what it means beyond that._isSubplotObj
: Seems like an annotation, perhaps used elsewhere? I can't find that it actually does anything, at least within plotly.js.role
: Not underscored, but in a similar boat.data_array
seems to be important for extracting data out of the json.style
affects theming in different environments, if I recall correctly. Do the other options likeinfo_array
have any effect? I usually write it because it seems friendly to include, but I don't know if it means anything.
There's probably very little be gained in documenting the internals, but attribute definitions seem like a common thing that people without deep knowledge of the internals probably end up touching pretty regularly, so it might be nice to communicate the meaning somewhere.
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.
_deprecated
These are simply deprecated keys that don't show up on https://plot.ly/javascript/reference/ and friends, but that plotly.py (still) considers valid.
_isLinkedToArray
See #1144 (comment)
_isSubplotObj
Subplot layout containers e.g. layout.xaxis
, layout.scene
can be input as layout.xaxis2
or layout.scene10
, Plotly.validate
and plotly.py need to know about that.
role
Has no effect in plotly.js (yet). At the moment, it is only used for plotly.py's strip style method which removes all role: 'style'
keys from a given figure.
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.
Ah, my mistake. data_array
is a valType
, not a role. Which affects streambed parsing, I think.
This PR significantly refactor
PlotSchema.get()
in an effort to reduce the level of (hard-coded) abstractions required to built the schema and to make it play better for custom modules.In brief,
_nestedModules
and_composedModules
attribute abstractions are gonePlotly.registry
now buildsPlots.layoutArrayContainer
automatically cc @rreusserframes
and animation attributes toPlotly.PlotSchema.get()
outputrangeslider
andrangeselector
where listed as available underlayout.yaxis
Annotations