Skip to content

Commit bcdabb0

Browse files
committed
🐛 Fix(quarto_reportview.py): correct sizes for interactive plots on quarto reports. Closes #68
1 parent 8a2193f commit bcdabb0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,5 @@ docs/images/UML_diagrams/
128128
docs/images/Graphical_abstract/
129129
docs/images/Nfcore_module_figure
130130
docs/presentations/
131-
./basic_example_vuegen_demo_notebook_config.yaml
132-
./earth_microbiome_vuegen_demo_notebook_config.yaml
131+
basic_example_vuegen_demo_notebook_config.yaml
132+
earth_microbiome_vuegen_demo_notebook_config.yaml

src/vuegen/quarto_reportview.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def _generate_plot_content(self, plot) -> List[str]:
569569
try:
570570
if plot.plot_type == r.PlotType.STATIC:
571571
plot_content.append(
572-
self._generate_image_content(plot.file_path, width="95%")
572+
self._generate_image_content(plot.file_path, width="90%")
573573
)
574574
elif plot.plot_type == r.PlotType.PLOTLY:
575575
plot_content.append(self._generate_plot_code(plot))
@@ -671,13 +671,13 @@ def _generate_plot_code(self, plot, output_file="") -> str:
671671
plot_json_str = json.dumps(plot_json)\n
672672
# Create the plotly plot
673673
fig_plotly = pio.from_json(plot_json_str)
674-
fig_plotly.update_layout(width=950, height=500)\n"""
674+
fig_plotly.update_layout(autosize=False, width=950, height=400, margin=dict(b=50, t=50, l=50, r=50))\n"""
675675
elif plot.plot_type == r.PlotType.ALTAIR:
676676
plot_code += """
677677
# Convert JSON to string
678678
plot_json_str = json.dumps(plot_json)\n
679679
# Create the plotly plot
680-
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=400)\n"""
680+
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)\n"""
681681
elif plot.plot_type == r.PlotType.INTERACTIVE_NETWORK:
682682
# Generate the HTML embedding for interactive networks
683683
if is_url(plot.file_path) and plot.file_path.endswith(".html"):
@@ -886,7 +886,7 @@ def _generate_html_content(self, html) -> List[str]:
886886
html_file_path = get_relative_file_path(html.file_path, base_path="..")
887887
iframe_code = f"""
888888
<div style="text-align: center;">
889-
<iframe src="{html_file_path.as_posix()}" alt="{html.title}" width="800px" height="630px"></iframe>
889+
<iframe src="{html_file_path.as_posix()}" alt="{html.title}" width="950px" height="530px"></iframe>
890890
</div>\n"""
891891
html_content.append(iframe_code)
892892

@@ -902,7 +902,7 @@ def _generate_html_content(self, html) -> List[str]:
902902
return html_content
903903

904904
def _generate_image_content(
905-
self, image_path: str, alt_text: str = "", width: str = "95%"
905+
self, image_path: str, alt_text: str = "", width: str = "90%"
906906
) -> str:
907907
"""
908908
Adds an image to the content list in an HTML format with a specified width and height.

0 commit comments

Comments
 (0)