I’m building a Django app for my blood pressure control (I’m a hypertonic). What would be the best way to create a chart for my blood pressure for last 30 days?
It should be days on x and pressure (both sistonic and diastonic) on y. Idially if colors would automatically apply (if pressure is normal - green, if high - orange, if too high - red).
There are just a ton of plotting libraries for web development; the challenge isn’t so much finding one as it is deciding on which one you’d like to use. Searching the web for “plotting library Python” or “web plot library” will turn up many many options for you to explore. Probably the best thing to do is to set aside some time to look at a few options, and choose the one that “clicks” for you.
One fundamental choice you’ll need to make is whether you’d like to generate the chart on the backend or on the frontend:
If you generate a chart on the backend, you’ll use Python code (in your view or whatever) to generate an image (typically PNG or SVG), and then embed that image in your HTML. You might choose to do this if you’re more comfortable writing Python than JavaScript, or if you want to use these charts in other ways (e.g. render to PDF).
If you generate a chart on the frontend, you’ll feed data to your view (either directly in the context, or often as an API serving something like JSON), and you’ll use a front-end JavaScript library to render the chart. You might choose this method if you’re more comfortable writing JavaScript, or if you want interactive charts.
There are also interesting hybrid approaches, where you write Python and the plotting library generates JavaScript for you.
I’ll mention a few of my favorites – but again, I want to stress that this is far from an exhaustive list, these are just the ones I’ve used and like.
I’ve done this recently and found that most of the nicer, more modern charting solutions are JavaScript based, which means you generally need to generate the data in Python/Django and then pass it to the frontend chart by including the data in your template. Adam Johnson has a good blog post explaining how to do this securely: How to Safely Pass Data to JavaScript in a Django Template - Adam Johnson Check out https://www.chartjs.org/ for a bunch of charts that are fairly easy to integrate into a Django project.
There are just a ton of plotting libraries for web development
Yes, there are, so thanks for sharing your research and conclusions. I
just now saved your message as a starting point for me once the topic
comes up again!