boazreicher / mosaic-plot

Apache License 2.0
11 stars 2 forks source link

Feature Request: Implement Max / Soft Max value #1

Closed moffitj closed 2 years ago

moffitj commented 2 years ago

I spun up a couple of panels with this plugin and something that feels missing is a manual Max or Softmax value.

If values up to 100 are acceptable but typically the values range from 0 to 5, then whenever there is a 5 it will show up as "red".

Is there another way to accomplish this without a panel option?

boazreicher commented 2 years ago

Currently the color range is mapped according to the min/max values in data. So, let's say you use a color palette that goes from green (min) to red (max), and the data has values between 0 and 100, 0 will be mapped to green and 100 will be mapped to red. Values in between will be mapped according to the selected Scale Type

If I understand you correctly, you would like to specify a Max value, which would override the max value from the data. So, if we use the same example and set the "Manual Max" value to 5, it would mean:

  1. Any value higher or equal to 5 would be colored red
  2. Even if the data contains values that are all smaller than 5, they would still be mapped to a scale that goes from 0 to 5

Is the above correct? Also, what do you mean by Softmax?

moffitj commented 2 years ago

Both 1 and 2 are correct. If my values are from 0 to 2, there would be green and some light yellow but no red because I have defined 5 to be "red".

By softmax I mean that I set a max of 5 and all values in the data are colored on a scale of 0 to 5, regardless of the actual max value in the data. This is the same as Max so far. But if any values in my data go over 5, then the higher value of the data is considered the Max.

So when Softmax is implemented, Max becomes the greater of {Softmax, Data Value}

boazreicher commented 2 years ago

I've made the suggested changes, let me know if you have any comments before I submit the update to the plugin. I've added two configuration parameters:

  1. Max Type - A radio button with 3 options: From Data, Explicit or Soft Max
  2. Max - A text field for inputting an explicit max value

As an example, consider a data set with the values 1,2,3,4,5,6,7,8,9,10, and Max set to 5 When From Data is selected, the Max value has no effect fromdata When Explicit is selected: explicit_5 When Soft Max is selected: sm_5

Now with Max set to 20:

When Explicit is selected: explicit_20 When Soft Max is selected: sm_20

Does this implementation line up with what you had in mind?

moffitj commented 2 years ago

Yes that's exactly what I expected.

This will help a lot for networking and other loads where the maximum value is fixed and known.

boazreicher commented 2 years ago

I've committed the change and sent the update to Grafana for review. It will probably take several days until it is updated in the marketplace.

If you want, you can just update the plugin directly by downloading this release: v1.0.9

boazreicher commented 2 years ago

The updated plugin is now published in the marketplace

boazreicher commented 2 years ago

@moffitj did you get a chance to check the updated plugin? Can this issue be closed?

moffitj commented 2 years ago

Yes. That was a great addition. Thank you.