Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8a0b27e

Browse files
delsimdelsim
and
delsim
authored
Add absolute height option to template tag (#499)
* Add preamble to file * Add height parameter to template tag * Update mantine component example * Update version number --------- Co-authored-by: delsim <dev@gibbsconsulting.ca>
1 parent 986ad13 commit 8a0b27e

File tree

6 files changed

+43
-13
lines changed

6 files changed

+43
-13
lines changed

‎demo/demo/dash_apps.py‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
'''Dash demonstration application
22
3-
TODO attribution here
3+
Copyright (c) 2018 Gibbs Consulting and others - see CONTRIBUTIONS.md
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
422
'''
523

624
# The linter doesn't like the members of the html and dcc imports (as they are dynamic?)

‎demo/demo/mantine_example.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
mantine_example = DjangoDash("MantineExample")
3232

3333

34-
mantine_example.layout = dmc.Alert(
34+
mantine_example.layout = dmc.MantineProvider(dmc.Alert(
3535
"Hi from Dash Mantine Components. You can create some great looking dashboards using me!",
3636
title="Welcome!",
3737
color="violet",
38-
)
38+
))
39+

‎demo/demo/templates/demo_one.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ <h1>Simple App Embedding</h1>
1919
<div class="card-body">
2020
<p><span>{</span>% load plotly_dash %}</p>
2121
<p>&lt;div class="<span>{</span>% plotly_class name="SimpleExample"%}">
22-
<p class="ml-3"><span>{</span>% plotly_app name="SimpleExample" %}</p>
22+
<p class="ml-3"><span>{</span>% plotly_app name="SimpleExample" ratio=0.2 %}</p>
2323
<p>&lt;\div>
2424
</div>
2525
</div>
2626
<p></p>
2727
<div class="card border-dark">
2828
<div class="card-body">
2929
<div class="{%plotly_class name="SimpleExample"%}">
30-
{%plotly_app name="SimpleExample"%}
30+
{%plotly_app name="SimpleExample" ratio=0.2%}
3131
</div>
3232
</div>
3333
</div>

‎django_plotly_dash/templatetags/plotly_dash.py‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,28 @@ def _locate_daapp(name, slug, da, cache_id=None):
6565

6666
return da, app
6767

68+
6869
@register.inclusion_tag("django_plotly_dash/plotly_app.html", takes_context=True)
69-
def plotly_app(context, name=None, slug=None, da=None, ratio=0.1, use_frameborder=False, initial_arguments=None):
70+
def plotly_app(context, name=None, slug=None, da=None, ratio=0.1,
71+
use_frameborder=False, initial_arguments=None,
72+
height=None):
7073
'Insert a dash application using a html iframe'
7174

7275
fbs = '1' if use_frameborder else '0'
7376

74-
dstyle = """
75-
position: relative;
76-
padding-bottom: %s%%;
77-
height: 0;
78-
overflow:hidden;
79-
""" % (ratio*100)
77+
if height is None:
78+
dstyle = """
79+
position: relative;
80+
padding-bottom: %s%%;
81+
height: 0;
82+
overflow:hidden;
83+
""" % (ratio*100)
84+
else:
85+
dstyle = f"""
86+
position: relative;
87+
height: {height};
88+
overflow:hidden;
89+
"""
8090

8191
istyle = """
8292
position: absolute;

‎django_plotly_dash/version.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
2424
'''
2525

26-
__version__ = "2.3.1"
26+
__version__ = "2.3.2"

‎docs/template_tags.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The tag arguments are:
3030
:da = None: An existing ``django_plotly_dash.models.DashApp`` model instance.
3131
:ratio = 0.1: The ratio of height to width. The container will inherit its width as 100% of its parent, and then rely on
3232
this ratio to set its height.
33+
:height = None: Optional direct specification of the container height. If specified, overrides any ``ratio`` setting.
3334
:use_frameborder = "0": HTML element property of the iframe containing the application.
3435
:initial_arguments = None: Initial arguments overriding app defaults and saved state.
3536

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /