Skip to content

Commit f7adfd1

Browse files
committed
Remove height and width from charts rendered without JavaScript
1 parent 2a49e7f commit f7adfd1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

report/surveyhero/render.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ def normalize_arg(key, value) -> Tuple[str, Any]:
5656
args = args.split(",")
5757
args = dict(normalize_arg(*tuple(arg.split("="))) for arg in args if arg.strip())
5858

59-
height = args.get("height", 600)
60-
6159
# Render the chart as PNG and SVG
6260
png_filename = render_png(image_dir=image_dir, renderer=chart, chart_id=chart_id)
6361

@@ -90,10 +88,13 @@ def normalize_arg(key, value) -> Tuple[str, Any]:
9088
).div
9189
div = element.find("div")
9290
div["class"] = chart_type
91+
92+
# The style makes the chart have weird dimensions when JavaScript is disabled
93+
del div["style"]
9394
div.append(
9495
BeautifulSoup(
9596
f"""<noscript>
96-
<img src="{png_filename}" height="{height}" alt="{chart_id}" />
97+
<img src="{png_filename}" alt="{chart_id}" />
9798
</noscript>""",
9899
"html.parser",
99100
)

0 commit comments

Comments
 (0)