It is currently May 9th, 2021, 5:22 pm

## how to display current max autoscale histogram

General topics related to Rainmeter.
TGonZo
Posts: 55
Joined: April 25th, 2015, 8:19 pm
Location: Virginia

### how to display current max autoscale histogram

Hi all,

I'm creating a basic Disk Meter of Bytes/sec with a histogram in autoscale.
It works great, but I would like to display the current max value of the histogram, to give context to the data being shown.
I've looked through the docs and searched the forum, and have no answer.

Can this be done? If so, any help would be much appreciated.

Thanks all.
balala
Rainmeter Sage
Posts: 12638
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: how to display current max autoscale histogram

As you didn't post any code, I took this from the manual (the example of the Histogram section), adding a few measures and meters:

Code: Select all

``````[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=ExampleMeterHistogram
Author=The Rainmeter Team
Information=Example of the Histogram meter
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Version=1.0

[MeasureCPU]
Measure=CPU

[MeasureCPUMax]
Measure=Calc
Formula=(( MeasureCPU > MeasureCPUMax ) ? MeasureCPU : MeasureCPUMax )

[MeterCPUBackgroundImage]
Meter=Image
SolidColor=24,102,10
X=0
Y=0
W=220
H=70

[MeterCPUHistogram]
Meter=Histogram
MeasureName=MeasureCPU
X=5
Y=5
W=210
H=60
PrimaryColor=255,255,255,255
SolidColor=0,0,0,100
AntiAlias=1

[MeterCPUMax]
Meter=Image
X=5
Y=([MeterCPUHistogram:H]*(1-([MeasureCPUMax]/100))+[MeterCPUHistogram:Y])
W=210
H=1
SolidColor=255,0,0
DynamicVariables=1

[MeterCPUText]
Meter=String
MeasureName=MeasureCPU
MeasureName2=MeasureCPUMax
X=110
Y=80
FontSize=13
FontColor=255,255,255,255
StringAlign=Center
AntiAlias=1
Text=CPU Usage: %1%#CRLF#Max: %2%``````
the new measure is [MeasureCPUMax] and the new meter [MeterCPUMax]. Also modified a bit the [MeterCPUMax], adding the MeasureName2 option and modifying the Text option.
fonpaolo
Moderator
Posts: 1388
Joined: April 11th, 2013, 8:08 pm
Location: Italy

### Re: how to display current max autoscale histogram

Just as a side note, you can also use this formula to obtain the Max value:

Code: Select all

``````[MeasureCPUMax]
Measure=Calc
Formula=Max(MeasureCPU, MeasureCPUMax)``````
TGonZo
Posts: 55
Joined: April 25th, 2015, 8:19 pm
Location: Virginia

### Re: how to display current max autoscale histogram

Thanks for the reply. I see some interesting code that may be helpful later. But in both cases, it appears to return the max value up to that point in time.

I am looking for what the Histogram max is actually set to when it is running in autoscale. Meaning the scale is changing depending on the data that is being displayed in the Histogram at that moment. Meaning, is the Histogram displaying a max of 4k Bytes/sec or is it displaying a max of 150M Bytes/sec. And then after the large data scrolls off the Histogram, it rescales back down to a small value. How can I get the Histogram max value, not a measure max value?

Here is a very simple meter I'm working with for now. C drive Read Bytes/sec, histogram, autoscale. As the drive goes from being quiet to large reads and then back to being quiet, the scale of the Histogram changes. How do I get and display that scale.

Example, when it first starts up, it may be scaled at about 32kB/sec max, then you do a large read and the scale changes to 200MB/sec max, and when that large part scrolls off the Histogram, the scale drops back down to 80kB/sec max. I what to display that changing max.

Thanks again.

Code: Select all

``````[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=0,0,0,100
BackgroundMargins=0,0,0,10

[Variables]
fontName=Trebuchet MS
textSize=8

;------------------------------
;------------------------------

[MeasureDiskReadBytesC]
; Measures disk access of the C: drive.
Measure=Plugin
Plugin=PerfMon
PerfMonObject=LogicalDisk
PerfMonCounter=Disk Read Bytes/sec
PerfMonInstance=C:

;------------------------------
;------------------------------

[styleLeftText]
StringAlign=Left
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

;------------------------------
;------------------------------

[MeterReadBytesHistogramC]
Meter=Histogram
MeasureName=MeasureDiskReadBytesC
X=10
Y=10
W=80
H=40
PrimaryColor=100,150,250,220
SolidColor=0,0,0,100
AntiAlias=1
AutoScale=1

[MeterDiskReadBytesC2]
Meter=String
MeterStyle=styleLeftText
MeasureName=MeasureDiskReadBytesC
X=90
Y=10r
W=120
H=20
FontColor=255,255,255,255
AutoScale=1
Text=Read C: %1B/sec

;------------------------------

``````
balala
Rainmeter Sage
Posts: 12638
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: how to display current max autoscale histogram

It seems that I (we) misunderstood you. Now I see what you'd like.
The histogram meter uses values returned by percentual measures. In some cases (like yours), the measure sets the MinValue and MaxValue of the measure dynamically, to the smallest and largest values the measure has been since the skin was loaded or refreshed. That's why when the amount of data changes dramaticaly, the histogram is rescaled.
I think the solution would be similar: add this measure to the skin:

Code: Select all

``````[MeasureMax]
Measure=Calc
Formula=( Max ( MeasureMax, MeasureDiskReadBytesC ))``````
and change the [MeterDiskReadBytesC2] string meter:

Code: Select all

``````[MeterDiskReadBytesC2]
Meter=String
MeterStyle=styleLeftText
MeasureName=MeasureDiskReadBytesC
MeasureName2=MeasureMax
X=90
Y=10r
W=120
H=25
FontColor=255,255,255,255
AutoScale=1
Text=Read C: %1B/sec#CRLF#Max C: %2B/sec``````
TGonZo
Posts: 55
Joined: April 25th, 2015, 8:19 pm
Location: Virginia

### Re: how to display current max autoscale histogram

Thanks Balala, but that does not seem to be it. I gave that code a try, and it's not scaling the Max value down when the Histogram autoscales down. It retains the max value from the measure and never goes back down. Also it is not always the max value of the Histogram.

When I see my disk read jump up to say 200MB/sec, I can see that peak data point does not touch the top of the Histogram. I suspect the histogram has rescaled it's display to something like 220MB/sec, and therefore the 200MB data point does not touch the top. I'd like to display the actual Histogram max value, in my example here, 220MB/sec. And when the Histogram scrolls that data off, it then autoscales down. I want to update my Histogram max from the 220MB down to whatever it dropped to.

I want the actual Histogram max value of the Histogram display, not the measure data.

Thanks for your efforts. Maybe the above explanation will help.

I'm starting to suspect there is no way to do this.

Has anyone ever seen a Rainmeter autoscale Histogram show is current Max display value and see it go up and down as it autoscales? If so, I'd like to see that code.

Thanks again. Someone out there knows this answer.
jsmorley, you care to comment here?
balala
Rainmeter Sage
Posts: 12638
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: how to display current max autoscale histogram

Another idea, but still seems to not be the best solution:

Code: Select all

``````[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=0,0,0,100
BackgroundMargins=0,0,0,10

[Variables]
fontName=Trebuchet MS
textSize=8

[MeasureDiskReadBytesC]
Measure=Plugin
Plugin=PerfMon
PerfMonObject=LogicalDisk
PerfMonCounter=Disk Read Bytes/sec
PerfMonInstance=C:

[styleLeftText]
StringAlign=Left
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[MeterReadBytesHistogramC]
Meter=Histogram
MeasureName=MeasureDiskReadBytesC
X=10
Y=10
W=80
H=40
PrimaryColor=100,150,250,220
SolidColor=0,0,0,100
AntiAlias=1
AutoScale=1

[MeasureMax]
Measure=Calc
Formula=[MeasureDiskReadBytesC:MaxValue]
DynamicVariables=1

[MeterDiskReadBytesC2]
Meter=String
MeterStyle=styleLeftText
MeasureName=MeasureDiskReadBytesC
MeasureName2=MeasureMax
X=90
Y=10r
W=120
H=25
FontColor=255,255,255,255
AutoScale=1
Text=Read C: %1B/sec#CRLF#Max C: %2B/sec``````
This time the [MeasureMax] measure, should return the largest value ([MeasureDiskReadBytesC:MaxValue]). Usualy it is, but when the histogram is autoscaled down, the maximum value isn't updated, it doesn't decrease.
jsmorley
Developer
Posts: 21681
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

### Re: how to display current max autoscale histogram

If I understand correctly, then not really any easy way I can think of right off.

The "scale" that is used by Histogram when it does AutoScale is not something you can know, but is just internal to the meter. So in effect you would probably need to somehow "save" the maximum value of the measure. However, not the maximum since the skin was loaded or refreshed, but the maximum of the last XX "running values returned" in a first-in-first-out dynamic list. Even getting the "maximum" of a "list" is not trivial in Rainmeter.

Hard to say what number XX would be as that will vary depending on the width of the meter and how often it is updated. I'm not sure there is any formula that could figure that out on its own.

That aside, probably possible with some moderately complicated Lua code, but can't think of a way in pure Rainmeter that makes sense.

Getting the maximum that the measure has reached is not hard at all. Getting the maximum of what is currently visible in the meter, which I gather is what you really mean, is not going to be easy at all. Maybe here is some way to say "if the meter is 200 pixels wide and updating once a second, that is 15 data points visible in the meter.", but I have no idea if that is possible or what such a formula would be.

Keeping track of the last 10 values returned isn't particularly scary, but I'm not sure how you can ever easily know that that number should be "10", and if you don't nail it, things won't match up with what is displayed in the meter.
TGonZo
Posts: 55
Joined: April 25th, 2015, 8:19 pm
Location: Virginia

### Re: how to display current max autoscale histogram

Thanks for the explanation. I was hoping for some secret sauce on this one. I may look into Lua scripting a bit later.

So, I officially request an enhancement for a variable in the Histogram meter, and maybe Line meter also, to be used for read/view/display of the current max display value.

Please!!!!

Thanks all.
Shakul
Posts: 1
Joined: April 6th, 2021, 8:49 am

### Re: how to display current max autoscale histogram

Hello. For anybody looking for max value in histogram down bellow is the script. If you want fully working widget here's the .ini file of the widget
CPU and network.ini
You need to create DownloadLocalMax.lua and UploadLocalMax.lua files, paste the code bellow inside and place them in the same folder as .ini file like this
image_2021-04-06_105722.png
To get fully working widget you need to modify the script in the UploadLocalMax.lua like this
SKIN:GetMeter('DownloadHistogram') ====> SKIN:GetMeter('UploadHistogram')
SKIN:GetMeasure('MeasureDownload') ====> SKIN:GetMeasure('MeasureUpload')

Code: Select all

``````function Initialize()
HistogramWidth = SKIN:GetMeter('DownloadHistogram'):GetW()
NetSpeedMeasure = SKIN:GetMeasure('MeasureDownload')
Index = 0
Speeds = {}
MaxValue = 0
CurrValue = 0
end

function Update()
Index = Index + 1
if Index > HistogramWidth then Index = 1 end

CurrValue = NetSpeedMeasure:GetValue()

if CurrValue > MaxValue then
Speeds[Index] = CurrValue
MaxValue = CurrValue
elseif Speeds[Index] == MaxValue and MaxValue ~= 0 then
Speeds[Index] = CurrValue
SetMax()
else
Speeds[Index] = CurrValue
end

return MaxValue
end

function SetMax()
MaxValue = Speeds[1]
for i = 2, #Speeds do
if MaxValue < Speeds[i] then
MaxValue = Speeds[i]
end
end
end``````
You do not have the required permissions to view the files attached to this post.