From 0a171c099dc29436dc356b2791b2b677d0582d62 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sat, 22 Nov 2014 01:38:57 -0500 Subject: [PATCH] fix linear regression tests --- tests/linear-regression-addseries.html | 8 ++++++-- tests/linear-regression-fractions.html | 13 +++++++++---- tests/linear-regression.html | 8 ++++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/linear-regression-addseries.html b/tests/linear-regression-addseries.html index 5e79860..f44df53 100644 --- a/tests/linear-regression-addseries.html +++ b/tests/linear-regression-addseries.html @@ -88,6 +88,10 @@ updateChart(); } + function toHex(rgb) { + return 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')'; + } + function updateChart() { // Generate a new data set with the regression lines. var new_labels = []; @@ -100,11 +104,11 @@ // Darken the series by 50% to generate its regression. var label = labels[i] + " Regression"; new_labels.push(label); - var c = new RGBColorParser(orig_colors[i - 1]); + var c = Dygraph.toRGB_(orig_colors[i - 1]); c.r = Math.floor(255 - 0.5 * (255 - c.r)); c.g = Math.floor(255 - 0.5 * (255 - c.g)); c.b = Math.floor(255 - 0.5 * (255 - c.b)); - new_colors.push(c.toHex()); + new_colors.push(toHex(c)); new_opts[label] = { drawPoints: false, strokeWidth: 1.0 diff --git a/tests/linear-regression-fractions.html b/tests/linear-regression-fractions.html index 253fa60..8b3a6d8 100644 --- a/tests/linear-regression-fractions.html +++ b/tests/linear-regression-fractions.html @@ -42,7 +42,8 @@ drawPoints: true, strokeWidth: 0.0, fractions: true, - errorBars: true + errorBars: true, + pointSize: 1 } ); @@ -89,6 +90,10 @@ g.updateOptions({}); } + function toHex(rgb) { + return 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')'; + } + function drawLines(ctx, area, layout) { if (typeof(g) == 'undefined') return; // won't be set on the initial draw. @@ -110,14 +115,14 @@ var p1 = g.toDomCoords(x1, y1); var p2 = g.toDomCoords(x2, y2); - var c = new RGBColorParser(g.getColors()[i - 1]); + var c = Dygraph.toRGB_(g.getColors()[i - 1]); c.r = Math.floor(255 - 0.5 * (255 - c.r)); c.g = Math.floor(255 - 0.5 * (255 - c.g)); c.b = Math.floor(255 - 0.5 * (255 - c.b)); - var color = c.toHex(); + var color = toHex(c); ctx.save(); ctx.strokeStyle = color; - ctx.lineWidth = 1.0; + ctx.lineWidth = 2.0; ctx.beginPath(); ctx.moveTo(p1[0], p1[1]); ctx.lineTo(p2[0], p2[1]); diff --git a/tests/linear-regression.html b/tests/linear-regression.html index d7c3700..41cfbf3 100644 --- a/tests/linear-regression.html +++ b/tests/linear-regression.html @@ -87,6 +87,10 @@ g.updateOptions({}); } + function toHex(rgb) { + return 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')'; + } + function drawLines(ctx, area, layout) { if (typeof(g) == 'undefined') return; // won't be set on the initial draw. @@ -104,11 +108,11 @@ var p1 = g.toDomCoords(x1, y1); var p2 = g.toDomCoords(x2, y2); - var c = new RGBColorParser(g.getColors()[i - 1]); + var c = Dygraph.toRGB_(g.getColors()[i - 1]); c.r = Math.floor(255 - 0.5 * (255 - c.r)); c.g = Math.floor(255 - 0.5 * (255 - c.g)); c.b = Math.floor(255 - 0.5 * (255 - c.b)); - var color = c.toHex(); + var color = toHex(c); ctx.save(); ctx.strokeStyle = color; ctx.lineWidth = 1.0; -- 2.7.4