It is currently May 13th, 2024, 5:35 am

Radar Chart

General topics related to Rainmeter.
JayVodka
Posts: 9
Joined: January 14th, 2012, 5:37 am

Radar Chart

Post by JayVodka »

I want to create a radar chart with something like CPU freespace as variables. Is there a way to do this?

For Reference:
http://en.wikipedia.org/wiki/Radar_chart
Last edited by JayVodka on January 14th, 2012, 6:50 am, edited 1 time in total.
User avatar
XANCI
Posts: 104
Joined: September 18th, 2011, 6:37 am
Location: Nanjing, China

Re: Radar Chart

Post by XANCI »

possible with some BarMeters/Rotators and a bit math
JayVodka
Posts: 9
Joined: January 14th, 2012, 5:37 am

Re: Radar Chart

Post by JayVodka »

XANCI wrote:possible with some BarMeters/Rotators and a bit math
Could you explain to me how that would be done on a conceptual level? Saying that a graph would need to measure stuff and uses math isn't very progressive.
User avatar
XANCI
Posts: 104
Joined: September 18th, 2011, 6:37 am
Location: Nanjing, China

Re: Radar Chart

Post by XANCI »

skin file:

Code: Select all

[ms]
Measure=Script
ScriptFile="#CURRENTPATH#t.lua"

[mCPU1]
Measure=CPU
Processor=1

[mCPU2]
Measure=CPU
Processor=2

[bg]
Meter=IMAGE
W=240
H=240
SolidColor=FFFFFF

[mt1]
Meter=IMAGE
X=120
Y=120
W=100
H=1
SolidColor=000000
AntiAlias=1
TransformationMatrix=0;-1;1;0;0;240

[mt2]
Meter=IMAGE
X=120
Y=120
W=100
H=1
SolidColor=000000
AntiAlias=1
TransformationMatrix=0.866;-0.5;0.5;0.866;-43.92;76.08

[mt3]
Meter=IMAGE
SolidColor=0000FF
W=1
H=1
AntiAlias=1
DynamicVariables=1
t.lua file:

Code: Select all

function Initialize()
	msC1=SKIN:GetMeasure("mCPU1")
	msC2=SKIN:GetMeasure("mCPU2")
end

function Update()
	iC1=msC1:GetValue()
	iC2=msC2:GetValue()
	iX1=120
	iY1=120-iC1
	iX2=120+iC2*0.866
	iY2=120-iC2/2
	iLX=(iX1+iX2)/2
	iLY=(iY1+iY2)/2
	iW=((iX2-iX1)^2+(iY2-iY1)^2)^0.5
	iA=math.atan((iY2-iY1)/(iX2-iX1))
	SKIN:Bang("!MoveMeter "..(iLX-iW/2).." "..(iLY).." mt3")
	SKIN:Bang("!SetOption mt3 W "..iW)
	SKIN:Bang("!SetOption mt3 TransformationMatrix "..math.cos(iA)..";"..math.sin(iA)..";"..-math.sin(iA)..";"..math.cos(iA)..";"..iLX*(1-math.cos(iA))+iLY*math.sin(iA)..";"..iLY*(1-math.cos(iA))-iLX*math.sin(iA))
end
未命名.jpg
You do not have the required permissions to view the files attached to this post.
JayVodka
Posts: 9
Joined: January 14th, 2012, 5:37 am

Re: Radar Chart

Post by JayVodka »

Thank you for the demonstration but now I have some other questions:

Are you basically connecting the endpoints of the yielded measurements?
Is the .lua file something created in notepad and placed in the current skin directory?
Is there a way to color the interior area of the shape created by the three lines?
User avatar
XANCI
Posts: 104
Joined: September 18th, 2011, 6:37 am
Location: Nanjing, China

Re: Radar Chart

Post by XANCI »

JayVodka wrote:Thank you for the demonstration but now I have some other questions:

Are you basically connecting the endpoints of the yielded measurements?
Is the .lua file something created in notepad and placed in the current skin directory?
Is there a way to color the interior area of the shape created by the three lines?
just create a new TXT and rename as .lua

the lua script above basicly do the following:
1.get measures' value and calculate 2 corresponding points (x1,y1) and (x2,y2) on radius line
2.calculate the coordinates of the mid-point of (x1,y1) and (x2,y2) as [mt3]'s center
3.calculate the distance between (x1,y1) and (x2,y2) as [mt3]'s length
4.calculate the angle that [mt3] rotates around its center to match (x1,y1) and (x2,y2)
5.apply all options to [mt3]

but it looks impossible to color the triangular area now
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Radar Chart

Post by jsmorley »

XANCI wrote:

Code: Select all

function Initialize()
	msC1=SKIN:GetMeasure("mCPU1")
	msC2=SKIN:GetMeasure("mCPU2")
end

function Update()
	iC1=msC1:GetValue()
	iC2=msC2:GetValue()
	iX1=120
	iY1=120-iC1
	iX2=120+iC2*0.866
	iY2=120-iC2/2
	iLX=(iX1+iX2)/2
	iLY=(iY1+iY2)/2
	iW=((iX2-iX1)^2+(iY2-iY1)^2)^0.5
	iA=math.atan((iY2-iY1)/(iX2-iX1))
	SKIN:Bang("!MoveMeter "..(iLX-iW/2).." "..(iLY).." mt3")
	SKIN:Bang("!SetOption mt3 W "..iW)
	SKIN:Bang("!SetOption mt3 TransformationMatrix "..math.cos(iA)..";"..math.sin(iA)..";"..-math.sin(iA)..";"..math.cos(iA)..";"..iLX*(1-math.cos(iA))+iLY*math.sin(iA)..";"..iLY*(1-math.cos(iA))-iLX*math.sin(iA))
end
Yike... 200 years ago you would have been burned as a witch... ;-)