Comments (13)
I've gone ahead and implemented this feature and it works for me, though its not a clean solution yet. You are right that there are some issues with injecting Dash in to an existing page, but I think these look resolvable.
I am still experimenting to see what is better in what scenario and learning how the dpd code works.
The iframe route might be fine but some handy options would be:
- Being able to choose whether to return raw html code for injection or an iframe
- If an iframe, passing specific css routes over to Dash during construction of the app would minimise duplication. For example, I am thinking that if we know the Django app name and the base url and the css we care about, it might be suitable to pass the same static routes over to DjangoDash to inject in the dpd template containing the iframe.
from django-plotly-dash.
Hi delsim,
I am on holiday without my computer but when I'm back in a week and a half I'll neaten my code and share!
from django-plotly-dash.
I've merged your pull request into a new branch off of the 0.6.0 tag. I'll use this as a base for pulling in parts of your changeset to trunk. It is not clear if this is the best workflow with git/github but it should work here.
from django-plotly-dash.
The iframe is used because the dash content doesn't mix well with other content on the page. This makes not encapsulating it tricky.
Would a different template - one that still had an iframe, but had some css (and perhaps js) added to it - suffice?
from django-plotly-dash.
I've done some work to move this project onto a newer dash version, so we now have the benefit of the new template rendering in dash and I'm starting to think about how to leverage that to make the iframe optional.
@eddy-ojb - are you able to share any ideas or code from your own work? I'm keen to avoid duplicating work, particularly if it helps me avoid trampling on what you've already done.
from django-plotly-dash.
The code is on its way shortly.
Whilst I have integrated my changes to the DPD code to show how I made this work, I won't be offended if you refine it as I don't have a mental map of how it all connects just yet. The way Django and Dash work is so different that I feel that I need to get stuck in to React and Flask to fully realize the DPD code.
I just need to scrub my demo and then push my version of the DPD code and a demo to a repo. Bearing in mind that I am not an expert in Git, would you like me to try pushing to your repo or shall I push to my own and you compare that way?
from django-plotly-dash.
I wouldnt claim to be a git expert either! I think push to your repo, then send a pull request, is the best/easiest way forward.
from django-plotly-dash.
I've made the request - I did try over the weekend but got quite frustrated with Git! This is my first push like this so not offended if you chop, change or reject. We will be sticking to this methodology for now though until we get our head around channels and how we can deploy with reverse proxy on IIS, then I would like to move on to your channels methodology.
from django-plotly-dash.
The clean_dash_content
function that I wrote in views.py in my branch can be replaced by the following:
dash_content = "".join(dash_content.decode('unicode_escape').splitlines())
Works across the different versions I have tested.
from django-plotly-dash.
I have tested my html return vs the iframe method for a larger layout with callbacks and the load time is nearly 2:1. The iframe method is superior in this case.
I have noticed the 'html_formation' branch has been developed with some probably much more efficient code. I am happy to give this a test if/when it is ready - wondering if the load ratios are similar. If this runs reasonably, this still seems like a nice option as I find duplicating the static routes with Dash offline tricky at the moment, unless I am doing it incorrectly.
from django-plotly-dash.
html formation (along with a replication of the example kindly supplied by @eddy-ojb) directly into a template, so not wrapped in an iframe, is now in the published prerelease 0.8.0 version and it covers (I think) the goal of this enhancement request.
As a consequence, closing this issue. If its way off base then please reopen and comment. If there are bugs etc then please open a new issue.
from django-plotly-dash.
@GibbsConsulting, once a project is setup to accommodate this feature, I have it found it works really well! Thanks!
from django-plotly-dash.
@eddy-ojb that's good to know, thanks!
from django-plotly-dash.
Related Issues (20)
- DataTable in full height HOT 2
- DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses HOT 5
- Make the use of position: relative in the plotly_dash template optional
- allow_duplicate on outputs doesn't work HOT 7
- Using dash_leaflet causes js library to fail HOT 9
- Using dash-tradingview dash_tvlwc breaks the app in Django HOT 2
- Improve configuration documentation
- How to pass multiple pandas Time Series (created in Django view) to Dash callback? HOT 2
- allow_duplicate output fails silently
- Bootstrap 5 incompatibility
- How to make Playable Gifs for Django Dash? HOT 1
- AttributeError: 'function' object has no attribute 'expanded' HOT 4
- Assets not fetched correctly while using plotly_direct template tags HOT 7
- Enable get_asset_url to be used for file names passed to the DjangoDash constructor
- Support for Django 5.0 HOT 5
- plotly_direct tag overwrites template style set in base.html HOT 3
- Enable use on Django 5.0
- Increase dash version to 2.10 or greater HOT 3
- Dash Vega Components HOT 1
- Update documentation to refer to bootstrap 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-plotly-dash.