Dave Jarvis' Repositories

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

Corrected pie chart color selection computation to reduce consecutive colours for adjancent wedges.

Author Dave Jarvis <email>
Date 2014-09-18 15:32:23 GMT-0700
Commit d7f5989739f3d6843b05135a07505ed8d7a6fef6
Parent 8b23e8e
xml/Adjacency.java
+public class Adjacency {
+ /**
+ * Shifts the index for even numbers by 4.
+ */
+ public static long d( int n, int t ) {
+ long te = t + (1- (t%2));
+
+ return (long)((n-(t%2))*Math.floor(t/2) % te) + (t%2) - 1;
+ }
+
+ public static void main( String args[] ) {
+ int t = 9;
+ for( int i = 1; i <= t; i++ ) {
+ System.out.printf( "%d\n", d(i, t) );
+ //System.out.printf( "d(%02d) = %d\n", i, d(i, t) );
+ }
+ }
+}
+
xml/colour.xsl
<!--
| Prevent similar adjacent colours.
- | http://math.stackexchange.com/a/936767/7932
+ |
+ | wi = wedge index number
+ | wt = total number of wedges
+ | wte = evenness determiniate for wt
+ |
+ | http://math.stackexchange.com/a/936276/7932
+-->
<xsl:variable name="wi" select="$wedge"/>
<xsl:variable name="wt" select="$wedges"/>
- <xsl:variable name="w">
- <xsl:choose>
- <xsl:when test="$wt &gt; 5">
- <xsl:variable name="weven" select="(($wi+4) mod ($wt + $wt mod 2))"/>
- <xsl:value-of
- select="$weven * (1-($wi mod 2)) + ($wi mod 2 * $wi)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$wedge"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
+ <xsl:variable name="wte" select="$wt + (1 - ($wt mod 2))"/>
+
+ <xsl:variable name="w" select="
+ round(($wi - ($wt mod 2)) *
+ floor( $wt div 2 ) mod $wte) +
+ ($wt mod 2)"/>
<!-- lch_l, lch_c, and lch_h are now set; rotate the hue. -->
xml/resources.css
}
-.data:nth-child(odd) {
+.data, .data:nth-child(odd) {
display: table-row;
+}
+
+.data:nth-child(odd) {
background-color: #EEE;
}
Delta 35 lines added, 14 lines removed, 21-line increase