Renderer to display figures using the plotly mime type. This renderer is compatible with VSCode and nteract. mime type: 'application/vnd.plotly.v1+json'
| 73 | |
| 74 | # Plotly mimetype |
| 75 | class PlotlyRenderer(MimetypeRenderer): |
| 76 | """ |
| 77 | Renderer to display figures using the plotly mime type. This renderer is |
| 78 | compatible with VSCode and nteract. |
| 79 | |
| 80 | mime type: 'application/vnd.plotly.v1+json' |
| 81 | """ |
| 82 | |
| 83 | def __init__(self, config=None): |
| 84 | self.config = dict(config) if config else {} |
| 85 | |
| 86 | def to_mimebundle(self, fig_dict): |
| 87 | config = _get_jconfig(self.config) |
| 88 | if config: |
| 89 | fig_dict["config"] = config |
| 90 | |
| 91 | json_compatible_fig_dict = json.loads( |
| 92 | to_json(fig_dict, validate=False, remove_uids=False) |
| 93 | ) |
| 94 | |
| 95 | return {"application/vnd.plotly.v1+json": json_compatible_fig_dict} |
| 96 | |
| 97 | |
| 98 | # Static Image |