Real time charting with Plotly and Flask? - python

I need to add a real-time chart to my Flask-SocketIO app, for that i found Plotly.
Would it be possible with Plotly to generate a chart which shows both real-time data and past data? When the user opens the page he should be able to see both the data from before the webpage was opened and the new data. How would it be possible to accomplish that with Plotly? Is there an example for it?

For this kind of apps it's highly recommended to feed your real time data to a database and connect your visualization with said database, however I think it is possible to achieve what you want in jupyter notebook with plotly 3 FigureWidget's batch_update. I can't quite get the idea of what you want without some code though.

Related

Is there a way to embed pandas analysis into a html page?

I've done some analysis using Pandas on a csv file and have created a number of graphs using matplotlib and plotly.
I'm trying to get these graphs in a html page so my team can see them on a dashboard.
I know it's possible to download the image and embed into html, however, the csv file I performed my analysis on will be constantly updated i.e. I need a way of include the graphs on a html page which auto refreshes.
Is this possible?
I think it would be possible and check pyscrpit
https://pyscript.net/
where you can use python in html
https://github.com/pyscript/pyscript/blob/main/docs/tutorials/getting-started.md
here are some tutorials to get and idea of what I am talking about and to start
Then you can host the html page anywhere you like and they will see when you update it
Voila or Panel to make a dashboard is another way to go. That needs an active Python kernel at this time. (That is as opposed to the pyscript / webassembly route. JupyterLite currently works in WASM and Voila in WASM is in development.) Examining demonstrations available at the Voila Gallery will give you a sense of how it can work. All those example demos are served via MyBinder. And you can use that too, if your code and data can be public. If it cannot be public, you'd need to host a server that only your team can access.
JupyterLite would also be possible if you don't mind your team being able to see the code cells and things that compose your Jupyter notebook stepping through the analysis. That would not require an active Python kernel server-side because it is based on WebAssembly that would run inside the client machine, like PyScript. So all you would need to do was a have a server that can serve static files. That's a lower bar than Voila that would run on the server. How to get started deploying JupyterLite is here.
I would checkout out Dash or Plotly, here you can add generation of the graphs in a callback for isntace. Which would update them when the .csv updates. Good luck!

How do I post Python generated GFS plots on my website?

I have a Python script that ingests GFS model data and plots it using matplotlib. How do I get those exact plots to display on a website? I am currently using PythonAnywhere to build my webpage.
It looks like Python Anywhere has a variety of options for how you can host your website/web application--so the details of how to do this will depend on how you are hosting your site.
One option is Flask, and I'll just point you to Matplotlib's example on embedding Matplotlib within Flask.
Another option is to generate the plots statically somewhere, and then upload them into your static website content. I'm not sure how exactly one one would go about that with Python Anywhere.

Exporting network data to cytoscape desktop client

I need to share some network data-visualization to people outside of my organization, that are not super good with IT (meaning they wouldn't know how to execute some python script I could give them). This data is rather confidential so I can't simply set up a Dash app and give them access, also the network graphs are rather big, so images are not satisfying.
I see two options that would meet my needs:
Sending them Cytoscape objects they just have to import on the Cytoscape desktop software
Sending HTML objects that they could just open in their browser (using cytoscape.js rendering typically).
So far, I managed to do the following:
Pulling data from elasticsearch using python, enriching the data, and setting up node and edges object into a json format.
Converting this data into ipycytoscape object that I'm able to render properly within a Jupyter Notebook
Converting to Dash cytoscape and rendering in a browser locally
Where I'm stuck is when it comes to exporting this in a format that's easy to exploit.
I couldn't find proper documentation on how to:
either export Cytoscape.js data so it's usable on the Cytoscape desktop client
Export Dash cytoscape-rendered graph into self-sufficient HTML document. I've seen some code examples working with plotly (https://plotly.com/python/interactive-html-export/)
Could someone help me on that?
Thank you very much,
Arnaud

Hosting interactive Bokeh plots independent of the Bokeh server

I have created a Bokeh Document that currently hosts two plots. The first employs two widgets that control a barchart while the other is a standalone choropleth map. Using the Bokeh server, the plots are completely interactive and dropdown and button widgets are able to dynamically update the source data and sort barchart respectively, but I am trying to share this Document with colleagues that simply want to visualize these data in the same fashion on a web page independent of the Bokeh server.
Is this possible?
Thanks in advance!

Google Time Based Graphs can't be seen as images

I have a chart that is a time based chart. However when I try to publish it as a image - it doesn't seem to physically publish. I get link and when I inspect link I can see the image, but the image is just a blank when you look at the site. I thought this was a browser specific issue - but alas, tried it on linux/microsoft O/S and different browsers - same result - the image is blank.
The interactive version of the graph seems to be working from the get go, in all o/s and browsers.
Is there way to bypass this and have a time-based chart display as an image?
Addendum:
The type of graph is as follows:
The x axis is time and y axis is any relevant value. The graph events that has happened at a given time instant. However with most if not all Google charts, when you click the publish button you have the option to publish the graph as an image or an interactive graph:
However with time-based graphs you still get this option but when you choose to publish it as an image, and go to the published website - there is nothing to be seen there - it's just blank. I have tried different o/s and browsers but no success.
Is there a way to publish the time-based graph as an image that can actually be seen?
This should not have a google-visualization tag. It looks like you are have created a chart in Google docs and are trying to use their 'publish to the web' feature. That is separate from the Google visualization API.

Categories