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!
Related
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 want to execute a python file using real user inputs from Web page Form and output should be displayed in the same Web Page or Web Dashboard. I have now created the Python file as .py and ipynb formats. But now I want to take the user inputs to the python code from HTML form and after executing the code results should be displayed as a HTML format using a Web Page. What should I do to achieve this target? I don't know any way to link python file and HTML easily. If anyone have an idea regarding this please help me to solve this.
A way to make the jupyter notebook interactive and to take the user inputs into account when running the code in the cells of the notebook is to use Jupyter Widgets. Thanks to the widgets, you will be able to bind the value of some variables to some actions made by the users. For example, you can bind the value of a variable to a text input the user will fill. That way, you can create a form, or can even think of using slider, dropdown lists, etc. to collect the information needed and to run the code accordingly.
Then, you can convert your jupyter notebook to a dashboard through the use of some tools such as Voila.
Also, you can make the jupyter notebook publicly available thanks to some service such as Binder (and associated documentation), that makes it available through an url and running the notebook on their server. You can also think of running the jupyter notebook on your own server and to share the associated url to the users.
Those are some tools that are based on directly using the jupyter notebook without creating and coding any classical html web page on your own. Yet, if you intend to code your form in a specific html web page, those tools will not help unfortunately as they aim to "do that job for you".
Is it possible to upload and manipulate a photo in the browser with GitHub-pages? The photo doesn't need to be stored else than just for that session.
PS. I'm new to this area and I am using python to manipulate the photo.
GitHub pages allows users to create static HTML sites. This means you have no control over the server which hosts the HTML files - it is essentially a file server.
Even if you did have full control over the server (e.g. if you hosted your own website), it would not be possible to allow the client to run Python code in the browser since the browser only interprets JavaScript.
Therefore the most easy solution is to re-write your code in JavaScript.
Failing this, you could offer a download link to your Python script, and have users trust you enough to run it on their computer.
I'm having trouble getting my mpld3 plot to show up in my Wordpress page. I make my plot, then use mpld3.save_html() to get an html file that contains my figure. However, when I paste this code into my Wordpress page (using the Text editor, not the visual editor) nothing happens. I paste both the script and div tags. I know my javascript is working because I can write alert('Hello'); inside script tags, which works fine. I've also tried installing the "Insert Javascript & CSS" plugin, which also did not work.
Is there some way to embed these graphs into Wordpress, and if not, how does one embed interactive charts in a Wordpress post?
I suspect that the d3.js and mpld3.js were not found, which would explain why you don't see the chart.
There is a d3_url and mpld3_url that you may want to provide and set to the url of a CDN where the files are available for example See https://mpld3.github.io/modules/API.html#mpld3.fig_to_html
Even after setting that properly you may have problems as this is not the recommended way to use javascript within wordpress. You can also try an embed with stricter separation from wordpress: see http://www.datamaplab.com/posts/embedding-javascript-visualization-wordpress/ for reference.
I am using reportlab in python to render a pdf server side.
I really like the look of highcharts graphs. But I am building a pdf server side which needs to include some graphs. The server side graphing (reportlab and matplotlib) do not have nearly as much choices for formatting / design.
Is there a way I can run a client side javascript graphing solution (highcharts) from the server side?
Here is a post with that request and this is what they said:
You feed this Java tool a URL, it fires up its internal WebKit browser, executes the JavaScript code and dumps the rendered page to PDF.
I am looking for resources on how this could be accomplished in python.
I had similar requirements and couldn't find an existing solution so I created a little proof-of-concept solution here.
This implementation works by having the python process create a node subprocess that uses the highchart-export-server node module which in turn spawns a PhantomJS instance to render the chart. A few russian dolls involved there, but it does the job.
Open a web browser on the server.
Point the web browser at a pre-made page that loads highcharts and renders your chart.
Grab the output of the browser.
Send that to a client.
Which of those steps seems confusing?
Note that this will be significantly slower than just using matplotlib, because you need to start up a full web browser just to render a graph. I had a quick look at the highcharts page you linked and I think you could probably reproduce that in matplotlib.