(self)
| 263 | self.include_plotlyjs = "cdn" if self.connected else include_plotlyjs |
| 264 | |
| 265 | def activate(self): |
| 266 | if self.global_init: |
| 267 | if not ipython_display: |
| 268 | raise ValueError( |
| 269 | "The {cls} class requires ipython but it is not installed".format( |
| 270 | cls=self.__class__.__name__ |
| 271 | ) |
| 272 | ) |
| 273 | |
| 274 | if self.connected: |
| 275 | script = """\ |
| 276 | <script> |
| 277 | {win_config} |
| 278 | {mathjax_config} |
| 279 | </script> |
| 280 | <script type="module">import \"{plotly_cdn}\"</script> |
| 281 | """.format( |
| 282 | win_config=_window_plotly_config, |
| 283 | mathjax_config=_mathjax_config, |
| 284 | plotly_cdn=plotly_cdn_url().rstrip(".js"), |
| 285 | ) |
| 286 | |
| 287 | else: |
| 288 | # If not connected then we embed a copy of the plotly.js |
| 289 | # library in the notebook |
| 290 | script = """\ |
| 291 | <script> |
| 292 | {win_config} |
| 293 | {mathjax_config} |
| 294 | </script> |
| 295 | <script>{script}</script> |
| 296 | """.format( |
| 297 | script=get_plotlyjs(), |
| 298 | win_config=_window_plotly_config, |
| 299 | mathjax_config=_mathjax_config, |
| 300 | ) |
| 301 | |
| 302 | ipython_display.display_html(script, raw=True) |
| 303 | |
| 304 | def to_mimebundle(self, fig_dict): |
| 305 | from plotly.io import to_html |
nothing calls this directly
no test coverage detected