MCPcopy Index your code
hub / github.com/plotly/plotly.py / to_mimebundle

Method to_mimebundle

plotly/io/_base_renderers.py:511–566  ·  view source on GitHub ↗
(self, fig_dict)

Source from the content-addressed store, hash-verified

509 self.html_directory = html_directory
510
511 def to_mimebundle(self, fig_dict):
512 from plotly.io import write_html
513
514 # Make iframe size slightly larger than figure size to avoid
515 # having iframe have its own scroll bar.
516 iframe_buffer = 20
517 layout = fig_dict.get("layout", {})
518
519 if layout.get("width", False):
520 iframe_width = str(layout["width"] + iframe_buffer) + "px"
521 else:
522 iframe_width = "100%"
523
524 if layout.get("height", False):
525 iframe_height = layout["height"] + iframe_buffer
526 else:
527 iframe_height = str(525 + iframe_buffer) + "px"
528
529 # Build filename using ipython cell number
530 filename = self.build_filename()
531
532 # Make directory for
533 try:
534 os.makedirs(self.html_directory)
535 except OSError:
536 if not isdir(self.html_directory):
537 raise
538
539 write_html(
540 fig_dict,
541 filename,
542 config=self.config,
543 auto_play=self.auto_play,
544 include_plotlyjs=self.include_plotlyjs,
545 include_mathjax="cdn",
546 auto_open=False,
547 post_script=self.post_script,
548 animation_opts=self.animation_opts,
549 default_width="100%",
550 default_height=525,
551 validate=False,
552 )
553
554 # Build IFrame
555 iframe_html = """\
556<iframe
557 scrolling="no"
558 width="{width}"
559 height="{height}"
560 src="{src}"
561 frameborder="0"
562 allowfullscreen
563></iframe>
564""".format(width=iframe_width, height=iframe_height, src=self.build_url(filename))
565
566 return {"text/html": iframe_html}
567
568 def build_filename(self):

Callers

nothing calls this directly

Calls 5

build_filenameMethod · 0.95
build_urlMethod · 0.95
write_htmlFunction · 0.90
getMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected