Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add to/from/read/write json functions to the plotly.io module #1188

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

Merged
jonmmease merged 6 commits into master from enh_io_json
Sep 21, 2018

Conversation

@jonmmease
Copy link
Contributor

@jonmmease jonmmease commented Sep 19, 2018

This PR introduces 4 new functions to the plotly.io module for converting figures to and from JSON strings and files.

These functions follow the plotly.io module conventions described in #1098

Pending bug fixes in jupyterlab/jupyter-renderers#159, the JSON files written by plotly.io.write_json will be compatible with the @jupyterlab/plotly-extension JupyterLab extension. This means it will be possible to create a figure in plotly.py, write it to a fig.plotly.json file, then double click the file in JupyterLab to view the figure right inside JupyterLab.

PlatonB reacted with hooray emoji
Copy link
Contributor Author

Note: failures seem to be due to npmjs being down: https://twitter.com/npmstatus/status/1042543988274692096

@jonmmease jonmmease added this to the v3.3.0 milestone Sep 20, 2018
This was referenced Sep 20, 2018
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,
Copy link
Contributor Author

@jonmmease jonmmease Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing quote character

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
Copy link
Contributor Author

@jonmmease jonmmease Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Contributor Author

@jonmmease jonmmease Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline

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
Copy link
Contributor Author

@jonmmease jonmmease Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update description as above

else:
from mock import MagicMock
from backports import tempfile

Copy link
Contributor Author

@jonmmease jonmmease Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline

@jonmmease jonmmease merged commit f727c46 into master Sep 21, 2018
# ----------------
if remove_uids:
for trace in fig_dict.get('data', []):
trace.pop('uid')
Copy link

@JavascriptMick JavascriptMick Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one of my traces was a Heatmap... which does not have a pop method

Copy link
Contributor Author

@jonmmease jonmmease Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

@JavascriptMick JavascriptMick Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up using validate=False and remove_uids=False

@nicolaskruchten nicolaskruchten deleted the enh_io_json branch June 19, 2020 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@JavascriptMick JavascriptMick JavascriptMick left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

v3.3.0

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /