def wrap_plotly_fig(fig: go.Figure, width: str = '100%', height: str = '100%'): if 'px' in width: fig = fig.to_html(include_plotlyjs=False, full_html=False, default_height=height, default_width=width) return div(raw(fig), style=f'width: {width}') else: fig = fig.to_html(include_plotlyjs=False, full_html=False, default_height=height, default_width='100%') return div(raw(fig), style=f'width: {width}')
def write_plotly_div(af: AnalyticsFunction, figure: go.Figure, filename: Union[str, Path], full_html: Optional[bool] = True, include_plotlyjs: Optional[Union[str, bool]] = True, auto_play: Optional[bool] = False): h = figure.to_html(filename, full_html=full_html, include_plotlyjs=include_plotlyjs, auto_play=auto_play) for f in af.generate_file(filename): f.write(h)
def save_plot_to_file(file: Path, figure: go.Figure): """Create standalone html of the given figure""" with open(file, "w") as f: f.write(figure.to_html(include_plotlyjs="cdn"))