Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/delibero.git

Fixed bug with large values.

Author Dave Jarvis <email>
Date 2014-08-01 01:36:44 GMT-0700
Commit 2a062c8fe43c68d5193e3b634ae3e88934ebc5fe
Parent 6b138cf
xml/chart.xsl
<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() &lt;= $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 &lt; 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>
xml/math.xsl
-<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="PI">3.14159265358979323846</xsl:variable>
<xsl:variable name="DEGREES" select="180 div $PI" />
- <xsl:variable name="PRECISION">0.0001</xsl:variable>
+ <xsl:variable name="PRECISION">0.00001</xsl:variable>
<xsl:template name="sqrt">
xml/resources.xml
<title>Expenses</title>
<dataset>
+ <!--
<data>
<name>Public Debt</name>
- <value>11</value>
+ <value>150</value>
+ </data>
+ <data>
+ <name>Miscellaneous</name>
+ <value>21</value>
</data>
<data>
<name>Transfers to Government</name>
<value>21</value>
+ </data>
+ -->
+ <data>
+ <name>Personnel</name>
+ <value>2991854</value>
+ </data>
+ <data>
+ <name>Transportation and Communications</name>
+ <value>259084</value>
+ </data>
+ <data>
+ <name>Information</name>
+ <value>7349</value>
+ </data>
+ <data>
+ <name>Professional and Special Services</name>
+ <value>393783</value>
+ </data>
+ <data>
+ <name>Rentals</name>
+ <value>95947</value>
+ </data>
+ <data>
+ <name>Repair and Maintenance</name>
+ <value>115060</value>
+ </data>
+ <data>
+ <name>Utilities, Materials, and Supplies</name>
+ <value>143399</value>
+ </data>
+ <data>
+ <name>Land, Buildings, and Works Acquisitions</name>
+ <value>81614</value>
+ </data>
+ <data>
+ <name>Machinery and Equipment Acquisitions</name>
+ <value>292968</value>
+ </data>
+ <data>
+ <name>Transfer Payments</name>
+ <value>137863</value>
+ </data>
+ <data>
+ <name>Miscellaneous</name>
+ <value>88078</value>
</data>
+ -->
</dataset>
</expenses>
Delta 69 lines added, 13 lines removed, 56-line increase