From: Nikhil Kasinadhuni Date: Thu, 11 Mar 2010 03:19:09 +0000 (-0800) Subject: Get the color alternating logic right. X-Git-Tag: v1.0.0~702^2~3 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=2aa21213e0c8f56985595ebd106dad77583a6b4e;p=dygraphs.git Get the color alternating logic right. --- diff --git a/dygraph.js b/dygraph.js index 1b4600e..954d067 100644 --- a/dygraph.js +++ b/dygraph.js @@ -527,10 +527,11 @@ Dygraph.prototype.setColors_ = function() { if (!colors) { var sat = this.attr_('colorSaturation') || 1.0; var val = this.attr_('colorValue') || 0.5; + var half = Math.ceil(num / 2); for (var i = 1; i <= num; i++) { if (!this.visibility()[i-1]) continue; // alternate colors for high contrast. - var idx = i - parseInt(i % 2 ? i / 2 : (i - num)/2, 10); + var idx = i % 2 ? Math.ceil(i / 2) : (half + i / 2); var hue = (1.0 * idx/ (1 + num)); this.colors_.push(Dygraph.hsvToRGB(hue, sat, val)); }