It is currently September 29th, 2022, 5:36 pm

Histogram & Line MinValue bug

Report bugs with the Rainmeter application and suggest features.
Saigo
Posts: 1
Joined: March 26th, 2018, 2:21 am

Histogram & Line MinValue bug

Post 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.
User avatar
jsmorley
Developer
Posts: 22547
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Histogram & Line MinValue bug

Post by jsmorley »

We will look at this right away. Thanks for reporting!
User avatar
Brian
Developer
Posts: 2512
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Histogram & Line MinValue bug

Post 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