From: Christopher Weiss Date: Tue, 21 Oct 2014 01:49:41 +0000 (-0400) Subject: Prototype for hue() & default fillColor to use it. X-Git-Tag: v2.0-alpha~47^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e21147cbb9e93797b1b3949a722b4958eed05a32;p=thirdparty%2FChart.js.git Prototype for hue() & default fillColor to use it. --- diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index 35de93c7f..0dab405c8 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -36,6 +36,14 @@ }; + function hue(part, total) { + var h, s, v, c, x, m, + r = '00', + g = '00', + b = '00'; + + return '#' + r + g + b; + } Chart.Type.extend({ //Passing in a name registers this chart in the Chart namespace @@ -94,7 +102,7 @@ value : segment.value, outerRadius : (this.options.animateScale) ? 0 : this.outerRadius, innerRadius : (this.options.animateScale) ? 0 : (this.outerRadius/100) * this.options.percentageInnerCutout, - fillColor : segment.color, + fillColor : segment.color || hue(index, this.segments.length), highlightColor : segment.highlight || segment.color, showStroke : this.options.segmentShowStroke, strokeWidth : this.options.segmentStrokeWidth, @@ -181,4 +189,4 @@ defaults : helpers.merge(defaultConfig,{percentageInnerCutout : 0}) }); -}).call(this); \ No newline at end of file +}).call(this);