Start a new topic

Sparkline regression: negative numbers now shown as zero, previously shown as grey bar.

Hi all,


Background:


I wrote an app some time ago to pull data from nightscout for Diabetes blood glucose monitoring.


I'm using a sparkling to draw a graph of blood sugar levels over the last 3 hours.


ChartData and negative numbers


The blood glucose levels aren't always available. Sometimes there are gaps in the data.


I previously included negative numbers in my chartData to show gaps:

 

"chartData": [
                160,
                140,
                120,
                100,
                -160,
                100,
                120,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100
            ]

  

It seemed that there was a feature of the sparkline. negative numbers were rendered as a full height grey bar, without a white pixel at the top:



Here's an example of how this missing data was rendered (note no white pixel in column 5)



This was good, but stopped working recently


I released an update to the app a few days ago, and although the data feed has not changed, the way the graph is rendered has changed:


Now, negative numbers are represented as a white pixel:


This is bad, missing data is now misleading


This makes the graph harder to understand, I can't tell if my blood sugar level is low or if there is a missing entry on the graph.


What would help


Restoring negative numbers being rendered as grey bars (without the white pixel at the top)


It would be awesome if there was a chordate entry I could add that asked the LaMetic to avoid drawing a column:


 

"chartData": [
  160,
  140,
  120,
  100,
  false or null or "NaN" or "LEAVEBLANK",
]

 So that it might be shown as :


Hiding columns in the sparkline would be great!





2 people like this idea

Recently revisited this issue:


Using a value of `2147483648` in the chartData array produces a blank vertical line (a grey vertical line whilst the chart is actually being drawn that changes to black)


This is great for my data as I'm able to show missing values from the graph. Gaps are extremely important for understanding blood glucose levels and how they're changing.


Whilst the chartData draws a chart that ranges from the minimum to the maximum value in the chartData array, this large number doesn't seem to impact the scaling and seems to be ignored when calculating the minimum/maximum scale


Please don't fix this, unless you're planning to support a "don't draw this value" in the array (like false, NaN, null) 


This is back to what I need to correctly display by blood glucose values.


Tested 2024-08-25 on an old Time and a Time 2022



 

"chartData": [
                160,
                140,
                120,
                100,
                2147483648,
                100,
                120,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100,
                100
            ]

 

That’s a shame. For me it’s extremely important to distinguish missing data (a grey or black bar) and zero (which would be a single white pixel on the bottom row) Using 2^31 seems to cause a grey/black line which doesn’t cause any unexpected/unwanted scaling and that works well for me. It would be a shame if that “bug” were fixed. Maybe accepting null as a value to deliberately leave a line blank would be acceptable?
Login or Signup to post a comment