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));
}
var cumulative_sum = 0; // used only if we have a stackedGraph.
var l = points.length;
var isStacked = this.attr_("stackedGraph");
- for (var i = 0; i < l; i++) {
+ for (var i = l - 1; i >= 0; i--) {
if (points[i].xval == lastx) {
if (!isStacked) {
- this.selPoints_.push(points[i]);
+ this.selPoints_.unshift(points[i]);
} else {
// Clone the point, since we need to 'unstack' it below. Stacked points
// are in reverse order.
var p = {};
- for (var k in points[l - i - 1]) {
- p[k] = points[l - i -1][k];
+ for (var k in points[i]) {
+ p[k] = points[i][k];
}
p.yval -= cumulative_sum;
cumulative_sum += p.yval;
+ this.selPoints_.push(p);
}
}
}