-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should Dash be a Flask Extension? #38
Comments
Somewhat related, is it possible to use Dash from inside my Flask app? I've been wanting to use the Python dendrogram+heatmap visualization in my Flask app for a long time. But sadly there is no Javascript dendrogram+heatmap, so I've had no choice but to use something else :'( |
Yeah I've been thinking about learning a little bit of Javascript to use one of it's libraries for making graphs. But Dash sounds like it would work fantastic with what I want to do, if it was more like a Flask extension. |
For this example, you can render these dendrograms as a
All of the |
Could folks explain a little bit more why they would like Dash as a flask extension? Some leading questions:
Thank you! |
It just seems a bit too limiting to have Dash stand on its own. It would create more consistent to make it an extension. Forgive me if any of my points are wrong, this is the way I understand Dash to be working from reading a bit into it and experimenting with it a bit. |
@chriddyp Firstly, thank you for your reply to my post! I'm very excited to try this out! My remaining concern is, I'm not sure how I will pass data from my Flask app to the Dash app? (More on that below). Secondly to answer your questions,
Edit - Silly me! I don't use Django. I use Jinja! |
I would second most of what has been said here. I think it would be great to have Dash integrable into existing Flask apps. My biggest problem with using things like Plotly or Bokeh was that it always seemed like they had to be used as standalone products.
|
I think what I'm saying is covered by the more general case statements that others have made in this issue, but sometimes simpler more concrete examples make the point more strongly. I have written a number of flask apps that have complex navigation and information display to get to help the user navigate to a particular dataset. I would like to have a dash app that lets me display that particular dataset to the user after they navigate to it, and give the user a fixed URL to get that dataset back at a later date, or email as a link. In such a case I need the flask endpoint to be able to convey information to the dash app in order to load the appropriate dataset and generate the interactive visualization. I could redo the whole dataset navigation in dash, but it seems overly complex in many instances as the layout's for selection procedures often vary dramatically from level to level, and the dataset selection parameters wouldn't be stored in the URL. Having different flask endpoints point to dash apps would then let you easily parameterize dash visualizations. I understand that 'snapshots' is an enterprise feature now for capturing the state of the visualization, but I'm talking about parameters that naturally live outside the UI visualization loop. |
I would also love to have the dash-app as a flask extension so that we can pass dataset (path to the data file on the server) as an argument to Flask's |
@yk-tanigawa flask extension would be awesome, but until we've gotten there here is how I implement the functionality you describe:
To see it in action - http://velometria.com/events/marmotte-alpes-2017 |
Dear @sladkovm
I want to generate the dash layout based on variables defined as flask config parameter, e.g. app.Config['plot_type'] in the dash app:
And I use the following callback in the flask app:
I have a template 'plot.html' with jinja2 div of 'plot', which I want to be replaced by the dash graph id=fig. |
Hi @resenganalytics, I wrote you a very long answer, but than I've noticed that you might have a different problem.
For your particular case, apart from the fact that you are populating the non-existent My long answer: I would not be able to answer all your questions since some of them (jinja2 etc.) are something I've never worked with, but let me guide you through the thinking process.
In your code this step is:
What it says in plain english is something like this: "find the element with id='url', read it's property-value 'pathname' and pass it to the element with id='fig' to the property ... in your case it is 'children', but... the Your code should look like this:
That will work if you know how to define different figure objects based on the path. The more general way of doing it however is not to populate the |
Hi @sladkovm |
Hi, I quickly implemented a very simple routing function at the branch: https://github.com/sladkovm/docker-flask-gunicorn-nginx/tree/routing If you are not familiar with docker, just simply run the app from dash_app folder as dash docs do recommend - in this case the app will run at http://127.0.0.1:8050/ What you expect to see is that the header of the plot will display the pathname of the url. Examples: http://127.0.0.1:8050/ - / For more practical cases, the pathname could be a key to the dict that will return an object you want to display - figure, div etc (see how I refere to the dict figures['fig1'] to fetch the actual figure object). |
HI @chriddyp
|
I would also like to add my support for having this request implemented. Visualising data is very much a function that most applications have to be able to do now days. Having the ability to build an application in Flask and using Dash to provide some of the visualisation capability would make a lot of sense, it would also mean we could keep our applications almost entirely as Python code (with a mix of some css / html as Jinja templates). I've had to deal with this requirement a number of different ways over the past couple of years, both of which have felt somewhat hacky.
If I could build the components of my dash app and then just insert them into general layout template using Jinja2 tags that would be ideal.
The dash_dropdown being just a standard html_component used in a callback and the dash_visual being the graph where I displayed the data. The rest of the layout and html types of things I would just do in my main application template. This way I would need to try and replicate how my Flask templates look like into another layout which I use just for Dash which I have to maintain separately. I appreciate this is probably a very hard thing to do but adding another perspective as to why it would be useful. |
dropdown alignment with td alignment
dropdown alignment with td alignment
Fix `x` behaviour
closing as the project has gone in other directions |
Extensions such as flask_sqlalchemy or whatever?
The text was updated successfully, but these errors were encountered: