SuperX-Kernmodul
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.
 
 
 
 
 
 

157 lines
6.0 KiB

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<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:if test="string-length($feldwert) &gt; 0">
<svg width="{$graphwidth}" height="{$graphheight}"><g>
<rect x="0" y="0" width="{$graphwidth}" height="{$graphheight}" fill="#cccccc">
<title><xsl:value-of select="$gesamt"/></title></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>
</g>
</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>
<rect class="{$barClass}"
width="{$barWidth}" height="{$barHeight}"
x="{$x}" y="{$y}"
rx="5" ry="5">
<title><xsl:value-of select="format-number($barLabel,'###.###.###.###.##0,00','German')"/></title></rect>
<xsl:if test="$showLabel='true' and $barWidth &gt; 5 and $barLabel !=''">
<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')"/></text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>