Skip to content

Commit 2f0d77b

Browse files
author
Mark Gibbs
committed
Made iframe in template be responsive
1 parent b1478e3 commit 2f0d77b

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

demo/demo/templates/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
{%load plotly_dash%}
44
<title>Simple stuff</title>
55
<body>
6-
<div>
6+
<div width="300">
77
Content here
88
{%plotly_item "simpleexample-1"%}
99
</div>
1010
<div>
1111
Content here
1212
{%plotly_item "SimpleExample"%}
1313
</div>
14-
<div>
14+
<div width="800">
1515
Content here
1616
{%plotly_item "Ex2"%}
1717
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<div>
2-
<iframe src="{{app.base_url}}"></iframe>
1+
<div style="{{dstyle}}">
2+
<iframe src="{{app.base_url}}" style="{{istyle}}"frameborder="{{fbs}}"></iframe>
33
</div>

django_plotly_dash/templatetags/dexy.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

django_plotly_dash/templatetags/plotly_dash.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,24 @@
55
from django_plotly_dash.models import DashApp
66

77
@register.inclusion_tag("django_plotly_dash/plotly_item.html", takes_context=True)
8-
def plotly_item(context, app_name):
8+
def plotly_item(context, app_name, ratio=0.1, use_frameborder=False):
9+
10+
fbs = use_frameborder and '1' or '0'
11+
12+
dstyle = """
13+
position: relative;
14+
padding-bottom: %s%%;
15+
height: 0;
16+
overflow:hidden;
17+
""" % (ratio*100)
18+
19+
istyle = """
20+
position: absolute;
21+
top: 0;
22+
left: 0;
23+
width: 100%;
24+
height: 100%;
25+
"""
926

1027
app = DashApp.get_app_instance(app_name)
1128

0 commit comments

Comments
 (0)