From 2aa21213e0c8f56985595ebd106dad77583a6b4e Mon Sep 17 00:00:00 2001 From: Nikhil Kasinadhuni Date: Wed, 10 Mar 2010 19:19:09 -0800 Subject: [PATCH] Get the color alternating logic right. --- dygraph.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)); } -- 2.7.4