| | <xsl:template match="dataset" mode="piechart"> |
| | <xsl:variable name="pie_width">100</xsl:variable> |
| | - <xsl:variable name="pie_height" select="$pie_width - $PI" /> |
| | + <xsl:variable name="pie_height" select="$pie_width" /> |
| | |
| | <!-- Number of pie pieces. --> |
 |
| | <xsl:variable name="rx" select="$pie_width * 0.5" /> |
| | <xsl:variable name="ry" select="$pie_height * 0.5" /> |
| | + |
| | + <svg:rect x="{360 * (1 - sum(//data[position() <= $piece -1]/value[position() = $item]) div $total)}" /> |
| | |
| | <xsl:variable name="deg"> |
 |
| | </xsl:call-template> |
| | </xsl:variable> |
| | + |
| | + <xsl:variable name="opt"><xsl:choose><xsl:when test="$deg - $deg2 < 180">0</xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose></xsl:variable> |
| | |
| | <!-- Fill the pie piece. --> |
| | - <svg:path fill="{$fill}" title="{$percent}" stroke="white" stroke-width="0.5" d="{concat('M',$x+$rx,' ',$y+$ry,'L',$x+$rx+$rx*$c2,' ',$y+$ry+$ry*$s2,'A',$rx,' ',$ry,' 0 ',0,' 1 ',$x+$rx + $rx * $c,' ',$y+$ry +$ry*$s,'z')}" /> |
| | + <svg:path fill="{$fill}" title="{$percent}" stroke="white" stroke-width="0.5" d="{concat('M',$x+$rx,' ',$y+$ry,'L',$x+$rx+$rx*$c2,' ',$y+$ry+$ry*$s2,'A',$rx,' ',$ry,' 0 ',$opt,' 1 ',$x+$rx + $rx * $c,' ',$y+$ry +$ry*$s,'z')}" /> |
| | </xsl:for-each> |
| | </xsl:for-each> |
| | </svg:g> |
| | </svg:svg> |
| | </div> |
| | |
| | - <xsl:variable name="font_size">6</xsl:variable> |
| | - <xsl:variable name="line_space">2</xsl:variable> |
| | + <xsl:variable name="bullet_size" select="5" /> |
| | + <xsl:variable name="font_size" select="6" /> |
| | + <xsl:variable name="line_space" select="2" /> |
| | <xsl:variable name="legend_width" select="$pie_width" /> |
| | - <xsl:variable name="legend_height" select="($font_size + $line_space) * $pieces" /> |
| | + <xsl:variable name="legend_height" select="($font_size + $line_space) * $pieces + $bullet_size" /> |
| | |
| | <div class="legend"> |
| | - <svg:svg width="30%" height="30%" viewBox="0 0 {$legend_width} {$legend_height}" version="1.1"> |
| | + <svg:svg width="30%" height="30%" viewBox="0 0 {$legend_width + $bullet_size * 2} {$legend_height}" version="1.1"> |
| | <xsl:for-each select="//name"> |
| | |
 |
| | |
| | <xsl:variable name="dy" select="position() * ($font_size + $line_space)" /> |
| | - <xsl:variable name="percent" select="concat(.,' (',format-number(. div $total, '0.00%'),')')" /> |
| | + <xsl:variable name="percent" select="concat(.,' (',format-number(../value div $total, '0.00%'),')')" /> |
| | |
| | - <svg:rect x="0" y="{$dy - 2 * $line_space}" width="5" height="5" fill="{$fill}" /> |
| | - <svg:text x="10" y="{$dy}" font-size="{$font_size}"><xsl:value-of select="$percent" /></svg:text> |
| | + <svg:rect x="0" y="{$dy - $line_space}" width="{$bullet_size}" height="{$bullet_size}" fill="{$fill}" /> |
| | + <svg:text x="10" y="{$dy + $line_space}" font-size="{$font_size}"><xsl:value-of select="$percent" /></svg:text> |
| | </xsl:for-each> |
| | </svg:svg> |
 |
| | </xsl:when> |
| | <xsl:otherwise> |
| | - <xsl:value-of select="concat('rgb(', $cm, ',', $xm, ',', $zm, ')' )" /> |
| | + <xsl:value-of select="concat('rgb(', $r, ',', $g, ',', $b, ')' )" /> |
| | </xsl:otherwise> |
| | </xsl:choose> |