ClimateChart extension

License
GPL.

First draft
This sit just a first draft to check the algorithm. It is not installed as an extension. Just see how it works here....


 * It uses the SimpleXML libraray of PHP5
 * Its just a simple SVG-File. There are no namespaces implemented till now.

<?php /* * Creates a climate chart for the Wikivoyage project * * @author Stefan Fussan * @copyright Copyright © 2011 Stefan Fussan * V 0.10 of Sepütember 15, 2011 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */

/* Hier kommt dann irgendwie der Programmtext, um die Daten aus'm Wiki übergeben zu bekommen * Jetzt werden sie erstmal aus der GET-Methode geholt */

//Variablen holen $xt = array; $nt = array; $rm = array;

$xt[] = $_GET["xtjan"]; $nt[] = $_GET["ntjan"]; $rm[] = $_GET["rmjan"]; $xt[] = $_GET["xtfeb"]; $nt[] = $_GET["ntfeb"]; $rm[] = $_GET["rmfeb"]; $xt[] = $_GET["xtmar"]; $nt[] = $_GET["ntmar"]; $rm[] = $_GET["rmmar"]; $xt[] = $_GET["xtapr"]; $nt[] = $_GET["ntapr"]; $rm[] = $_GET["rmapr"]; $xt[] = $_GET["xtmay"]; $nt[] = $_GET["ntmay"]; $rm[] = $_GET["rmmay"]; $xt[] = $_GET["xtjun"]; $nt[] = $_GET["ntjun"]; $rm[] = $_GET["rmjun"]; $xt[] = $_GET["xtjul"]; $nt[] = $_GET["ntjul"]; $rm[] = $_GET["rmjul"]; $xt[] = $_GET["xtaug"]; $nt[] = $_GET["ntaug"]; $rm[] = $_GET["rmaug"]; $xt[] = $_GET["xtsep"]; $nt[] = $_GET["ntsep"]; $rm[] = $_GET["rmsep"]; $xt[] = $_GET["xtoct"]; $nt[] = $_GET["ntoct"]; $rm[] = $_GET["rmoct"]; $xt[] = $_GET["xtnov"]; $nt[] = $_GET["ntnov"]; $rm[] = $_GET["rmnov"]; $xt[] = $_GET["xtdec"]; $nt[] = $_GET["ntdec"]; $rm[] = $_GET["rmdec"]; $ort = $_GET["ort"];

// Zählervariablen für die IDs $layer_no = 1; $rect_no = 1; $path_no = 1; $text_no = 1; $line_no = 1;

/* Parameter * $factor_precipitation -> Faktor für den Maßstab der Säulen des Niederschlags */

$factor_precipitation = 1;

/* XML Objekt anlegen * * Namespaces anzulegen bekomme ich mit SimpleXML noch niocht hin * daher auskommentiert */

$svg = new SimpleXMLElement(" "); // $svg->addAttribute ( "xmlns:dd", "http://purl.org/dc/elements/1.1/" ); // $svg->addAttribute ( "xmlns:cc", "http://creativecommons.org/ns#" ); // $svg->addAttribute ( "xmlns:rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ); // $svg->addAttribute ( "xmlns:svg", "http://www.w3.org/2000/svg" ); $svg->addAttribute ( "xmlns", "http://www.w3.org/2000/svg" ); $svg->addAttribute ( "version", "1.1" ); $svg->addAttribute ( "width", "760" ); $svg->addAttribute ( "height", "700" ); $svg->addAttribute ( "id", "svg2" ); $svg->addAttribute ( "style", "display:inline" );

// Titel $svg->addChild( "title", "Climate chart");

// Metadaten $metadata = $svg->addChild ( "metadata" ); // $rdf = $metadata->addChild ( "RDF", "", "rdf" );

// Defs schreiben -> Noch keine Ahnung wozu das Tag eigentlich da ist $defs = $svg->addChild( "defs" ); $defs->addAttribute ( "id", "defs1" );

/* Ebene: Die Regenbalken */

// Ebene anlegen $g[$layer_no] = $svg->addChild( "g" ); $g[$layer_no]->addAttribute ( "id", "layer".$layer_no ); $g[$layer_no]->addAttribute ( "style", "display:inline" );

// Startwert y-Koordinate der Balken $x = 110;

// Balken anlegen for ( $i = 0; $i <= 11; $i++ ) { //Parameter berechnen $height = 3.2 * $rm[$i] * $factor_precipitation; $y = 500 - $height; $rect = $g[$layer_no]->addChild( "rect" ); $rect->addAttribute ( "width", "40" ); $rect->addAttribute ( "height", $height ); $rect->addAttribute ( "x", $x ); $rect->addAttribute ( "y", $y ); $rect->addAttribute ( "id", "rect".$rect_no ); $rect->addAttribute ( "style", "fill:#00ddff;fill-opacity:1;stroke:none" ); $rect_no++; // X-Koordinate weiterrücken $x = $x + 48; } $layer_no++;

/* Ebene: Die Temperaturen */

// Ebene anlegen $g[$layer_no] = $svg->addChild( "g" ); $g[$layer_no]->addAttribute ( "id", "layer".$layer_no ); $g[$layer_no]->addAttribute ( "style", "display:inline" );

/* Maximaltemperatur */

//Stützpunkte berechnen // Start $x = 130; $y = 500 - ( $xt[0] * 8 );

// Jahr durchlaufen $polygon = "m "; for ( $i = 1; $i <= 12; $i++ ) { // Werte schreiben $polygon = $polygon.$x." ".$y." "; // nächste Koordinate berechnen // Die folgenden Zahlen sind immer nur Koordinatenunterschiede $x = 48; $y = ( $xt[$i-1] * 8 ) - ( $xt[$i] * 8 ); } rtrim ( $polygon );

// Polygon schreiben $path = $g[$layer_no]->addChild( "path" ); $path->addAttribute ( "d", $polygon ); $path->addAttribute ( "id", "path".$path_no ); $path->addAttribute ( "style", "fill:none;stroke:#ff1919;stroke-width:5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" ); $path_no++; /* Minimaltemperatur */

//Stützpunkte berechnen // Start $x = 130; $y = 500 - ( $nt[0] * 8 );

// Jahr durchlaufen $polygon = "m "; for ( $i = 1; $i <= 12; $i++ ) { // Werte schreiben $polygon = $polygon.$x." ".$y." "; // nächste Koordinate berechnen // Die folgenden Zahlen sind immer nur Koordinatenunterschiede $x = 48; $y = ( $nt[$i-1] * 8 ) - ( $nt[$i] * 8 ); } rtrim ( $polygon );

// Polygon schreiben $path = $g[$layer_no]->addChild( "path" ); $path->addAttribute ( "d", $polygon ); $path->addAttribute ( "id", "path".$path_no ); $path->addAttribute ( "style","fill:none;stroke:#aa0000;stroke-width:5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline" ); $path_no++;

$layer_no++;

/* Legende */

// Ebene anlegen $g[$layer_no] = $svg->addChild( "g" ); $g[$layer_no]->addAttribute ( "id", "layer".$layer_no ); $g[$layer_no]->addAttribute ( "style", "display:inline" );

// Texte schreiben $text = $g[$layer_no]->addChild( "text", "Mittlere Jahreshöchsttemperatur in °C" ); $text->addAttribute ( "x", "270" ); $text->addAttribute ( "y", "560" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:24.66666603px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ff1919;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "Mittlere Jahrestiefsttemperatur in °C" ); $text->addAttribute ( "x", "270" ); $text->addAttribute ( "y", "600" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:24.66666603px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ff1919;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "Jahresniederschlag in mm" ); $text->addAttribute ( "x", "270" ); $text->addAttribute ( "y", "640" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:24.66666603px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ff1919;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana" ); $text_no++;

// Rechtecke schreiben $rect = $g[$layer_no]->addChild( "rect" ); $rect->addAttribute ( "width", "110" ); $rect->addAttribute ( "height", "30" ); $rect->addAttribute ( "rx", "8" ); $rect->addAttribute ( "ry", "8" ); $rect->addAttribute ( "x", "140" ); $rect->addAttribute ( "y", "535" ); $rect->addAttribute ( "id", "rect".$rect_no ); $rect->addAttribute ( "style", "fill:none;stroke:#ff1919;stroke-width:4px" ); $rect_no;

$rect = $g[$layer_no]->addChild( "rect" ); $rect->addAttribute ( "width", "110" ); $rect->addAttribute ( "height", "30" ); $rect->addAttribute ( "rx", "8" ); $rect->addAttribute ( "ry", "8" ); $rect->addAttribute ( "x", "140" ); $rect->addAttribute ( "y", "575" ); $rect->addAttribute ( "id", "rect".$rect_no ); $rect->addAttribute ( "style", "fill:none;stroke:#aa0000;stroke-width:4px" ); $rect_no;

$rect = $g[$layer_no]->addChild( "rect" ); $rect->addAttribute ( "width", "110" ); $rect->addAttribute ( "height", "30" ); $rect->addAttribute ( "rx", "8" ); $rect->addAttribute ( "ry", "8" ); $rect->addAttribute ( "x", "140" ); $rect->addAttribute ( "y", "615" ); $rect->addAttribute ( "id", "rect".$rect_no ); $rect->addAttribute ( "style", "fill:none;stroke:#0000ff;stroke-width:4px" ); $rect_no;

// Mittelwerte schreiben

$avg = 0; foreach ( $xt AS $wert ) { $avg = $avg + $wert; } $avg = round ( $avg / 12, 1 ); $text = $g[$layer_no]->addChild( "text", $avg ); $text->addAttribute ( "x", "170" ); $text->addAttribute ( "y", "560" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:24.66666603px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ff1919;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana" ); $text_no++;

$avg = 0; foreach ( $nt AS $wert ) { $avg = $avg + $wert; } $avg = round ( $avg / 12, 1 ); $text = $g[$layer_no]->addChild( "text", $avg ); $text->addAttribute ( "x", "170" ); $text->addAttribute ( "y", "600" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:24.66666603px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#aa0000;stroke:none;display:inline;font-family:Verdana;-inkscape-font-specification:Verdana" ); $text_no++;

$avg = 0; foreach ( $rm AS $wert ) { $avg = $avg + $wert; } $avg = round ( $avg / 12 ); $text = $g[$layer_no]->addChild( "text", $avg ); $text->addAttribute ( "x", "170" ); $text->addAttribute ( "y", "640" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:24.66666603px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#0000ff;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana" ); $text_no++;

$layer_no++;

/* Die Monate */

// Ebene anlegen $g[$layer_no] = $svg->addChild( "g" ); $g[$layer_no]->addAttribute ( "id", "layer".$layer_no ); $g[$layer_no]->addAttribute ( "style", "display:inline" );

$text = $g[$layer_no]->addChild( "text", "JFMAMJJASOND" ); $text->addAttribute ( "x", "120 168 216 264 312 360 408 454 502 550 598 646" ); $text->addAttribute ( "y", "110" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:30px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana" ); $text_no++;

$layer_no++;

/* Der Ortsname */

// Ebene anlegen $g[$layer_no] = $svg->addChild( "g" ); $g[$layer_no]->addAttribute ( "id", "layer".$layer_no ); $g[$layer_no]->addAttribute ( "style", "display:inline" );

$text = $g[$layer_no]->addChild( "text", $ort ); $text->addAttribute ( "x", "384" ); $text->addAttribute ( "y", "64" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:48px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana" ); $text_no++;

$layer_no++;

/* Die Skalen */

// Ebene anlegen $g[$layer_no] = $svg->addChild( "g" ); $g[$layer_no]->addAttribute ( "id", "layer".$layer_no ); $g[$layer_no]->addAttribute ( "style", "display:inline" );

// Linien zeichnen

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "90" ); $line->addAttribute ( "y1", "100" ); $line->addAttribute ( "x2", "110" ); $line->addAttribute ( "y2", "100" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#000000;stroke-width:2px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "90" ); $line->addAttribute ( "y1", "180" ); $line->addAttribute ( "x2", "110" ); $line->addAttribute ( "y2", "180" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#000000;stroke-width:2px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "90" ); $line->addAttribute ( "y1", "260" ); $line->addAttribute ( "x2", "110" ); $line->addAttribute ( "y2", "260" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#000000;stroke-width:2px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "90" ); $line->addAttribute ( "y1", "340" ); $line->addAttribute ( "x2", "110" ); $line->addAttribute ( "y2", "340" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#000000;stroke-width:2px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "90" ); $line->addAttribute ( "y1", "420" ); $line->addAttribute ( "x2", "110" ); $line->addAttribute ( "y2", "420" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#000000;stroke-width:2px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "90" ); $line->addAttribute ( "y1", "500" ); $line->addAttribute ( "x2", "690" ); $line->addAttribute ( "y2", "500" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#000000;stroke-width:4px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "90" ); $line->addAttribute ( "y1", "580" ); $line->addAttribute ( "x2", "110" ); $line->addAttribute ( "y2", "580" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#000000;stroke-width:2px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "100" ); $line->addAttribute ( "y1", "90" ); $line->addAttribute ( "x2", "100" ); $line->addAttribute ( "y2", "680" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#000000;stroke-width:4px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "680" ); $line->addAttribute ( "y1", "90" ); $line->addAttribute ( "x2", "680" ); $line->addAttribute ( "y2", "500" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#0000ff;stroke-width:4px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "670" ); $line->addAttribute ( "y1", "100" ); $line->addAttribute ( "x2", "690" ); $line->addAttribute ( "y2", "100" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#0000ff;stroke-width:2px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "670" ); $line->addAttribute ( "y1", "180" ); $line->addAttribute ( "x2", "690" ); $line->addAttribute ( "y2", "180" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#0000ff;stroke-width:2px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "670" ); $line->addAttribute ( "y1", "260" ); $line->addAttribute ( "x2", "690" ); $line->addAttribute ( "y2", "260" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#0000ff;stroke-width:2px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "670" ); $line->addAttribute ( "y1", "340" ); $line->addAttribute ( "x2", "690" ); $line->addAttribute ( "y2", "340" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#0000ff;stroke-width:2px" ); $line_no++;

$line = $g[$layer_no]->addChild( "line" ); $line->addAttribute ( "x1", "670" ); $line->addAttribute ( "y1", "420" ); $line->addAttribute ( "x2", "690" ); $line->addAttribute ( "y2", "420" ); $line->addAttribute ( "id", "line".$line_no ); $line->addAttribute ( "style", "stroke:#0000ff;stroke-width:2px" ); $line_no++;

$text = $g[$layer_no]->addChild( "text", "50 °C" ); $text->addAttribute ( "x", "20" ); $text->addAttribute ( "y", "110" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "40 °C" ); $text->addAttribute ( "x", "20" ); $text->addAttribute ( "y", "190" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "30 °C" ); $text->addAttribute ( "x", "20" ); $text->addAttribute ( "y", "270" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "20 °C" ); $text->addAttribute ( "x", "20" ); $text->addAttribute ( "y", "350" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "10 °C" ); $text->addAttribute ( "x", "20" ); $text->addAttribute ( "y", "430" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "0 °C" ); $text->addAttribute ( "x", "20" ); $text->addAttribute ( "y", "510" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "-10 °C" ); $text->addAttribute ( "x", "20" ); $text->addAttribute ( "y", "590" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "-20 °C" ); $text->addAttribute ( "x", "20" ); $text->addAttribute ( "y", "670" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "125" ); $text->addAttribute ( "x", "700" ); $text->addAttribute ( "y", "110" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "100" ); $text->addAttribute ( "x", "700" ); $text->addAttribute ( "y", "190" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "75" ); $text->addAttribute ( "x", "700" ); $text->addAttribute ( "y", "270" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "50" ); $text->addAttribute ( "x", "700" ); $text->addAttribute ( "y", "350" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "25" ); $text->addAttribute ( "x", "700" ); $text->addAttribute ( "y", "430" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

$text = $g[$layer_no]->addChild( "text", "0" ); $text->addAttribute ( "x", "700" ); $text->addAttribute ( "y", "510" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++;

// Monatsangaben Regen for ( $i = 0; $i <= 11; $i++ ) { $text = $g[$layer_no]->addChild( "text", $rm[$i] ); $text->addAttribute ( "x", 115 + $i * 48 ); $text->addAttribute ( "y", "520" ); $text->addAttribute ( "id", "text".$text_no ); $text->addAttribute ( "style", "font-size:20px;font-style:normal;fill:#000000;stroke:none;font-family:Arial" ); $text_no++; }

$layer_no++;

/* Ebene: Der Rahmen */ $g[$layer_no] = $svg->addChild( "g" ); $g[$layer_no]->addAttribute ( "id", "layer".$layer_no ); $g[$layer_no]->addAttribute ( "style", "display:inline" ); $rect = $g[$layer_no]->addChild( "rect" ); $rect->addAttribute ( "width", "750" ); $rect->addAttribute ( "height", "690" ); $rect->addAttribute ( "rx", "8" ); $rect->addAttribute ( "ry", "8" ); $rect->addAttribute ( "x", "5" ); $rect->addAttribute ( "y", "5" ); $rect->addAttribute ( "id", "rect".$rect_no ); $rect->addAttribute ( "style", "fill:none;stroke:#c0c0c0;stroke-width:6px;display:inline" );

// SVG-Datei schreiben $handle = fopen("klima.svg", "w"); fwrite($handle, $svg->asXML); fclose($handle); echo ""; ?>