It is currently April 19th, 2024, 8:55 pm

[Bug] Histogram doesn't work if measure's MinValue is not 0

Report bugs with the Rainmeter application and suggest features.
User avatar
killall-q
Posts: 305
Joined: August 14th, 2009, 8:04 am

[Bug] Histogram doesn't work if measure's MinValue is not 0

Post by killall-q »

Histogram meters only work if MinValue is 0, or, for non-zero MinValue values, if the return value is between (MinValue * MaxValue) and ((MinValue + 1) * MaxValue).

Simple test skin for proof:

Code: Select all

; ---------------MEASURES---------------

[Measure]
Measure=Calc
Formula=45
MinValue=20
MaxValue=60

; ----------------STYLES----------------

[sGraph]
Y=10R
W=200
H=60
SolidColor=20202080

; ----------------METERS----------------

[Bar]
Meter=Bar
MeasureName=Measure
MeterStyle=sGraph
Y=0
H=20
BarOrientation=Horizontal

[Histogram]
Meter=Histogram
MeasureName=Measure
MeterStyle=sGraph

[Line]
Meter=Line
MeasureName=Measure
MeterStyle=sGraph

[Roundline]
Meter=Roundline
MeasureName=Measure
MeterStyle=sGraph
H=200
LineLength=100
LineColor=0,128,0
Solid=1
A clue to the cause of this bug is that MeterHistogram.cpp is the only meter to contain GetMinValue(). So perhaps values are already being clamped to range elsewhere, and the histogram is doing it again, screwing up the output.

Pretty major bug, probably been around for years, amazing that no one has ever reported this.
Last edited by killall-q on September 20th, 2022, 6:53 pm, edited 2 times in total.
Judian81
Posts: 180
Joined: May 6th, 2021, 2:57 pm

Re: [Bug] Histogram doesn't work if measure's MinValue is not 0

Post by Judian81 »

and what if you do MinValue=0.20?

i do not understand why, but it does something.
User avatar
killall-q
Posts: 305
Joined: August 14th, 2009, 8:04 am

Re: [Bug] Histogram doesn't work if measure's MinValue is not 0

Post by killall-q »

As I explained above, with the current bugged behavior, for non-zero MinValue values, MinValue acts as a multiplier for the "window" within which the histogram will display something. So, for MinValue=0.2 and, e.g. MaxValue=100, the histogram will display measure values between 20 and 120.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5397
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: [Bug] Histogram doesn't work if measure's MinValue is not 0

Post by eclectic-tech »

There was a suggestion several years ago regarding the MinValue for Histogram and Line meters:
https://forum.rainmeter.net/viewtopic.php?p=146360&hilit=histogram#p146354

Not sure what the decision was, but it may not have been implemented for fear of not being backwardly compatible... :confused:
User avatar
killall-q
Posts: 305
Joined: August 14th, 2009, 8:04 am

Re: [Bug] Histogram doesn't work if measure's MinValue is not 0

Post by killall-q »

There's no backwards compatibility issue here, nor was it mentioned, because currently, the only sane way to use histograms is with MinValue either unset or set to 0.

No one is using fancy math to wrangle the intended functionality out of the bugged functionality, and even if they were to try, they would be very limited in what they could do, e.g. you currently cannot make a histogram display measure values between 60 and 100. There is nothing of value in this bug worth preserving.

It was not fixed simply due to negligence.
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Bug] Histogram doesn't work if measure's MinValue is not 0

Post by Brian »

Thanks for the bug report. I believe this to be fixed for the next release. In the meantime, here is a test build if you want to test it.
https://builds.rainmeter.net/test_builds/Rainmeter-4.5.15.3672-prerelease.exe

The reason this took so long to fix is mainly because the original code for this was written nearly 20 years ago. The fix (thanks for the link eclectic-tech!), works fine for Histogram....but then the Line meter doesn't match with what Histogram is doing. It looks like the Line meter didn't even take the MinValue into consideration at all.

Histogram and Line meters are often used together to create a fill/stroke combination. Getting the drawing calculations "right" is difficult because of several factors. First, the Line meter has the ScaleN option, but Histogram does not. Second, the Line meters supports any number of measures, while the Histogram only supports a max of 2 measures. Third, both have the AutoScale option which attempts to do further scaling on all the measured values.

Those 3 issues are the main reason this was "neglected"...well that, and the lack of developers since the issue was first reported. Given all of our schedules and lack of man power, sometimes these things fall through the cracks.

On backwards compatibility. This is one of our top priorities and we take great care to assure that skins made years ago still work (at least from a measuring and drawing standpoint). This is one of Rainmeter's greatest strengths. So, for this fix, there is some backwards compatibility issues, but like killall-q stated, the risk should be minimal. I don't think MinValue is used too often.

-Brian
User avatar
killall-q
Posts: 305
Joined: August 14th, 2009, 8:04 am

Re: [Bug] Histogram doesn't work if measure's MinValue is not 0

Post by killall-q »

Thanks for working on this.

Some test results: Histogram passes all tests so far. Line meter works for positive MinValue and MaxValue values, but falls apart with negative MinValue and MaxValue.

Line meter shows nothing for

Code: Select all

[Measure]
Measure=Calc
Formula=-40
MinValue=-60
MaxValue=-10
Same for

Code: Select all

[Measure]
Measure=Calc
Formula=-40
MinValue=-60
MaxValue=60
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Bug] Histogram doesn't work if measure's MinValue is not 0

Post by balala »

killall-q wrote: September 18th, 2022, 1:38 am Some test results: Histogram passes all tests so far.
Are you sure? It doesn't, I think. Not the Line, nor the Histogram meter doesn't work, none of them shows nothing with neither one of the posted [Measure] measures, same as in any other case when the MinValue or MaxValue are negative.
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Bug] Histogram doesn't work if measure's MinValue is not 0

Post by Brian »

killall-q wrote: September 18th, 2022, 1:38 am Some test results: Histogram passes all tests so far. Line meter works for positive MinValue and MaxValue values, but falls apart with negative MinValue and MaxValue.
Thanks for testing. I had a brain fart on the negative values, well the "initialization" part of it anyway.

I think I have it all sorted out *hopefully*. Here is another test build:
https://builds.rainmeter.net/test_builds/Rainmeter-4.5.15.3673-prerelease.exe

balala wrote: September 18th, 2022, 7:54 am Are you sure? It doesn't, I think. Not the Line, nor the Histogram meter doesn't work, none of them shows nothing with neither one of the posted [Measure] measures, same as in any other case when the MinValue or MaxValue are negative.
With the previous "test" build, it should show the histogram okay, but not the line meter (it just stays at the bottom of the meter). Remember that the initial value of the measure is 0, so when the meter (both Histogram and Line) are initialized, it fills the "drawing" buffer with 0's. Then the Histogram and Line draw where 0 would be located on the graph before filling the drawing buffer with the measures value over time (for both test cases, this value is -40). Hopefully that makes sense.

-Brian
User avatar
killall-q
Posts: 305
Joined: August 14th, 2009, 8:04 am

Re: [Bug] Histogram doesn't work if measure's MinValue is not 0

Post by killall-q »

Everything passes now. A last couple tests that I don't even know what the result should be:

Code: Select all

Formula=-40
MinValue=0
MaxValue=-50

Code: Select all

Formula=40
MinValue=50
MaxValue=0
For these, every meter returns nothing (equivalent to no measure value), except line meter displays results as if min and max value weren't swapped.