boazreicher / mosaic-plot

Apache License 2.0
11 stars 2 forks source link

Feature Request: Ignore Null Values #5

Closed andybaumgar closed 1 year ago

andybaumgar commented 1 year ago

Hi, thanks for the great plugin!

It appears that null values are currently rendered as if they are 0. It would be great if there was an option to render entirely null regions as transparent, and for mixed regions to ignore null in the average.

In my application many intervals have no data, so this feature would be very useful. If you are open to PR's I could take a shot at implementing the feature.

Thanks again!

boazreicher commented 1 year ago

Hi @andybaumgar 👋 The panel treats missing values as 0 by default, but you can change that with the Zero Values configuration option (render as transparent, or not render the cell at all). Here's an example: https://github.com/boazreicher/mosaic-plot/assets/44614829/4a1866f0-2332-4400-88cc-60d3fe7efa15

Regarding how average values are computed when there are null values - you're right. Those are treated as 0 (so no effect on sum, but it could lead to incorrect results for avg) It would be great if you could open a PR to fix that. I believe the fix should be in https://github.com/boazreicher/mosaic-plot/blob/main/src/data/SeriesUtils.tsx#L288 (calculate how many null values are in each bin, and then subtract them from the denominator in aggregated = sum / binSize;). I think that behavior should depend on the value of the Zero Values setting (sometimes it might make sense to treat null values as zeros in the average, and sometimes it can make sense to disregard them)

andybaumgar commented 1 year ago

Thanks @boazreicher! I had been using zero to represent a discrete "no error" state, but I should be able to encode it to something else.

I'll start the PR for ignoring null in the average. At the very least I am curious to see how your plugin works :)

boazreicher commented 1 year ago

Hi @andybaumgar, I've created a new release (https://github.com/boazreicher/mosaic-plot/releases/tag/v1.0.18) with your changes. I've also submitted it to Grafana for review. I'll post an update here once the new version gets published in the Grafana Marketplace.

andybaumgar commented 1 year ago

Woo!

boazreicher commented 1 year ago

@andybaumgar the plugin has been updated in the Grafana Marketplace:

Image

andybaumgar commented 1 year ago

Awesome! I'll update my dashboard :)