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.
172 lines
6.5 KiB
172 lines
6.5 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"> |
|
<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: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:call-template name="chartBarXSeries"> |
|
<xsl:with-param name="graphwidth" select="$graphwidth" /> |
|
<xsl:with-param name="barHeight" select="$graphheight" /> |
|
<xsl:with-param name="ordnr" select="1" /> |
|
<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="ordnr" select="1" /> |
|
<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',$ordnr)" /> |
|
<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',$ordnr)" /> |
|
<xsl:with-param name="x" select="$offset" /> |
|
<xsl:with-param name="y" select="0" /> |
|
</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="ordnr" select="$ordnr + 1" /> |
|
<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:variable name="barWidth"> |
|
<xsl:value-of select="$maxwidth * ($barValue div $barMaxValue)"/> |
|
</xsl:variable> |
|
|
|
<xsl:variable name="barColorFg"> |
|
<xsl:call-template name="myBarColorFg" /> |
|
</xsl:variable> |
|
|
|
<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,00','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','German')"/></svg:text> |
|
</xsl:if> |
|
</xsl:template> |
|
<xsl:template name="myBarColorBg" > |
|
<xsl:text>blue</xsl:text> |
|
</xsl:template> |
|
<xsl:template name="myBarColorFg" > |
|
<xsl:text>white</xsl:text> |
|
</xsl:template> |
|
</xsl:stylesheet>
|
|
|