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
Related
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!
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.
I'm using retentioneering library with python for analysing complex user behaviors in a website and show it as a graph.
Everything works as expected but now, I would like to provide access to this plots also to other people using a web app built with flask.
This is the result given from retentioneering: retentioneering graph result where you can select various "filters" and drag node to change their location.
I would like to create a web app with this exact graph and filters provided by the library plus, as I said, the drop down.
The problem is that the graph is not just an image but something a user can interact with, so my question is: how can I show it in a dynamic way like here? Is there some specific html object I should use?
Thanks.
Investigating a bit more on how retentioneering works it turns out that the final return value is basically an html with javascript that create the graph.
So using flask displaying this html is really straightforward using the render_template function.
I have a python code that exports data into a csv, then I load that csv into Tableau. I don't want to load a csv into tableau.
Is there a way I can just take the return value of my python script and put it directly into tableau?
Question is similar to Export data from Python into Tableau using JSON? , but they inquire about Json format and the answer was to use csv. I want to skip csv step if possible. The data im returning will be in a tabular format.
Consider using TabPy. It returns values created by scripts as calculated fields within a workbook.
Otherwise, Tableau purely operates as a layer on top of a source of data. There is no such thing, unfortunately, as loading data directly into it.
The way I typically handle jobs like this is to have Python load data directly into a data store of some sort. All new information - or overwritten information - is then viewable with the existing data connection of your Tableau workbook.
A simple way to do this, without having to use a formal database is to consistently load the CSV into the same place with the same name. Then once Tableau is opened with the pre-existing connection, all that is needed is a click of 'refresh.'
I understand that your goal is to have Tableau populate your data directly from Python, and I'm sorry this isn't the answer you probably wanted, but there is some backend work that needs to be done. If done properly, though, the end effect to any user could appear to render directly from Python.
Make sure your current Tableau extract is a "Tableau Data Source" and then use the "Tableau Data Extract Command-Line Utility" to push the data into Tableau. You use os.system or subprocess to call the tableau executable. One caveat is this thing only work on Windows.
https://onlinehelp.tableau.com/current/pro/desktop/en-us/extracting_TDE.htm
Loading a csv file example from the Tableau site:
C:\Program Files\Tableau\Tableau 2019.1\bin>tableau addfiletoextract --server https://our_server_name --username OurServerSignIn --password "OurServerPwd" --project "New Animations" --datasource "CurrentYrOverYrStats" --file "C:\Users\user1\Documents\DataUploadFiles\AprMay.csv"
One of the existing options in the Tableau Desktop "Connect" screen is "Web Data Connector," which can connect to any kind of web server and get data through a well-documented protocol. I suspect this would include a web server running on localhost written in Python.
If you want to go this route, it would require either changing your existing Python script to turn it into a web server that transmits the script's output over the web data connection, or (preferably) making some very general Python code that could that could wrap an arbitrary script of any type in this way, exposing its output as a web data connection.
You will, of course, have to leave that Python script running, listening for connections from Tableau.
I have a tableau dashboard that has a web object in it. The web object has comments made to that particular dashboard, it is basically just html in a server. When I open it in Tableau server, it works perfectly and it is displayed correctly. When I export it to PDF, the web object is not displaying at all. As per tableau docs, the web object will not be displayed. Is there another way of getting the web object or the html to display in the PDF?
I can use python and tabcmd to achieve this, I'm open to suggestions of any kind, this requirement is completely necessary for what I'm doing and I'm tearing my hear out at this point.
Thanks!
According to the Tableau Community Forums, it's not possible to export the contents of a web object inside a dashboard because of how the web object works:
Thank you for contacting Tableau Technical Support. I understand
exported PDF on Tableau Server is not including the contents of web
pages. Please let me know if I misunderstood your request.
It is the expected behavior that exporting views to PDF will not
include web page objects. The dashboard containing a web page object
has no knowledge of what is in the web browser object so it is left
blank.
One way I could think to do this is build a web data connector to pull the comments as text data, then do some string manipulation to make a view formatted how you want, and add that view to your dashboard.