You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
273 lines
12 KiB
273 lines
12 KiB
<?xml version="1.0" encoding="UTF-8" ?> |
|
<xsl:stylesheet version="1.0" |
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
xmlns:svg="http://www.w3.org/2000/svg"> |
|
<!--graphtools-Layout Templates, können in pageComponents_html_final.xsl überlagert werden--> |
|
<xsl:template name="myBarColorFg" > |
|
<xsl:text>steelblue</xsl:text> |
|
</xsl:template> |
|
<xsl:template name="myBarColorBg" > |
|
<xsl:text>#cccccc</xsl:text> |
|
</xsl:template> |
|
<xsl:template name="myBarColorSeriesFgStart" > |
|
<xsl:text>0,0,139</xsl:text> |
|
</xsl:template> |
|
<xsl:template name="myBarColorSeriesFgEnd" > |
|
<xsl:text>173,216,230</xsl:text> |
|
</xsl:template> |
|
<xsl:template name="myBarColorSeriesFgSteps" > |
|
<xsl:text>10</xsl:text> |
|
</xsl:template> |
|
|
|
<!-- nun die templates zur Berechnung:--> |
|
<xsl:template name="graph"> |
|
<xsl:param name="graphwidth" select="100" /> |
|
<xsl:param name="graphheight" select="20" /> |
|
<xsl:param name="feldname" /> |
|
<xsl:param name="feldwert" /> |
|
|
|
<xsl:variable name="gesamt"> |
|
<xsl:choose> |
|
<xsl:when test="contains($feldwert,'|')"> |
|
<xsl:value-of select="number(substring-after($feldwert,'|'))"/> |
|
</xsl:when> |
|
<xsl:otherwise>100</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:variable> |
|
<xsl:variable name="feldwertOhneGesamt"> |
|
<xsl:choose> |
|
<xsl:when test="contains($feldwert,'|')"> |
|
<xsl:value-of select="substring-before($feldwert,'|')"/> |
|
</xsl:when> |
|
<xsl:otherwise><xsl:value-of select="$feldwert"/></xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:variable> |
|
<xsl:variable name="barColorBg"> |
|
<xsl:call-template name="myBarColorBg" /> |
|
</xsl:variable> |
|
<xsl:variable name="barColorSeriesFgStart"> |
|
<xsl:call-template name="myBarColorSeriesFgStart" /> |
|
</xsl:variable> |
|
<xsl:variable name="barColorSeriesFgEnd"> |
|
<xsl:call-template name="myBarColorSeriesFgEnd" /> |
|
</xsl:variable> |
|
<xsl:variable name="barColorSeriesFgSteps"> |
|
<xsl:call-template name="myBarColorSeriesFgSteps" /> |
|
</xsl:variable> |
|
|
|
<xsl:if test="string-length($feldwert) > 0"> |
|
<svg:svg width="{concat($graphwidth,'px')}" height="{concat($graphheight,'px')}"><svg:g> |
|
<svg:rect x="0" y="0" width="{concat($graphwidth,'px')}" height="{concat($graphheight,'px')}" fill="{$barColorBg}"> |
|
<svg:title><xsl:value-of select="$gesamt"/></svg:title></svg:rect> |
|
|
|
|
|
<xsl:choose> |
|
<xsl:when test="starts-with($feldname,'_graphbarright')"> |
|
<xsl:call-template name="drawBar"> |
|
<xsl:with-param name="maxwidth" select="$graphwidth" /> |
|
<xsl:with-param name="barHeight" select="$graphheight" /> |
|
<xsl:with-param name="barClass" select="'chartBar'" /> |
|
<xsl:with-param name="barValue" select="number($feldwertOhneGesamt)" /> |
|
<xsl:with-param name="barMaxValue" select="$gesamt" /> |
|
<xsl:with-param name="barLabel" select="number($feldwertOhneGesamt)" /> |
|
<xsl:with-param name="barLabelClass" select="'chartLabel'" /> |
|
<xsl:with-param name="x" select="($graphwidth - ($graphwidth * (number($feldwertOhneGesamt) div $gesamt)))" /> |
|
<xsl:with-param name="y" select="0" /> |
|
</xsl:call-template> |
|
|
|
</xsl:when> |
|
|
|
<xsl:when test="starts-with($feldname,'_graphbarxseries')"> |
|
<xsl:variable name="feldwertPlusDelim"> |
|
<xsl:value-of select="concat($feldwertOhneGesamt,',')"/> |
|
</xsl:variable> |
|
<xsl:variable name="countSteps"> |
|
<xsl:call-template name="countDelims" > |
|
<xsl:with-param name="s1" select="$feldwertPlusDelim"/> |
|
<xsl:with-param name="nr" select="0"/> |
|
<xsl:with-param name="delim" select="','"/> |
|
</xsl:call-template> |
|
</xsl:variable> |
|
<xsl:call-template name="chartBarXSeries"> |
|
<xsl:with-param name="graphwidth" select="$graphwidth" /> |
|
<xsl:with-param name="barHeight" select="$graphheight" /> |
|
<xsl:with-param name="barColorSeriesFgStart" select="$barColorSeriesFgStart" /> |
|
<xsl:with-param name="barColorSeriesFgEnd" select="$barColorSeriesFgEnd" /> |
|
<xsl:with-param name="barColorSeriesFgStep" select="1" /> |
|
<xsl:with-param name="barColorSeriesFgSteps" select="$countSteps" /> |
|
<xsl:with-param name="offset" select="0" /> |
|
<xsl:with-param name="feldwertSubString" select="$feldwertPlusDelim"/> |
|
<xsl:with-param name="gesamt" select="$gesamt"/> |
|
</xsl:call-template> |
|
</xsl:when> |
|
|
|
<xsl:when test="starts-with($feldname,'_graphbarwithlabel')" > |
|
<xsl:call-template name="drawBar"> |
|
<xsl:with-param name="maxwidth" select="$graphwidth" /> |
|
<xsl:with-param name="barHeight" select="19" /> |
|
<xsl:with-param name="barClass" select="'chartBar'" /> |
|
<xsl:with-param name="barValue" select="number($feldwertOhneGesamt)" /> |
|
<xsl:with-param name="barMaxValue" select="$gesamt" /> |
|
<xsl:with-param name="barLabel" select="number($feldwertOhneGesamt)" /> |
|
<xsl:with-param name="barLabelClass" select="'chartLabel'" /> |
|
<xsl:with-param name="showLabel" select="'true'" /> |
|
</xsl:call-template> |
|
|
|
</xsl:when> |
|
|
|
<xsl:otherwise><!-- default: Balken linksbündig--> |
|
|
|
<xsl:call-template name="drawBar"> |
|
<xsl:with-param name="maxwidth" select="$graphwidth" /> |
|
<xsl:with-param name="barHeight" select="19" /> |
|
<xsl:with-param name="barClass" select="'chartBar'" /> |
|
<xsl:with-param name="barValue" select="number($feldwertOhneGesamt)" /> |
|
<xsl:with-param name="barMaxValue" select="$gesamt" /> |
|
<xsl:with-param name="barLabel" select="number($feldwertOhneGesamt)" /> |
|
<xsl:with-param name="barLabelClass" select="'chartLabel'" /> |
|
</xsl:call-template> |
|
|
|
</xsl:otherwise> |
|
</xsl:choose> |
|
|
|
</svg:g> |
|
</svg:svg> |
|
</xsl:if> |
|
</xsl:template> |
|
<xsl:template name="chartBarXSeries"> |
|
<xsl:param name="graphwidth" select="100" /> |
|
<xsl:param name="barHeight" select="19" /> |
|
<xsl:param name="barColorSeriesFgStart" select="'0,0,139'" /><!--dark blue--> |
|
<xsl:param name="barColorSeriesFgEnd" select="'173, 216, 230'" /><!--light blue--> |
|
<xsl:param name="barColorSeriesFgStep" select="1" /><!--Nr. der Abstufung--> |
|
<xsl:param name="barColorSeriesFgSteps" select="10" /><!--Anzahl Abstufungen--> |
|
<xsl:param name="offset" select="0" /> |
|
<xsl:param name="feldwertSubString" /> |
|
<xsl:param name="gesamt" select="100"/> |
|
|
|
<xsl:variable name="feldwertNumeric"> |
|
<xsl:value-of select="number(substring-before($feldwertSubString,','))"/> |
|
</xsl:variable> |
|
|
|
<xsl:call-template name="drawBar"> |
|
<xsl:with-param name="maxwidth" select="$graphwidth" /> |
|
<xsl:with-param name="barHeight" select="$barHeight" /> |
|
<xsl:with-param name="barClass" select="concat('chartBarSeries',$barColorSeriesFgStep)" /> |
|
<xsl:with-param name="barValue" select="$feldwertNumeric" /> |
|
<xsl:with-param name="barMaxValue" select="$gesamt" /> |
|
<xsl:with-param name="barLabel" select="$feldwertNumeric" /> |
|
<xsl:with-param name="barLabelClass" select="concat('chartLabelSeries',$barColorSeriesFgStep)" /> |
|
<xsl:with-param name="x" select="$offset" /> |
|
<xsl:with-param name="y" select="0" /> |
|
<xsl:with-param name="barColorSeriesFgStart" select="$barColorSeriesFgStart" /> |
|
<xsl:with-param name="barColorSeriesFgEnd" select="$barColorSeriesFgEnd" /> |
|
<xsl:with-param name="barColorSeriesFgStep" select="$barColorSeriesFgStep" /> |
|
<xsl:with-param name="barColorSeriesFgSteps" select="$barColorSeriesFgSteps" /> |
|
|
|
</xsl:call-template> |
|
|
|
|
|
<xsl:if test="contains(substring-after($feldwertSubString,','),',')"> |
|
<xsl:call-template name="chartBarXSeries"> |
|
<xsl:with-param name="graphwidth" select="$graphwidth" /> |
|
<xsl:with-param name="barHeight" select="$barHeight" /> |
|
<xsl:with-param name="barColorSeriesFgStep" select="$barColorSeriesFgStep + 1" /> |
|
<xsl:with-param name="barColorSeriesFgStart" select="$barColorSeriesFgStart" /> |
|
<xsl:with-param name="barColorSeriesFgEnd" select="$barColorSeriesFgEnd" /> |
|
<xsl:with-param name="barColorSeriesFgSteps" select="$barColorSeriesFgSteps" /> |
|
<xsl:with-param name="offset" select="$offset + ($graphwidth * ($feldwertNumeric div $gesamt))" /> |
|
<xsl:with-param name="feldwertSubString" select="substring-after($feldwertSubString,',')"/> |
|
</xsl:call-template> |
|
</xsl:if> |
|
</xsl:template> |
|
<xsl:template name="drawBar"> |
|
<xsl:param name="maxwidth" select="100" /> |
|
<xsl:param name="barHeight" select="19" /> |
|
<xsl:param name="barClass" select="'chartBar'" /> |
|
<xsl:param name="barValue" /> |
|
<xsl:param name="barMaxValue" /> |
|
<xsl:param name="barLabel" /> |
|
<xsl:param name="barLabelClass" select="'chartLabel'" /> |
|
<xsl:param name="x" select="0" /> |
|
<xsl:param name="y" select="0" /> |
|
<xsl:param name="showLabel" select="'false'" /> |
|
<xsl:param name="barColorSeriesFgStart" select="'0,0,139'" /><!--dark blue--> |
|
<xsl:param name="barColorSeriesFgEnd" select="'173, 216, 230'" /><!--light blue--> |
|
<xsl:param name="barColorSeriesFgStep" select="1" /><!--Nr. der Abstufung--> |
|
<xsl:param name="barColorSeriesFgSteps" select="10" /><!--Anzahl Abstufungen--> |
|
<xsl:variable name="barWidth"> |
|
<xsl:value-of select="$maxwidth * ($barValue div $barMaxValue)"/> |
|
</xsl:variable> |
|
<xsl:variable name="barColorFg"> |
|
<xsl:call-template name="getBarColorSeries" > |
|
<xsl:with-param name="color_start" select="$barColorSeriesFgStart"/> |
|
<xsl:with-param name="color_end" select="$barColorSeriesFgEnd"/> |
|
<xsl:with-param name="steps" select="$barColorSeriesFgSteps"/> |
|
<xsl:with-param name="step" select="$barColorSeriesFgStep"/> |
|
</xsl:call-template> |
|
</xsl:variable> |
|
<!--<p><xsl:value-of select="concat($maxwidth,'-',$barValue,'-',$barMaxValue)"/></p>--> |
|
<svg:rect class="{$barClass}" |
|
width="{$barWidth}" height="{$barHeight}" |
|
x="{$x}" y="{$y}" |
|
rx="5" ry="5" fill="{$barColorFg}"> |
|
<svg:title><xsl:value-of select="format-number($barLabel,'###.###.###.###.##0','German')"/></svg:title></svg:rect> |
|
<xsl:if test="$showLabel='true' and $barWidth > 5 and $barLabel !=''"> |
|
<svg:text x="{$x + ($barWidth div 2)}" y="{$barHeight div 2}" class="{$barLabelClass}" |
|
dominant-baseline="middle" text-anchor="middle"> |
|
<xsl:value-of select="format-number($barLabel,'###.###.###.###.##0,00','German')"/></svg:text> |
|
</xsl:if> |
|
</xsl:template> |
|
|
|
|
|
|
|
<xsl:template name="getBarColorSeries" > |
|
<xsl:param name="color_start" select="'0,0,139'"/> |
|
<xsl:param name="color_end" select="'173,216,230'"/> |
|
<xsl:param name="steps" select="10"/> |
|
<xsl:param name="step" select="1"/> |
|
<xsl:variable name="startR" select="number(substring-before($color_start,','))" /> |
|
<xsl:variable name="startGB" select="substring-after($color_start,',')" /> |
|
<xsl:variable name="startG" select="number(substring-before($startGB,','))" /> |
|
<xsl:variable name="startB" select="number(substring-after($startGB,','))" /> |
|
|
|
<xsl:variable name="endR" select="number(substring-before($color_end,','))" /> |
|
<xsl:variable name="endGB" select="substring-after($color_end,',')" /> |
|
<xsl:variable name="endG" select="number(substring-before($endGB,','))" /> |
|
<xsl:variable name="endB" select="number(substring-after($endGB,','))" /> |
|
|
|
<!-- Berechnung der Farbschritte --> |
|
<xsl:variable name="rStep" select="($endR - $startR) div $steps"/> |
|
<xsl:variable name="gStep" select="($endG - $startG) div $steps"/> |
|
<xsl:variable name="bStep" select="($endB - $startB) div $steps"/> |
|
|
|
|
|
<xsl:for-each select="0 to $steps"> |
|
<xsl:variable name="i" select="."/> |
|
<xsl:if test="$i=$step"> |
|
<xsl:variable name="currentR" select="round($startR + $rStep * $i)"/> |
|
<xsl:variable name="currentG" select="round($startG + $gStep * $i)"/> |
|
<xsl:variable name="currentB" select="round($startB + $bStep * $i)"/> |
|
<xsl:value-of select="concat('rgb(',$currentR,',',$currentG,',',$currentB,')')"/> |
|
</xsl:if> |
|
</xsl:for-each> |
|
</xsl:template> |
|
<xsl:template name="countDelims" > |
|
<xsl:param name="s1" /> |
|
<xsl:param name="nr" select="0"/> |
|
<xsl:param name="delim" select="','"/> |
|
<xsl:choose> |
|
<xsl:when test="$s1 = '' or not(contains($s1,$delim))"> |
|
<xsl:value-of select="$nr"/> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<!-- Recursive call: increment length and process the rest of the string --> |
|
<xsl:call-template name="countDelims"> |
|
<xsl:with-param name="s1" select="substring-after($s1,$delim)"/> |
|
<xsl:with-param name="nr" select="$nr + 1"/> |
|
<xsl:with-param name="delim" select="$delim"/> |
|
</xsl:call-template> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:template> |
|
</xsl:stylesheet>
|
|
|