Yet More Solar Statistics
It probably won’t come as much of a surprise to anyone who read my last post about the new Solar Statistics page to learn that I didn’t leave it alone for very long. I finished that post by saying:
“I guess the next obvious improvement will be to make the tables user-sortable; that should keep me and my AI busy for a while.”
Well, the tables are now sortable. That bit was actually fairly straightforward. As is often the way with these things, making the tables sortable merely gave me more ideas.
Charts, charts and more charts
The Daily, Monthly and Annual Statistics pages now have charts above the tables as well. These show the same data visually, so it’s much easier to spot patterns without poring over rows of numbers.
The Daily chart shows the amount generated each day along with the peak power achieved that day. The Monthly chart does much the same thing for the months of a year, while the Annual chart compares whole years.
Generation is shown as bars, with Peak Power shown as a line over the top. Incomplete days, months or years are shown slightly differently so that they aren’t mistaken for genuinely low values.
The exact figures are still there in the tables underneath, along with the High and Low markers, so the charts are really just a quicker way of seeing what’s going on.
I may have spent rather too long deciding on colours, line thicknesses and animations, but that’s half the fun.
Anna was right, obviously
Anna then suggested that it would be useful to compare the same month across different years. Naturally, this was a good idea.
There is therefore now a Compare Months section where I can choose, say, November and see November 2021, November 2022, November 2023 and so on alongside each other.
That immediately makes comparisons between years much easier. November 2021 is marked as partial because the solar panels weren’t installed until halfway through that month, and the current month is also marked as partial until it finishes.
Once I’d built that, Anna told me that I hadn’t actually listened to her and what she wanted was a comparison chart showing all the months across all the years. If only I had listened to start with. Oh well, it was a good opportunity for another chart! This has January through December along the bottom with a separate line for each year from 2022 onwards. The current year simply stops at the current month.
Annoyingly, it’s probably the most useful chart! It makes the seasonal pattern really obvious, but also shows how different individual years can be. I thought it might get a little too crowded as the years go by, so now you can even click individual years in the key to hide them, which makes comparing two particular years much easier.
Goodbye Google Charts
Most of the charts on the Solar Monitoring pages were originally made using Google Charts. They worked perfectly well, but this latest work seemed like a good opportunity to modernise things a little.
The charts are now being moved over to Chart.js, which is stored locally as part of my SolaX plugin. There are a few advantages to this.
The site no longer needs to contact Google every time it wants to draw one of these charts, I have much more control over how they look and animate, and all the code that builds them can live inside the SolaX plugin rather than being scattered around custom theme header files.
That last point is probably the most important behind the scenes.
Over the years quite a bit of SolaX-specific PHP, SQL and JavaScript had found its way into special theme headers. It worked, but it meant the solar monitoring system was rather more tied to this particular website theme than it really needed to be.
The recent changes have moved much of that back where it belongs: inside the plugin.
A bit of gratuitous animation
Chart.js also gave me far too many opportunities to play with animations.
- The bar charts now bounce gently into place when the page loads.
- The gauges have animated needles.
- The multi-year comparison chart has its own smoother animation.
None of this is remotely essential to knowing how much electricity the roof has generated, of course. But it looks nice. If I’m going to spend this much time looking at solar statistics, they might as well arrive with a little flourish.
New gauges too
The live Solar Power and Battery State of Charge gauges have also been replaced. These were previously Google gauges. The new versions are custom gauges made using Chart.js.
They have coloured operating ranges, tick marks, animated needles and a slightly more modern appearance. The Solar gauge also has a small marker showing the highest live output reached that day.
The same gauges are now used on the main Solar Overview page and on my little Mini Solar display in the house. The Mini Solar display is a separate personal project really. It combines the SolaX information with data from my weather station and local tide times, so it’s very specific to our house and unlikely ever to be useful to anyone else. It is, however, a very handy test bed for this sort of thing.
An old iPad fights back
There was one little snag. The Mini Solar display lives permanently on an old iPad in the kitchen. The iPad is still perfectly good for this job, except it is stuck on iPadOS 12.5.8.
Everything worked beautifully on my Macs, phones and development site, but the shiny new charts were completely blank on the iPad. After taking the iPad into the office, plugging it into the Mac and remotely inspecting Safari, we eventually discovered that the latest version of Chart.js was simply too modern for it.
So I added a small compatibility fix for something called ResizeObserver. Somewhat to my surprise, it all sprang into life. How did I used to do such things without the help of a handy AI?
Records and Averages gets some attention too
Having converted the Statistics and Overview pages, it seemed silly to leave the Records and Averages page using the old Google charts. That has now been converted too.
There is a Solar Performance by Year chart, matching the Annual Statistics chart, with orange bars for annual generation.
The Total Monthly Yields chart shows the most recent 26 months. I kept the blue bars from the old version and the angled month labels because I rather liked them.
There is also an Average Daily Yields and Maximum Power by Month chart, which averages all the data collected over the years to show the typical daily generation and peak power for January, February, March and so on.
That one gives a particularly nice overview of just how seasonal solar generation is here in Wales.
A little tidying behind the scenes
Perhaps the less exciting, but ultimately more useful, part of all of this has been tidying up the code.
- Database queries that used to live in theme header files have moved into the plugin.
- Common charts now share the same rendering code.
- The Overview and Records pages no longer need their own special chart-heavy headers.
- Some data is cached so that the database isn’t repeatedly doing the same calculations, while live information is refreshed much more frequently.
- The Peak Power axes have also moved from Watts to kW where appropriate, simply because 4.2 takes up less room on a graph than 4,200.
There have been various other small fixes along the way too. Even the tide display on my Mini Solar screen got some attention after an exactly 5 metre tide managed to reveal how fragile my old “take these six characters from the RSS feed and hope for the best” code was.
That now actually parses the tide height instead. Probably a better idea.
Where next?
I’m getting to the point where the SolaX plugin is becoming rather more self-contained than I ever intended it to be. It already has its own settings page for things such as the SolaX API token, solar array size and battery capacity. The charts, database queries and most of the presentation are gradually moving out of the theme as well. That does make me wonder whether, with a bit more work, it could eventually become something that other SolaX users could install.
There would still be plenty to do before that. Installation and database setup would need to be automated, various assumptions specific to our installation would need removing, and I’d have to make sure it behaved properly with different SolaX systems and WordPress themes.
But it’s beginning to look possible.
For now though, I think I should probably stop fiddling with graphs and actually let the solar panels get on with generating some electricity.
Although I’ve said things like that before.
Discover more from A Simple Life of Luxury
Subscribe to get the latest posts sent to your email.









