Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion demo/demo/dash_apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
'''Dash demonstration application

TODO attribution here
Copyright (c) 2018 Gibbs Consulting and others - see CONTRIBUTIONS.md

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'''

# The linter doesn't like the members of the html and dcc imports (as they are dynamic?)
Expand Down
5 changes: 3 additions & 2 deletions demo/demo/mantine_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
mantine_example = DjangoDash("MantineExample")


mantine_example.layout = dmc.Alert(
mantine_example.layout = dmc.MantineProvider(dmc.Alert(
"Hi from Dash Mantine Components. You can create some great looking dashboards using me!",
title="Welcome!",
color="violet",
)
))

4 changes: 2 additions & 2 deletions demo/demo/templates/demo_one.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ <h1>Simple App Embedding</h1>
<div class="card-body">
<p><span>{</span>% load plotly_dash %}</p>
<p>&lt;div class="<span>{</span>% plotly_class name="SimpleExample"%}">
<p class="ml-3"><span>{</span>% plotly_app name="SimpleExample" %}</p>
<p class="ml-3"><span>{</span>% plotly_app name="SimpleExample" ratio=0.2 %}</p>
<p>&lt;\div>
</div>
</div>
<p></p>
<div class="card border-dark">
<div class="card-body">
<div class="{%plotly_class name="SimpleExample"%}">
{%plotly_app name="SimpleExample"%}
{%plotly_app name="SimpleExample" ratio=0.2%}
</div>
</div>
</div>
Expand Down
24 changes: 17 additions & 7 deletions django_plotly_dash/templatetags/plotly_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,28 @@ def _locate_daapp(name, slug, da, cache_id=None):

return da, app


@register.inclusion_tag("django_plotly_dash/plotly_app.html", takes_context=True)
def plotly_app(context, name=None, slug=None, da=None, ratio=0.1, use_frameborder=False, initial_arguments=None):
def plotly_app(context, name=None, slug=None, da=None, ratio=0.1,
use_frameborder=False, initial_arguments=None,
height=None):
'Insert a dash application using a html iframe'

fbs = '1' if use_frameborder else '0'

dstyle = """
position: relative;
padding-bottom: %s%%;
height: 0;
overflow:hidden;
""" % (ratio*100)
if height is None:
dstyle = """
position: relative;
padding-bottom: %s%%;
height: 0;
overflow:hidden;
""" % (ratio*100)
else:
dstyle = f"""
position: relative;
height: {height};
overflow:hidden;
"""

istyle = """
position: absolute;
Expand Down
2 changes: 1 addition & 1 deletion django_plotly_dash/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@

'''

__version__ = "2.3.1"
__version__ = "2.3.2"
1 change: 1 addition & 0 deletions docs/template_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The tag arguments are:
:da = None: An existing ``django_plotly_dash.models.DashApp`` model instance.
:ratio = 0.1: The ratio of height to width. The container will inherit its width as 100% of its parent, and then rely on
this ratio to set its height.
:height = None: Optional direct specification of the container height. If specified, overrides any ``ratio`` setting.
:use_frameborder = "0": HTML element property of the iframe containing the application.
:initial_arguments = None: Initial arguments overriding app defaults and saved state.

Expand Down