From c7209c76419c63169fcc11a2d6034c0c9a20bc8d Mon Sep 17 00:00:00 2001
From: Markus Birth <mbirth@gmail.com>
Date: Sun, 4 Sep 2016 21:02:06 +0200
Subject: [PATCH] Split 7days template into includes. Some optimisations.

---
 _graph_templates/7days.png.xml                | 55 ++-----------------
 _graph_templates/7days.svg.xml                | 55 ++-----------------
 _graph_templates/includes/daily_rain_bar.xml  |  2 +-
 .../includes/hourly_press_line.xml            |  2 +-
 _graph_templates/includes/hourly_rain_bar.xml |  2 +-
 .../includes/hourly_temp_dew_line.xml         | 15 +++++
 .../includes/hourly_wind_gust_line.xml        |  2 +-
 .../includes/raw_wind_gust_line.xml           |  2 +-
 8 files changed, 30 insertions(+), 105 deletions(-)
 create mode 100644 _graph_templates/includes/hourly_temp_dew_line.xml

diff --git a/_graph_templates/7days.png.xml b/_graph_templates/7days.png.xml
index b7badb2..0fc1b53 100644
--- a/_graph_templates/7days.png.xml
+++ b/_graph_templates/7days.png.xml
@@ -1,57 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <graph xmlns:xi="http://www.w3.org/2001/XInclude">
   <size>600, 800</size>
-  <fileformat>pngcairo font "arial,8"</fileformat>
+  <xi:include href="includes/format_png.xml" parse="xml" />
   <duration>weeks=1</duration>
   <xformat>%a %d</xformat>
   <dateformat></dateformat>
-  <plot>
-    <yrange>-20, 40</yrange>
-    <source>hourly</source>
-    <subplot>
-      <colour>1</colour>
-      <title>Temperatur (℃)</title>
-      <ycalc>data['temp_out']</ycalc>
-    </subplot>
-    <subplot>
-      <colour>3</colour>
-      <ycalc>dew_point(data['temp_out'], data['hum_out'])</ycalc>
-      <title>Taupunkt (℃)</title>
-    </subplot>
-  </plot>
-  <plot>
-    <title>Windgeschwindigkeit (km/h)</title>
-    <yrange>0, 30</yrange>
-    <source>hourly</source>
-    <subplot>
-      <colour>4</colour>
-      <ycalc>data['wind_gust'] * 3.6</ycalc>
-      <title>Boe</title>
-    </subplot>
-    <subplot>
-      <colour>3</colour>
-      <ycalc>data['wind_ave'] * 3.6</ycalc>
-      <title>durchschn.</title>
-    </subplot>
-  </plot>
-  <plot>
-    <yrange>0, 5</yrange>
-    <source>hourly</source>
-    <subplot>
-      <colour>5</colour>
-      <style>box</style>
-      <xcalc>data['idx'].replace(minute=30, second=0)</xcalc>
-      <ycalc>data['rain']</ycalc>
-      <title>Stündl. Regenfall (mm)</title>
-    </subplot>
-  </plot>
-  <plot>
-    <source>hourly</source>
-    <subplot>
-      <colour>2</colour>
-      <ycalc>data['rel_pressure']</ycalc>
-      <title>Luftdruck (hPa)</title>
-    </subplot>
-    <yrange>960, 1050</yrange>
-  </plot>
+  <xi:include href="includes/hourly_temp_dew_line.xml" parse="xml" />
+  <xi:include href="includes/hourly_wind_gust_line.xml" parse="xml" />
+  <xi:include href="includes/hourly_rain_bar.xml" parse="xml" />
+  <xi:include href="includes/hourly_press_line.xml" parse="xml" />
 </graph>
diff --git a/_graph_templates/7days.svg.xml b/_graph_templates/7days.svg.xml
index ed5380e..df31637 100644
--- a/_graph_templates/7days.svg.xml
+++ b/_graph_templates/7days.svg.xml
@@ -1,57 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <graph xmlns:xi="http://www.w3.org/2001/XInclude">
   <size>600, 800</size>
-  <fileformat>svg font "arial,10"</fileformat>
+  <xi:include href="includes/format_svg.xml" parse="xml" />
   <duration>weeks=1</duration>
   <xformat>%a %d</xformat>
   <dateformat></dateformat>
-  <plot>
-    <yrange>-20, 40</yrange>
-    <source>hourly</source>
-    <subplot>
-      <colour>1</colour>
-      <title>Temperatur (℃)</title>
-      <ycalc>data['temp_out']</ycalc>
-    </subplot>
-    <subplot>
-      <colour>3</colour>
-      <ycalc>dew_point(data['temp_out'], data['hum_out'])</ycalc>
-      <title>Taupunkt (℃)</title>
-    </subplot>
-  </plot>
-  <plot>
-    <title>Windgeschwindigkeit (km/h)</title>
-    <yrange>0, 30</yrange>
-    <source>hourly</source>
-    <subplot>
-      <colour>4</colour>
-      <ycalc>data['wind_gust'] * 3.6</ycalc>
-      <title>Boe</title>
-    </subplot>
-    <subplot>
-      <colour>3</colour>
-      <ycalc>data['wind_ave'] * 3.6</ycalc>
-      <title>durchschn.</title>
-    </subplot>
-  </plot>
-  <plot>
-    <yrange>0, 5</yrange>
-    <source>hourly</source>
-    <subplot>
-      <colour>5</colour>
-      <style>box</style>
-      <xcalc>data['idx'].replace(minute=30, second=0)</xcalc>
-      <ycalc>data['rain']</ycalc>
-      <title>Stündl. Regenfall (mm)</title>
-    </subplot>
-  </plot>
-  <plot>
-    <source>hourly</source>
-    <subplot>
-      <colour>2</colour>
-      <ycalc>data['rel_pressure']</ycalc>
-      <title>Luftdruck (hPa)</title>
-    </subplot>
-    <yrange>960, 1050</yrange>
-  </plot>
+  <xi:include href="includes/hourly_temp_dew_line.xml" parse="xml" />
+  <xi:include href="includes/hourly_wind_gust_line.xml" parse="xml" />
+  <xi:include href="includes/hourly_rain_bar.xml" parse="xml" />
+  <xi:include href="includes/hourly_press_line.xml" parse="xml" />
 </graph>
diff --git a/_graph_templates/includes/daily_rain_bar.xml b/_graph_templates/includes/daily_rain_bar.xml
index 992d107..1b50b0d 100644
--- a/_graph_templates/includes/daily_rain_bar.xml
+++ b/_graph_templates/includes/daily_rain_bar.xml
@@ -7,6 +7,6 @@
       <style>box</style>
       <xcalc>data['start'] + timedelta(hours=12)</xcalc>
       <ycalc>data['rain']</ycalc>
-      <title>Tägl. Regenfall (mm)</title>
+      <title>Tägl. Regenfall (㎜)</title>
     </subplot>
   </plot>
diff --git a/_graph_templates/includes/hourly_press_line.xml b/_graph_templates/includes/hourly_press_line.xml
index 607e93b..14b226c 100644
--- a/_graph_templates/includes/hourly_press_line.xml
+++ b/_graph_templates/includes/hourly_press_line.xml
@@ -4,7 +4,7 @@
     <subplot>
       <colour>2</colour>
       <ycalc>data['rel_pressure']</ycalc>
-      <title>Luftdruck (hPa)</title>
+      <title>Luftdruck (㍱)</title>
     </subplot>
     <yrange>960, 1050</yrange>
   </plot>
diff --git a/_graph_templates/includes/hourly_rain_bar.xml b/_graph_templates/includes/hourly_rain_bar.xml
index 5e7ab9c..83d5b83 100644
--- a/_graph_templates/includes/hourly_rain_bar.xml
+++ b/_graph_templates/includes/hourly_rain_bar.xml
@@ -7,6 +7,6 @@
       <style>box</style>
       <xcalc>data['idx'].replace(minute=30, second=0)</xcalc>
       <ycalc>data['rain']</ycalc>
-      <title>Tägl. Regenfall (mm)</title>
+      <title>Regenfall (㎜)</title>
     </subplot>
   </plot>
diff --git a/_graph_templates/includes/hourly_temp_dew_line.xml b/_graph_templates/includes/hourly_temp_dew_line.xml
new file mode 100644
index 0000000..5bb24f2
--- /dev/null
+++ b/_graph_templates/includes/hourly_temp_dew_line.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+  <plot>
+    <yrange>-20, 40</yrange>
+    <source>hourly</source>
+    <subplot>
+      <colour>1</colour>
+      <title>Temperatur (℃)</title>
+      <ycalc>data['temp_out']</ycalc>
+    </subplot>
+    <subplot>
+      <colour>3</colour>
+      <ycalc>dew_point(data['temp_out'], data['hum_out'])</ycalc>
+      <title>Taupunkt (℃)</title>
+    </subplot>
+  </plot>
diff --git a/_graph_templates/includes/hourly_wind_gust_line.xml b/_graph_templates/includes/hourly_wind_gust_line.xml
index 13f86ba..62447d4 100644
--- a/_graph_templates/includes/hourly_wind_gust_line.xml
+++ b/_graph_templates/includes/hourly_wind_gust_line.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
   <plot>
-    <title>Windgeschwindigkeit (km/h)</title>
+    <title>Windgeschwindigkeit (㎞/h)</title>
     <yrange>0, 30</yrange>
     <source>hourly</source>
     <subplot>
diff --git a/_graph_templates/includes/raw_wind_gust_line.xml b/_graph_templates/includes/raw_wind_gust_line.xml
index 276e078..f3290f7 100644
--- a/_graph_templates/includes/raw_wind_gust_line.xml
+++ b/_graph_templates/includes/raw_wind_gust_line.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
   <plot>
-    <title>Windgeschwindigkeit (km/h)</title>
+    <title>Windgeschwindigkeit (㎞/h)</title>
     <yrange>0, 30</yrange>
     <source>raw</source>
     <subplot>