From cbf79e9b49026dcbe777b86350bd5e4e2da3ee9e Mon Sep 17 00:00:00 2001 From: delsim Date: Mon, 23 Sep 2024 08:27:41 -0700 Subject: [PATCH 1/4] Add preamble to file --- demo/demo/dash_apps.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/demo/demo/dash_apps.py b/demo/demo/dash_apps.py index 94a6e6be..4f628d5e 100644 --- a/demo/demo/dash_apps.py +++ b/demo/demo/dash_apps.py @@ -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?) From 311acb68c63f6071e1e6ec52ff0aa9992c0a0d61 Mon Sep 17 00:00:00 2001 From: delsim Date: Mon, 23 Sep 2024 09:28:10 -0700 Subject: [PATCH 2/4] Add height parameter to template tag --- demo/demo/templates/demo_one.html | 4 ++-- .../templatetags/plotly_dash.py | 24 +++++++++++++------ docs/template_tags.rst | 1 + 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/demo/demo/templates/demo_one.html b/demo/demo/templates/demo_one.html index 2d9ecb26..5823b5e0 100644 --- a/demo/demo/templates/demo_one.html +++ b/demo/demo/templates/demo_one.html @@ -19,7 +19,7 @@

Simple App Embedding

{% load plotly_dash %}

<div class="{% plotly_class name="SimpleExample"%}"> -

{% plotly_app name="SimpleExample" %}

+

{% plotly_app name="SimpleExample" ratio=0.2 %}

<\div>

@@ -27,7 +27,7 @@

Simple App Embedding

- {%plotly_app name="SimpleExample"%} + {%plotly_app name="SimpleExample" ratio=0.2%}
diff --git a/django_plotly_dash/templatetags/plotly_dash.py b/django_plotly_dash/templatetags/plotly_dash.py index e90bda71..9bfcd4d6 100644 --- a/django_plotly_dash/templatetags/plotly_dash.py +++ b/django_plotly_dash/templatetags/plotly_dash.py @@ -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; diff --git a/docs/template_tags.rst b/docs/template_tags.rst index 596a9a23..dd6b5c1b 100644 --- a/docs/template_tags.rst +++ b/docs/template_tags.rst @@ -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. From 6bf3ca92493ead17fc40ca85e2f902191a803ea4 Mon Sep 17 00:00:00 2001 From: delsim Date: Mon, 30 Sep 2024 15:51:19 -0700 Subject: [PATCH 3/4] Update mantine component example --- demo/demo/mantine_example.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/demo/demo/mantine_example.py b/demo/demo/mantine_example.py index ce8f6dc4..0762e116 100644 --- a/demo/demo/mantine_example.py +++ b/demo/demo/mantine_example.py @@ -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", -) +)) + From 46ecab91cfd86105cd72fbed1e4a959cf03dba9a Mon Sep 17 00:00:00 2001 From: delsim Date: Mon, 30 Sep 2024 16:14:47 -0700 Subject: [PATCH 4/4] Update version number --- django_plotly_dash/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_plotly_dash/version.py b/django_plotly_dash/version.py index 23109e48..208dc79d 100644 --- a/django_plotly_dash/version.py +++ b/django_plotly_dash/version.py @@ -23,4 +23,4 @@ ''' -__version__ = "2.3.1" +__version__ = "2.3.2"