It is currently October 15th, 2019, 9:43 am

Using !RainmeterSetVariable to change colors of line graphs?

Help with creating, editing & fixing problems with skins
daemonsan
Posts: 1
Joined: April 3rd, 2010, 7:40 pm

Using !RainmeterSetVariable to change colors of line graphs?

daemonsan » April 3rd, 2010, 8:02 pm

I read through the thread on changing a font's color based on a measure here, and I got it to work in the context of a bar graph (in a different skin) but now its being a pain and not working. Here is the code, it is from a skin pack called 'Simple Rain' and I've been working on modifying it to my needs.

Initially the skin contains two line graphs, with histogram fills, for monitoring upload and download speeds. What I am attempting to do is make the line graphs (and the fill from the histogram) change color if the bandwidth (upload or download) exceeds a certain specified amount (around 80% of max download or 60% of max upload), and to switch back to the standard color when the throughput drops back under the threshold limits.

Here are my two problems:
  • The line colors will not change based on changes in the throughput. I have altered the thresholds and made sure I was crossing them by toggling on some FTP downloads that I know max out my 10mbit connection (which I verified with other tools) but they stubbornly remain grey. Altering the color codes in the 'initialization' of the InLineColor/OutLineColor variables properly passes to the measure, just not the set variable !bang in the NetIn/NetOut measures.
  • I don't know how to set the histogram colors - specifically I don't know if I can include multiple IfBelowAction/IfAboveAction commands, or how to properly format them. For this reason there is no histogram color change code included, except the initialization of the variable setting its default.
Any help would be appreciated and thanks ahead of time :D

Code: Select all


[Rainmeter]
Author=Mr.Black
AppVersion=14000

;Metadata added by RainBrowser
;http://rainmeter.net/RainWiki/index.php?title=Rainmeter_101#.5BMetadata.5D

[Metadata]
Name=
Config=
Description=
Instructions=
Version=
Tags=
License=
Variant=
Preview=

;End of added Metadata

[Variables]
FontName=Trebuchet MS
FontColour=255,255,255,220
FontHeight=8

InLineColor=255, 255, 255, 45
InHistColor=255,255,255,20
OutLineColor=255, 255, 255, 45
OutHistColor=255,255,255,20


;////////////////////////////////////////
;  Uptime Display
;////////////////////////////////////////


[MeasureUptime]
Measure=Uptime
Substitute="d":" day(s)",":":"h "

[MeterUptime.txt]
Meter=STRING
X=5
Y=10
FontColor=#FontColour#
FontSize=#FontHeight#
FontFace=#FontName#
AntiAlias=1
Prefix="Uptime:"

[MeterUptime]
Meter=STRING
MeasureName=MeasureUptime
X=170r
Y=0r
StringAlign=Right
FontColor=#FontColour#
FontSize=#FontHeight#
FontFace=#FontName#
Text="%1min"
AntiAlias=1

;////////////////////////////////////////
;  Network Traffic
;////////////////////////////////////////


[TCPIn]
Measure=NetIn
;Roughly 80% capacity on a 1mB line or 800k
IfAboveValue=840000
IfAboveAction=!RainmeterSetVariable InLineColor 255,0,0,255
IfBelowValue=840001
IfBelowAction=!RainmeterSetVariable InLineColor 255,255,255,45


[TCPOut]
Measure=NetOut
;Roughly 60% capacity on a 100kB upload line or 60kB
IfAboveValue=61440
IfAboveAction=!RainmeterSetVariable OutLineColor 255,0,0,255
IfBelowValue=61441
IfBelowAction=!RainmeterSetVariable OutLineColor 255,255,255,45

[TCPInAll]
Measure=NetIn
Cumulative=1

[TCPOutAll]
Measure=NetOut
Cumulative=1

[NetTraffic.txt]
;Meter=STRING
X=5
Y=20r
FontColor=#FontColour#
FontSize=#FontHeight#
FontFace=#FontName#
AntiAlias=1
Text="Network Traffic:"

[TCPIn1]
Meter=HISTOGRAM
MeasureName=TCPIn
X=5
Y=15r
H=27
W=80
PrimaryColor=#InHistColor#
AntiAlias=1
AutoScale=1
DynamicVariables=1

[TCPOut1]
Meter=HISTOGRAM
MeasureName=TCPOut
X=95
Y=0r
H=27
W=80
PrimaryColor=#OutHistColor#
AntiAlias=1
AutoScale=1
DynamicVariables=1

[TCPIn2]
Meter=Line
MeasureName=TCPIn
X=5
Y=0r
H=28
W=80
LineCount=1
DynamicVariables=1
LineColor=#InLineColor#
AntiAlias=1
AutoScale=1

[TCPOut2]
Meter=Line
MeasureName=TCPOut
X=95
Y=0r
H=28
W=80
LineCount=1
LineColor=#OutLineColor#
AntiAlias=1
AutoScale=1
DynamicVariables=1

[NetIn]
Meter=STRING
MeasureName=TCPIn
X=5
Y=0r
FontColor=#FontColour#
FontSize=6
FontFace=#FontName#
AntiAlias=1
AutoScale=1
Text="In: %1B"

[NetOut]
Meter=STRING
MeasureName=TCPOut
X=95
Y=0r
FontColor=#FontColour#
FontSize=6
FontFace=#FontName#
AntiAlias=1
AutoScale=1
Text="Out: %1B"

[MeterRefresh]
Meter=IMAGE
SolidColor=255,255,0,255
x=1r
y=0r
H=20
W=20
LeftMouseDownAction=!RainmeterRefresh
wasky1
Posts: 128
Joined: June 10th, 2009, 8:26 am

Re: Using !RainmeterSetVariable to change colors of line graphs?

wasky1 » April 3rd, 2010, 9:05 pm

try putting the setvariable commands on a calc eg

[Calc0]
Measure=Calc
Formula=[TCPIn]
IfAboveValue=
IfAboveAction=
DynamicVariables=1

maybe this will work
User avatar
Alex2539
Rainmeter Sage
Posts: 648
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: Using !RainmeterSetVariable to change colors of line graphs?

Alex2539 » April 3rd, 2010, 9:32 pm

Wasky, please stop making unhelpful posts. All your post is doing is leading him on the wrong path. If you don't know the answer, don't post just for the sake of posting. Normally I wouldn't say anything, but you do it all the time. It's not helpful, it's just clutter.

The colour change is working just fine for me. Some things you have to keep in mind are that it will only change if the rate is currently higher than the value you set, so just because the graph has a peak doesn't mean that it's going to stay red. Also the rate is in bits/sec not bytes/sec, so it's possible you're just not reaching those speeds as often as you think you are. If you really want to be sure that the colours are changing properly, you can temporarily drop the IfAbove/Below values to something really low that you know will be exceeded fairly often (maybe divide them by 10 or something). That way, while you're testing the skin you can make sure it works properly, then change them back to something useful when it's done.

As for changing the histogram; when you want to have multiple bangs fire on a single action, precede them by the !Execute bang and then encase them in [square brackets], like so:

Code: Select all

...
IfAboveAction=!Execute [!RainmeterSetVariable InLineColor 255,0,0,255][!RainmeterSetVariable InHistColor 255,0,0,128]
...
Of course, you can use your own values, those numbers are just a suggestion.
ImageImageImageImage
wasky1
Posts: 128
Joined: June 10th, 2009, 8:26 am

Re: Using !RainmeterSetVariable to change colors of line graphs?

wasky1 » April 3rd, 2010, 9:40 pm

Alex2539 wrote:Wasky, please stop making unhelpful posts. All your post is doing is leading him on the wrong path. If you don't know the answer, don't post just for the sake of posting. Normally I wouldn't say anything, but you do it all the time. It's not helpful, it's just clutter.

The colour change is working just fine for me. Some things you have to keep in mind are that it will only change if the rate is currently higher than the value you set, so just because the graph has a peak doesn't mean that it's going to stay red. Also the rate is in bits/sec not bytes/sec, so it's possible you're just not reaching those speeds as often as you think you are. If you really want to be sure that the colours are changing properly, you can temporarily drop the IfAbove/Below values to something really low that you know will be exceeded fairly often (maybe divide them by 10 or something). That way, while you're testing the skin you can make sure it works properly, then change them back to something useful when it's done.

As for changing the histogram; when you want to have multiple bangs fire on a single action, precede them by the !Execute bang and then encase them in [square brackets], like so:

Code: Select all

...
IfAboveAction=!Execute [!RainmeterSetVariable InLineColor 255,0,0,255][!RainmeterSetVariable InHistColor 255,0,0,128]
...
Of course, you can use your own values, those numbers are just a suggestion.
fair enough i will not post anymore i was just trying to help.

goodbye