-
-
Notifications
You must be signed in to change notification settings - Fork 144
Remove graph config innards from defaultProps #515
Conversation
and add missing config items to propTypes
Took the liberty of fixing the format check https://github.com/plotly/dash-core-components/pull/515/files/d4df7ccef95fffb0274e992700b0d45ca85631ba..071b11cbdd67989c16a384c343d638a91eebf7c4 |
The renderer also uses the graph for a few tests, nothing deep, but might be worth taking some time to create a renderer branch pointing to this dcc branch to increase sanity/coverage. |
@@ -557,7 +557,7 @@ const graphPropTypes = { | |||
* Extra resolution to give the file after | |||
* rendering it with the given width and height | |||
*/ | |||
scale: PropTypes.number | |||
scale: PropTypes.number, |
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 thanks. I had done that locally but hadn't pushed it yet as I'm adding a couple of tests.
also remove an old plotly.js bundle
@@ -1193,7 +1193,7 @@ def on_click(n_clicks): | |||
def check_plotlyjs(self): | |||
# find plotly.js files in the dist folder, check that there's only one | |||
all_dist = os.listdir(dcc.__path__[0]) | |||
js_re = '^plotly-(.*)\.min\.js$' | |||
js_re = r'^plotly-(.*)\.min\.js$' |
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.
oddly I can't get this error to appear locally... 😐
) | ||
with open(os.path.join(dcc.__path__[0], 'metadata.json')) as meta: | ||
graph_meta = json.load(meta)['src/components/Graph.react.js'] | ||
config_prop_shape = graph_meta['props']['config']['type']['value'] |
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.
kind of ugly to have to use metadata.json
for this... I was hoping I could get this directly from the Graph
component, but PropTypes
seems to turn everything into a validation function, I don't see a way to get the input params back out.
if item_name in ignored_config: | ||
continue | ||
|
||
self.assertIn(item_name, props) |
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.
Currently not testing anything about the props, just that the right keys exist. We could enhance this later to verify that their types match what's in the schema. Note that we could have put back in the deep defaults and used a similar framework to test that they match the schema, but I don't think that's a good idea. We'd still have the problem of a single override dropping the defaults - in principle picking up the right defaults again from plotly.js, but there could be subtle problems with this, or perhaps a user overrides the plotly.js version... I'd rather keep the looser coupling.
js_re = r'^plotly-(.*)\.min\.js$' | ||
plotlyjs_dist = [fn for fn in all_dist if re.match(js_re, fn)] | ||
|
||
self.assertEqual(len(plotlyjs_dist), 1) |
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 don't know how we ended up with 2 copies of plotly.js on master, 1.44.1 and 1.45.0... the associated PRs all seem to swap one file for another, maybe a mis-merge somewhere. But anyway this test will prevent that in the future.
src/components/Graph.react.js
Outdated
/** | ||
* add the plotly logo on the end of the mode bar | ||
*/ | ||
displaylogo: PropTypes.bool, | ||
|
||
/** | ||
* add the plotly logo even with no modebar |
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.
* add the plotly logo even with no modebar | |
* Add the plotly logo even with no modebar |
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 right, a lot of the older docstrings didn't bother capitalizing so I tried to follow that, but then some of the newer ones do... I should just go through and capitalize them all. Thanks for pointing this out.
src/components/Graph.react.js
Outdated
@@ -491,6 +501,13 @@ const graphPropTypes = { | |||
*/ | |||
displayModeBar: PropTypes.oneOf([true, false, 'hover']), | |||
|
|||
/** | |||
* should we include a modebar button to send this data to a |
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.
* should we include a modebar button to send this data to a | |
* Should we include a modebar button to send this data to a |
src/components/Graph.react.js
Outdated
@@ -374,6 +374,11 @@ const graphPropTypes = { | |||
*/ | |||
staticPlot: PropTypes.bool, | |||
|
|||
/** | |||
* base URL for a Plotly cloud instance, if `showSendToCloud` is enabled |
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.
* base URL for a Plotly cloud instance, if `showSendToCloud` is enabled | |
* Base URL for a Plotly cloud instance, if `showSendToCloud` is enabled |
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 looks fine to me 💃 Nice test!
Addresses most of #514 - doesn't include a test (yet?), but removes the config innards and adds the missing pieces to
propTypes
.