It is currently April 28th, 2024, 6:53 pm

Trailing Zeros

General topics related to Rainmeter.
User avatar
balala
Rainmeter Sage
Posts: 16185
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trailing Zeros

Post by balala »

Resike wrote:To be honest even i don't know what i want yet, i'm just bouncing ideas and i will decide based on the results.

The main idea would be for the user to see if the price-percentage went up or down since the last update. And relatively how big was that value change.

I can point you to this little graph:

http://addgadgets.com/image/currency_meter.png
Please post the code you have so far, to can take a look.
Resike
Posts: 33
Joined: May 1st, 2015, 1:25 am

Re: Trailing Zeros

Post by Resike »

Not sure where could i upload it?
User avatar
balala
Rainmeter Sage
Posts: 16185
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trailing Zeros

Post by balala »

Pack it to a zip or rmskin format (last one can be created using the Create rmskin package... button on the Skins tab of the Manage Rainmeter window). Then attach the created file, using the Upload attachement section here, where you post reply.
Maybe alternatively you coud upload just the code (use the Code button above), but use this only if you don't have needed resources (images, inc files and so on).
Resike
Posts: 33
Joined: May 1st, 2015, 1:25 am

Re: Trailing Zeros

Post by Resike »

Here is it.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trailing Zeros

Post by jsmorley »

I'd be tempted with something like this. I use a little Lua to save the "old" price for comparison with the "new" price, and then had the skin take some actions based on rising or falling values.
LineCompare_1.0.rmskin
No change:
1.png
Lower:
2.png
Higher:
3.png
LineCompare.ini:

Code: Select all

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

[Variables]
OldValue=1.3

[MeasureValue]
Measure=Plugin
Plugin=WebParser
URL=file://#CURRENTPATH#Example.html
RegExp=(?siU)<price>(.*)</price>
UpdateRate=10
StringIndex=1
FinishAction=[!UpdateMeasure MeasureNumValue][!EnableMeasure MeasureCompareScript][!UpdateMeasure MeasureCompareScript][!UpdateMeter MeterLine]

[MeasureNumValue]
Measure=Calc
Formula=[MeasureValue]
MinValue=0
MaxValue=4
DynamicVariables=1

[MeasureCompareScript]
Measure=Script
ScriptFile=#CURRENTPATH#LineCompare.lua
Disabled=1
UpdateDivider=-1

[MeterLine]
Meter=Line
MeasureName=MeasureNumValue
W=300
H=100
LineColor=230,245,252,255
SolidColor=23,77,105,255
AntiAlias=1
UpdateDivider=-1

[MeterOldValue]
Meter=String
X=10
Y=5R
FontSize=11
FontColor=255,255,255,255
AntiAlias=1
NumOfDecimals=4
Text=1.1000

[MeterChangeValue]
Meter=String
MeasureName=MeasureNumValue
X=150
Y=0r
StringAlign=Center
FontSize=11
FontColor=255,255,255,255
AntiAlias=1
NumOfDecimals=4
Text=+ 0.1000

[MeterNewValue]
Meter=String
MeasureName=MeasureNumValue
X=290
Y=0r
StringAlign=Right
FontSize=11
FontColor=255,255,255,255
AntiAlias=1
NumOfDecimals=4
Text=%1
LineCompare.lua:

Code: Select all

function Initialize()

	measureValue = SKIN:GetMeasure('MeasureNumValue')
	
end

function Update()

	oldValue = tonumber(SKIN:GetVariable('OldValue'))
	newValue = tonumber(measureValue:GetValue())
	
	SKIN:Bang('!SetOption', 'MeterOldValue', 'Text', PadZero(oldValue))
	
	if newValue < oldValue then
		SKIN:Bang('!SetOption', 'MeterChangeValue', 'Text', '- '..PadZero(oldValue - newValue))
		SKIN:Bang('!SetOption', 'MeterChangeValue', 'FontColor', '237,159,159,255')
	end
	
	if newValue > oldValue then
		SKIN:Bang('!SetOption', 'MeterChangeValue', 'Text', '+ '..PadZero(newValue - oldValue))
		SKIN:Bang('!SetOption', 'MeterChangeValue', 'FontColor', '159,237,164,255')	
	end
	
	if newValue == oldValue then
		SKIN:Bang('!SetOption', 'MeterChangeValue', 'Text', '+/- '..PadZero('0'))
		SKIN:Bang('!SetOption', 'MeterChangeValue', 'FontColor', '200,200,200,255')
	end
	
	SKIN:Bang('!SetVariable', 'OldValue', newValue)
	SKIN:Bang('!WriteKeyValue', 'Variables', 'OldValue', newValue)
	
	return newValue

end

function PadZero(arg)

	return string.format("%.4f", arg)

end
Example.html:

Code: Select all

<price>1.3000</price>
You can test by simply opening Example.html, changing the value, and saving it. I have UpdateRate=10 on the WebParser measure, just for testing. Do NOT leave a value that low when hitting an actual site.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trailing Zeros

Post by jsmorley »

Just one last example, which also touches on the the "broken range functionality" in the Line meter balala and I were discussing:
TempLine_1.0.rmskin

Code: Select all

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

[Variables]
Location=23418210
Unit=f
OldValue=83
RangeLow=-20
RangeHigh=110

[MeasureValue]
Measure=Plugin
Plugin=WebParser
URL=http://weather.yahooapis.com/forecastrss?w=#Location#&u=#Unit#
RegExp=(?siU)<yweather:condition.*temp="(.*)"
UpdateRate=600
StringIndex=1
FinishAction=[!UpdateMeasure MeasureNumValue][!UpdateMeasure MeasurePercent][!EnableMeasure MeasureCompareScript][!UpdateMeasure MeasureCompareScript][!ShowMeterGroup AllMeters][!UpdateMeter MeterLine]

[MeasureNumValue]
Measure=Calc
Formula=[MeasureValue]
MinValue=#RangeLow#
MaxValue=#RangeHigh#
DynamicVariables=1

[MeasurePercent]
Measure=Calc
Formula=[MeasureNumValue:%]
MinValue=0
MaxValue=100
DynamicVariables=1

[MeasureCompareScript]
Measure=Script
ScriptFile=#CURRENTPATH#TempLine.lua
Disabled=1
UpdateDivider=-1

[MeterLine]
Meter=Line
Group=AllMeters
MeasureName=MeasurePercent
W=300
H=100
LineColor=230,245,252,255
SolidColor=23,77,105,255
AntiAlias=1
UpdateDivider=-1
Hidden=1

[MeterOldValue]
Meter=String
Group=AllMeters
X=10
Y=5R
FontSize=11
FontColor=255,255,255,255
AntiAlias=1
Hidden=1

[MeterChangeValue]
Meter=String
Group=AllMeters
X=150
Y=0r
StringAlign=Center
FontSize=11
FontColor=255,255,255,255
AntiAlias=1
Hidden=1

[MeterNewValue]
Meter=String
Group=AllMeters
MeasureName=MeasureNumValue
X=290
Y=0r
StringAlign=Right
FontSize=11
FontColor=255,255,255,255
AntiAlias=1
Text=%1°F
Hidden=1
1.png
Does much the same thing with "temperatures" from a weather site, while properly dealing with the fact that for Fahrenheit, the range can likely be from -20 to 110 some places in the world. Tracks the temperature over time in the Line meter, showing the relative "change" every 10 minutes.

Ok, if it is ever -20 or 110 degrees in Virginia, I'm moving...
You do not have the required permissions to view the files attached to this post.
Resike
Posts: 33
Joined: May 1st, 2015, 1:25 am

Re: Trailing Zeros

Post by Resike »

jsmorley wrote:Just one last example, which also touches on the the "broken range functionality" in the Line meter balala and I were discussing:
TempLine_1.0.rmskin

Code: Select all

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

[Variables]
Location=23418210
Unit=f
OldValue=83
RangeLow=-20
RangeHigh=110

[MeasureValue]
Measure=Plugin
Plugin=WebParser
URL=http://weather.yahooapis.com/forecastrss?w=#Location#&u=#Unit#
RegExp=(?siU)<yweather:condition.*temp="(.*)"
UpdateRate=600
StringIndex=1
FinishAction=[!UpdateMeasure MeasureNumValue][!UpdateMeasure MeasurePercent][!EnableMeasure MeasureCompareScript][!UpdateMeasure MeasureCompareScript][!ShowMeterGroup AllMeters][!UpdateMeter MeterLine]

[MeasureNumValue]
Measure=Calc
Formula=[MeasureValue]
MinValue=#RangeLow#
MaxValue=#RangeHigh#
DynamicVariables=1

[MeasurePercent]
Measure=Calc
Formula=[MeasureNumValue:%]
MinValue=0
MaxValue=100
DynamicVariables=1

[MeasureCompareScript]
Measure=Script
ScriptFile=#CURRENTPATH#TempLine.lua
Disabled=1
UpdateDivider=-1

[MeterLine]
Meter=Line
Group=AllMeters
MeasureName=MeasurePercent
W=300
H=100
LineColor=230,245,252,255
SolidColor=23,77,105,255
AntiAlias=1
UpdateDivider=-1
Hidden=1

[MeterOldValue]
Meter=String
Group=AllMeters
X=10
Y=5R
FontSize=11
FontColor=255,255,255,255
AntiAlias=1
Hidden=1

[MeterChangeValue]
Meter=String
Group=AllMeters
X=150
Y=0r
StringAlign=Center
FontSize=11
FontColor=255,255,255,255
AntiAlias=1
Hidden=1

[MeterNewValue]
Meter=String
Group=AllMeters
MeasureName=MeasureNumValue
X=290
Y=0r
StringAlign=Right
FontSize=11
FontColor=255,255,255,255
AntiAlias=1
Text=%1°F
Hidden=1
1.png
Does much the same thing with "temperatures" from a weather site, while properly dealing with the fact that for Fahrenheit, the range can likely be from -20 to 110 some places in the world. Tracks the temperature over time in the Line meter, showing the relative "change" every 10 minutes.

Ok, if it is ever -20 or 110 degrees in Virginia, I'm moving...
Thats pretty neat, i made a smaller change to allow the line to dyamically strech it's maxvalue, however it's still not really working for the minus values. Would be awsome if it could handle thoose values too.
You do not have the required permissions to view the files attached to this post.
Resike
Posts: 33
Joined: May 1st, 2015, 1:25 am

Re: Trailing Zeros

Post by Resike »

Is it possbile to show an image like this one in rainmeter?

http://chart.finance.yahoo.com/b?s=USDHUF=X&lang=en-US&region=US
Last edited by Resike on May 23rd, 2015, 10:58 am, edited 1 time in total.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Trailing Zeros

Post by moshi »

Resike
Posts: 33
Joined: May 1st, 2015, 1:25 am

Re: Trailing Zeros

Post by Resike »