ZW WeatherGraph Widgets
Posted by: pierrot | on February 26, 2015
ZW WeatherGraph Widgets
ZW files are now ready for download.
I did some optimizations to the lately teased (https://plus.google.com/u/0/+LutzLinke/posts/RRrC6QtZWK6) WeatherGraph widgets, now they look pretty good:
– scaling no longer 0°C-based, focus on current min/max area
– horizontal line gone (0°C, no longer needed)
– added dynamic scale
– created a whole bunch of sample widgets
Download here:
https://app.box.com/s/yextrr7js9xupu9y90ovacmjwvc1ikwt
Some technical stuff for those interested:
– (ceil(max(#W0MAXN#;[..];#W6MAXN#)/5)*5 – floor(min(#W0MINN#;[..];#W6MINN#)/5)*5)
Min/Max-range for scaling. Min/max values are rounded up/down to 5°. Made adding the vertical scale easier. Also looks better then using absolute range (i.e. instead of absolute range -3°C to 11°C = 14°C we use -5°C to 15°C = 20°C).
Hint: to revert to 0°C-based scaling, 0 has to be added to the list, i.e. max(0;#W0MAXN#;[..];#W6MAXN#)
– sample: [oy]$(30 + (#W0MAXN# -floor(min(#W0MINN#;[..];#W6MINN#)/5)*5) / (ceil(max(#W0MAXN#;[..];#W6MAXN#)/5)*5 – floor(min(#W0MINN#;[..];#W6MINN#)/5)*5) * 100)$[/oy]
30 is the absolute offset from widget’s bottom (all items are aligned “Center Bottom”).
(W0Max -floor(…)) is the current max temperature relative to absolute min temperature.
Relative offset value is divided by min/max-scale.
” * 100″ finally scales to the pixel-range to use.
Calculations for graph:
[r]$(atan((#W3MINN#-#W2MINN#) * 100/(ceil(max(#W0MAXN#;[..];#W6MAXN#)/5)*5 – floor(min(#W0MINN#;[..];#W6MINN#)/5)*5) / 75) * -180 / pi)$[/r]
[rw]$(75/cos(atan((#W3MINN#-#W2MINN#) * 100/(ceil(max(#W0MAXN#;[..];#W6MAXN#)/5)*5 – floor(min(#W0MINN#;[..];#W6MINN#)/5)*5) / 75)))$[/rw]
75 is the width if the line was horizontal without rotation (the “Ankathete” = adjacent side of the triangle’s angle).
Arcus Tangens calculates the angle of the graph via the temperature difference (“Gegenkathete” = opposite side of the angle).
Cosinus finally calculates the new length of the rotated line (=rect width).
Tipps for editing:
– “Batch editing” on PC
Copy the ZW file to my PC. AirDroid or PushBullet come handy for doing so.
It’s a ZIP-archive, so extract all JSON-files included to a folder.
Open all JSON-files in the free editor Notepad++.
Now it’s possible search and replace values in all opened files at once.
Save all, then replace the files in the ZW-file. Do NOT create a new ZIP!!
Copy back to phone and load in ZW to see the results.
– Moving horizontally
All graph items can be moved horizontally (x-axis) easily. However the lengths of the graphs need to be adjusted.
You can do this by replacing the base value 75 in their calculations by, i.e. 60 if you reduced the spacing by 15.
It’s the JSON files with “pref_module_name” like “Min Line” and “Max Line”.
– Changing horizontal scaling
In all JSON files the string “* 100” can be replaced with i.e. “* 75” or what ever your desired new height is.
– Change offset from bottom
I suggest using search for “[oy]$(” and replace with i.e. “[oy]$(10 + ” if you want the graph to be positioned 10 pixels higher.
]]>
< ![CDATA[
Very nice!
]]>
< ![CDATA[
Really good! Thanks a lot for files and for technical explanation 👍
]]>
< ![CDATA[
Does this have that day and night setup you made a long time ago?
]]>
< ![CDATA[
Very impressive!
]]>
< ![CDATA[
Mik lalo Nope, just a light and dark variant. But would be easy to add, just changing bkg or text color based on day/night. Kept it simple.
]]>
< ![CDATA[
Lutz Linke this is still a awesome setup i just thought i would ask thanks for sharing your hard work i like the way you setup things up.
]]>
< ![CDATA[
These are awesome, thanks for sharing
]]>
< ![CDATA[
Dude you are just so cool.
It must get 7/5.
]]>