Page 1 of 1

Histogram & Line MinValue bug

Posted: March 26th, 2018, 2:31 am
by Saigo
When applying a Measure with MinValue and MaxValue, the Histogram and Line meter will bug out. Anything other than 0 for MinValue will cause the Histogram & Line meter to show nothing.

Please take a look at line 451 and line 513 of MeterHistogram.cpp https://github.com/rainmeter/rainmeter/blob/master/Library/MeterHistogram.cpp

Code: Select all

	double value = (m_MaxPrimaryValue == 0.0) ?
		  0.0
		: m_PrimaryValues[(i + m_MeterPos) % meterRect.Width] / m_MaxPrimaryValue;
	value -= m_MinPrimaryValue;
If the values of some Measure return something from lets say 10 to 20, then MinValue = 10 and MaxValue = 20.
Given the value to be lets say 15, then:

EX:
double value = 15/20; // 0.75
value -= 10; // -9.25

Next the actual bar height in pixels is calculated:

Code: Select all

	int primaryBarHeight = (int)(meterRect.Height * value);
	primaryBarHeight = min(meterRect.Height, primaryBarHeight);
	primaryBarHeight = max(0, primaryBarHeight);
Because value is negative, the height will remain 0.

This should be corrected by doing this:

Code: Select all

	double value = (m_MaxPrimaryValue == 0.0) ?
		  0.0
		: (m_PrimaryValues[(i + m_MeterPos) % meterRect.Width] - m_MinPrimaryValue) / (m_MaxPrimaryValue-m_MinPrimaryValue);
EX:
double value = (15-10)/(20-10); // 0.5

Thus when the actual bar height is calculated, it will return the correct result.

The Bar meter uses relative value which is why it does not have this problem.

Please include this fix in the next update.

Re: Histogram & Line MinValue bug

Posted: March 26th, 2018, 1:03 pm
by jsmorley
We will look at this right away. Thanks for reporting!

Re: Histogram & Line MinValue bug

Posted: September 20th, 2022, 6:05 am
by Brian
Thanks for this bug report. This has finally been fixed. Sorry it took so long to get to. :oops:

Further discussion here: https://forum.rainmeter.net/viewtopic.php?t=41330

-Brian