Histogram & Line MinValue bug
Posted: March 26th, 2018, 2:31 am
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
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:
Because value is negative, the height will remain 0.
This should be corrected by doing this:
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.
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;
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);
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);
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.