@JustinL Thank you for all the steady progress on the Quick Chart app. I discovered this code was out there only a few days ago and I've been dying for a better way to visualize certain Hubitat data than numbers on dash boards or downloading data I've put in a file to graph in excel. The charts are very useful for me. For example, I have a golf cart whose charger is plugged into a 15A Sarnoff switch that reports power. I'm able to graph out the charging curve in real time vs. writing all the data to file then graphing in excel after the fact. Very cool!
I do think I've run across a bug while using v1.0.6 where the X-axis labels disappear for numerical data like temperatures. I've seen others bump into this in this thread going way back and I'm guessing there may still be an issue or two. I don't have very much experience with Groovy, but I've dropped in a few debug statements in Quick Chart Child to hopefully help someone narrow down the root cause.
Reproducing the bug (i.e. Sparkline with numeric data displayed without X-axis labels) :
- Make a sparkline chart that plots two temperature sensors for Today. When working, the chart looks like this in my case:
(I'll provide all the configuration settings if requested)
- Note: the bug NEVER happens when you trigger the chart manually from within the app configuration - this always works correctly! Why?
- The first chart I created after installing Quick Chart 1.0.6 works fine and does not reproduce the bug at all. Weird.
- Every numeric chart after the that first one I created seems to reproduce the bug, BUT ONLY when it does it's own periodic update (I'm using every 5 minutes for now). Here's what the chart looks like when the bug happens:
- To be perfectly clear, I never see this when I'm using the manual trigger in the child app settings.
Here's what I've noticed in the Quick Chart Child code and logs:
A. When the chart is adding X-axis labels correctly, the "Xaxes" setup within the "builderChart" debug output looks like this:
xAxes: [{display: true, stacked: false, type: 'time', time: {unit: 'minute', displayFormats: {minute: 'ddd HH:mm'}}, ticks: {source:'auto', fontColor: 'white'}, gridLines:{display: true, zeroLineColor: 'gray', color: 'gray'}}]
But when the bug happens it looks like this:
xAxes: [{display: true, stacked: false, type: 'time', time: {unit: 'day', displayFormats: {day: 'ddd'}}, ticks: {source:'auto', fontColor: 'white'}, gridLines:{display: true, zeroLineColor: 'gray', color: 'gray'}}]
You'll notice the good one have the time unit set to 'minute' and the bad one has it set to 'day'. Tracing this back in the code, it appears there is an issue eventChartingHandler in the chunk of code handling numeric charts. Around line 1872 you'll see this fragment of code:
if(dataType == "rawdata") {
if(dFormat) {
displayFormat = "ddd HH:mm"
} else {
displayFormat = "ddd hh:mm"
}
}
else {
displayFormat = "ddd"
displayUnit = 'day'
}
When the bug happens, ${dataType} seems to be a null value at this check (is it out of scope?) and the displayUnit is incorrectly set to 'day'. I don't really understand why dataType is null here. I can work around the bug by changing the code to force displayUnit to "minute" and displayFormat to "ddd HH:mm".
I hope this helps you improve the app. I'm happy to provide more information if needed.