Add to/from/read/write json functions to the plotly.io module#1188
Merged
Add to/from/read/write json functions to the plotly.io module#1188
Conversation
Contributor
Author
|
Note: failures seem to be due to npmjs being down: https://twitter.com/npmstatus/status/1042543988274692096 |
This was referenced Sep 20, 2018
Closed
jonmmease
commented
Sep 21, 2018
plotly/io/_json.py
Outdated
| String containing the JSON representation of a figure | ||
| output_type: type or str (default 'Figure') | ||
| The output figure type or type name. | ||
| One of: graph_objs.Figure, 'Figure, |
Contributor
Author
There was a problem hiding this comment.
missing quote character
plotly/io/_json.py
Outdated
| One of: graph_objs.Figure, 'Figure, | ||
| graph_objs.FigureWidget, 'FigureWidget' | ||
| skip_invalid: bool (default False) | ||
| False if invalid figure properties should result in an exception |
Contributor
Author
There was a problem hiding this comment.
and "True if invalid figure properties should be silently ignored."
| output_type: type or str (default 'Figure') | ||
| The output figure type or type name. | ||
| One of: graph_objs.Figure, 'Figure, | ||
| graph_objs.FigureWidget, 'FigureWidget' |
plotly/io/_json.py
Outdated
| One of: graph_objs.Figure, 'Figure, | ||
| graph_objs.FigureWidget, 'FigureWidget' | ||
| skip_invalid: bool (default False) | ||
| False if invalid figure properties should result in an exception |
Contributor
Author
There was a problem hiding this comment.
Update description as above
| else: | ||
| from mock import MagicMock | ||
| from backports import tempfile | ||
|
|
| # ---------------- | ||
| if remove_uids: | ||
| for trace in fig_dict.get('data', []): | ||
| trace.pop('uid') |
There was a problem hiding this comment.
one of my traces was a Heatmap... which does not have a pop method
Contributor
Author
There was a problem hiding this comment.
Hmm, did you set validate=False? If not, then validate_coerce_fig_to_dict() should have made sure that the traces were converted into dicts.
There was a problem hiding this comment.
I ended up using validate=False and remove_uids=False
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces 4 new functions to the
plotly.iomodule for converting figures to and from JSON strings and files.These functions follow the
plotly.iomodule conventions described in #1098Pending bug fixes in jupyterlab/jupyter-renderers#159, the JSON files written by
plotly.io.write_jsonwill be compatible with the@jupyterlab/plotly-extensionJupyterLab extension. This means it will be possible to create a figure in plotly.py, write it to afig.plotly.jsonfile, then double click the file in JupyterLab to view the figure right inside JupyterLab.