| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Original Author: Frankline Francis
- Copyright (c) 2012, Imaginea. All rights reserved.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND DEVELOPERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE COPYRIGHT OWNER OR DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- Redistribution and use, with or without modification, are permitted provided that the following conditions are met:
- # Redistribution of source code must retain the above copyright notice, this list of conditions and the disclaimer.
- # Neither the name of Imaginea nor the names of the developers may be used to endorse or promote products derived from
- this software without specific prior written permission.
- -->
- <xsl:stylesheet version="2.0"
- xmlns:p5gnuplot="http://biuro.biall-net.pl/WPS_Functions/graph_gnuplot"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <!-- Constants -->
- <xsl:variable name="COLOURS" select="document('colours.xml')/colours/colour" />
- <xsl:variable name="FONT" select="'Arial'" />
- <xsl:variable name="FONT_SIZE" select="5" />
- <!-- Helper template to return the maximum of given items -->
- <xsl:template name="maximum">
- <xsl:param name="numbers" />
- <xsl:for-each select="$numbers">
- <xsl:sort select="." data-type="number" order="descending" />
- <xsl:if test="position()=1">
- <xsl:value-of select="." />
- </xsl:if>
- </xsl:for-each>
- </xsl:template>
- <!-- Helper template to return the minimum of given items -->
- <xsl:template name="minimum">
- <xsl:param name="numbers" />
- <xsl:for-each select="$numbers">
- <xsl:sort select="." data-type="number" order="ascending" />
- <xsl:if test="position()=1">
- <xsl:value-of select="." />
- </xsl:if>
- </xsl:for-each>
- </xsl:template>
- <!-- Helper template to return the absolute value -->
- <xsl:template name="absolute">
- <xsl:param name="number" />
- <xsl:choose>
- <xsl:when test="$number >= 0">
- <xsl:value-of select="$number" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="- $number" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- Returns a named colour for the given index -->
- <xsl:template name="colour">
- <xsl:param name="index" />
- <xsl:value-of select="$COLOURS[@index=($index mod count($COLOURS))]" />
- </xsl:template>
- <!-- Helper template to print x-axis -->
- <xsl:template name="p5gnuplot:printXAxis">
- <xsl:param name="xData" />
- <xsl:param name="step" />
- <xsl:param name="xMin" />
- <xsl:param name="xMax" />
- <xsl:param name="Data.analyzed" required="yes" tunnel="yes"/>
- <xsl:for-each select="$Data.analyzed//xData.postition"><!-- $xData -->
- <xsl:choose>
- <xsl:when test="position() <= $xMax">
- <svg:text writing-mode="tb" x="{$xMin+(position() - 1)*$step}"
- deb="#73 osie nazwy "
- dy="5" fill="black" font-family="{$FONT}" font-weight="bold"
- font-size="{$FONT_SIZE}" xmlns:svg="http://www.w3.org/2000/svg">
- <!--<xsl:value-of select="." />-->
- <xsl:value-of select="$Data.analyzed//xData.name[@pos = current()/@pos]"/>
- </svg:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:comment>#90 error position() = <xsl:value-of select="position()"/> lt <xsl:value-of select="$xMax"/> </xsl:comment>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:template>
-
- <xsl:template name="printXAxis">
- <xsl:param name="xData" />
- <xsl:param name="step" />
- <xsl:param name="xMin" />
- <xsl:param name="xMax" />
-
- <xsl:for-each select="$xData">
- <xsl:if test="position() <= $xMax">
- <svg:text writing-mode="tb" x="{$xMin+(position() - 1)*$step}"
- dy="5" fill="black" font-family="{$FONT}" font-weight="bold"
- font-size="{$FONT_SIZE}" xmlns:svg="http://www.w3.org/2000/svg">
- <xsl:value-of select="." />
- </svg:text>
- </xsl:if>
- </xsl:for-each>
- </xsl:template>
- <!-- Helper template to print y-axis -->
- <xsl:template name="printYAxis">
- <xsl:param name="index" />
- <xsl:param name="step" />
- <xsl:param name="xMin" />
- <xsl:param name="xMax" />
- <xsl:param name="yMin" />
- <xsl:param name="yMax" />
- <xsl:param name="yScale" />
- <xsl:variable name="labelDelta" select="$FONT_SIZE div 2" />
- <xsl:if test="$index < $yMax">
- <xsl:variable name="y">
- <xsl:choose>
- <xsl:when test="$yMin < 0">
- <xsl:value-of select="floor($yScale*($yMax - $index + $step div 2))" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="floor($yScale*($yMax - $index))" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <svg:text x="{($xMin - 5)}" y="{($y + $labelDelta)}"
- text-anchor="end" fill="black" font-family="{$FONT}" font-weight="bold"
- font-size="{$FONT_SIZE}" xmlns:svg="http://www.w3.org/2000/svg">
- <xsl:value-of select="$index" />
- </svg:text>
- <svg:line x1="{$xMin}" y1="{$y}" x2="{$xMax}" y2="{$y}"
- stroke="grey" stroke-width="0.25" xmlns:svg="http://www.w3.org/2000/svg" />
- <xsl:call-template name="printYAxis">
- <xsl:with-param name="index" select="$index+$step" />
- <xsl:with-param name="step" select="$step" />
- <xsl:with-param name="xMin" select="$xMin" />
- <xsl:with-param name="xMax" select="$xMax" />
- <xsl:with-param name="yMin" select="$yMin" />
- <xsl:with-param name="yMax" select="$yMax" />
- <xsl:with-param name="yScale" select="$yScale" />
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
-
-
- <xsl:template name="p5gnuplot:printYAxis">
- <xsl:param name="index.context.position" select="1"/>
- <xsl:param name="index" />
- <xsl:param name="index2" />
- <xsl:param name="step" />
- <xsl:param name="step2" />
- <xsl:param name="stepAll" />
-
- <xsl:param name="yDelta"/>
- <xsl:param name="y2Delta"/>
- <xsl:param name="yAllDelta"/>
- <xsl:param name="yAllDataMax" />
- <xsl:param name="xMin" />
- <xsl:param name="xMax" />
- <xsl:param name="yMin" />
- <xsl:param name="y2Min" />
- <xsl:param name="yAllMin" />
- <xsl:param name="yMax" />
- <xsl:param name="y2Max" />
- <xsl:param name="yAllMax" />
- <xsl:param name="viewBoxHeight"/>
- <xsl:param name="yAllDataMin"/>
- <xsl:param name="yScale" />
- <xsl:param name="y2Scale" />
- <xsl:param name="yAllScale" />
- <xsl:param name="totalHeightAll"/>
- <xsl:param name="Data.analyzed" required="yes" tunnel="yes"/>
- <xsl:variable name="labelDelta" select="$FONT_SIZE div 2" />
- <xsl:variable name="index.context.value.y" select="$Data.analyzed//yData.postition[@pos=$index.context.position]/text()"/>
- <xsl:variable name="index.context.value.y2" select="$Data.analyzed//y2Data.postition[@pos=$index.context.position]/text()"/>
-
- <xsl:if test="$Data.analyzed//yData.postition[@pos=$index.context.position]"><!-- $index < $yMax -->
- <!--<xsl:variable name="y" select="$totalHeightAll - ($yDelta * $index.context.value.y) "/>-->
- <!--<xsl:variable name="y.test" select="$viewBoxHeight - (($viewBoxHeight div ($yAllDataMax - $yAllDataMin)) * ($index.context.value.y - $yAllDataMin))"/>-->
- <xsl:variable name="y" select="$viewBoxHeight - (($viewBoxHeight div ($yAllDataMax - $yAllDataMin)) * ($index.context.value.y - ($yAllDataMin )))">
- <!--<xsl:choose>
- <xsl:when test="$yAllMin < 0"><!-\- $yMin -\->
- <xsl:value-of select="floor($yAllScale*($yAllMax - $index.context.value.y + $stepAll div 2))" /><!-\-$index $step $yMax $yScale-\->
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="floor($yAllScale*($yAllMax - $index.context.value.y))" /><!-\- $index$yMax $yScale -\->
- </xsl:otherwise>
- </xsl:choose>-->
- </xsl:variable>
-
- <xsl:variable name="y2.test" select="$viewBoxHeight - (( $viewBoxHeight div $yAllDataMax ) * $index.context.value.y2 ) "/>
- <xsl:variable name="y2" select="$viewBoxHeight - (($viewBoxHeight div ($yAllDataMax - $yAllDataMin)) * ( $index.context.value.y2 - $yAllDataMin )) "><!-- $totalHeightAll - ($y2Delta * $index.context.value.y2) -->
- <!--<xsl:choose>
- <xsl:when test="$yAllMin < 0"><!-\- $y2Min -\->
- <xsl:value-of select="floor($yAllScale*($yAllMax - $index.context.value.y2 + $stepAll div 2))" /><!-\-$index2 $y2Max $yScale -\->
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="floor($yAllScale*($yAllMax - $index.context.value.y2))" /><!-\-$index2 $y2Max $y2Scale -\->
- </xsl:otherwise>
- </xsl:choose>-->
- </xsl:variable>
-
- <svg:text x="{($xMin - 5)}" y="{($y + $labelDelta)}"
- deb="178-do-y1 val={$index.context.value.y} pos.{$index.context.position}
- $viewBoxHeight={$viewBoxHeight}
- div={(($viewBoxHeight div $yAllDataMax) * $index.context.value.y)}
- tuned={($viewBoxHeight div ($yAllDataMax - $yAllDataMin))}
- Mx-Min={($yAllDataMax - $yAllDataMin)}
- Vb_div(Mx-Min)={($viewBoxHeight div ($yAllDataMax - $yAllDataMin))}
- V-Admin={($index.context.value.y - $yAllDataMin)}
- V-divAdmax={($index.context.value.y div $yAllDataMax)}
- "
- text-anchor="end" fill="black" font-family="{$FONT}" font-weight="bold"
- font-size="{$FONT_SIZE}" xmlns:svg="http://www.w3.org/2000/svg">
- <xsl:choose>
- <xsl:when test="$Data.analyzed//yData.postition[@pos=$index.context.position]/@yData.attr.title">
- <xsl:value-of select="$Data.analyzed//yData.postition[@pos=$index.context.position]/@yData.attr.title" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$index.context.value.y" />
- </xsl:otherwise>
- </xsl:choose>
-
- <!--<xsl:value-of select="' $y '"/>
- <xsl:value-of select="$y"/>-->
- </svg:text>
-
- <svg:text x="{($xMin - 5)}" y="{($y2 + $labelDelta)}" deb="178-do-y2 $y2.test={$y2.test} val={$index.context.value.y2} pos.{$index.context.position}"
- text-anchor="end" fill="black" font-family="{$FONT}" font-weight="bold"
- font-size="{$FONT_SIZE}" xmlns:svg="http://www.w3.org/2000/svg">
-
- <xsl:choose>
- <xsl:when test="$Data.analyzed//y2Data.postition[@pos=$index.context.position]/@y2Data.attr.title">
- <xsl:value-of select="$Data.analyzed//y2Data.postition[@pos=$index.context.position]/@y2Data.attr.title" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$index.context.value.y2" />
- </xsl:otherwise>
- </xsl:choose>
-
- <!--<xsl:value-of select="' $y2 '"/>
- <xsl:value-of select="$y2"/>-->
- </svg:text>
-
- <svg:line x1="{$xMin}" y1="{$y}" x2="{$xMax}" y2="{$y}" deb="#210A-all-os-tylko poziomy tik1"
- stroke="grey" stroke-width="0.25" xmlns:svg="http://www.w3.org/2000/svg" />
- <svg:line x1="{$xMin}" y1="{$y2}" x2="{$xMax}" y2="{$y2}" deb="#210B-all-os-tylko poziomy tik2"
- stroke="grey" stroke-width="0.25" xmlns:svg="http://www.w3.org/2000/svg" />
-
- <xsl:call-template name="p5gnuplot:printYAxis">
- <xsl:with-param name="index.context.position" select="$index.context.position + 1"/>
- <xsl:with-param name="index" select="$index+$step" />
- <xsl:with-param name="index2" select="$index2+$step2"/>
- <xsl:with-param name="step" select="$step" />
- <xsl:with-param name="step2" select="$step2" />
- <xsl:with-param name="stepAll" select="$stepAll" />
- <xsl:with-param name="xMin" select="$xMin" />
- <xsl:with-param name="xMax" select="$xMax" />
- <xsl:with-param name="yMin" select="$yMin" />
- <xsl:with-param name="y2Min" select="$y2Min"/>
- <xsl:with-param name="yAllMin" select="$yAllMin"/>
- <xsl:with-param name="yMax" select="$yMax" />
- <xsl:with-param name="y2Max" select="$y2Max" />
- <xsl:with-param name="yAllMax" select="$yAllMax" />
- <xsl:with-param name="yAllDataMax" select="$yAllDataMax"/>
- <xsl:with-param name="viewBoxHeight" select="$viewBoxHeight"/>
- <xsl:with-param name="yDelta" select="$yDelta"/>
- <xsl:with-param name="y2Delta" select="$y2Delta"/>
- <xsl:with-param name="yAllDelta" select="$yAllDelta"/>
- <xsl:with-param name="yAllDataMin" select="$yAllDataMin"/>
- <xsl:with-param name="totalHeightAll" select="$totalHeightAll"/>
- <xsl:with-param name="yScale" select="$yScale" />
- <xsl:with-param name="y2Scale" select="$y2Scale" />
- <xsl:with-param name="yAllScale" select="$y2Scale" />
- <xsl:with-param name="Data.analyzed" select="$Data.analyzed" tunnel="yes"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
- </xsl:stylesheet>
|