X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Flinear-regression.html;h=c38ed3366daf798dc58570532c812c92a83275ca;hb=da2a028fc41e5573868358b3d9eda9826211d217;hp=03c95c23b4b870da173a1efb48b2490924a733cf;hpb=b03b9d235686d105e46a4263bcaddf8eee2b9553;p=dygraphs.git diff --git a/tests/linear-regression.html b/tests/linear-regression.html index 03c95c2..c38ed33 100644 --- a/tests/linear-regression.html +++ b/tests/linear-regression.html @@ -1,13 +1,10 @@ + + Linear Regression - - - - - + + @@ -55,6 +52,10 @@ var y = g.getValue(i, series); if (y == null) continue; + if (y.length == 2) { + // using fractions + y = y[0] / y[1]; + } num++; sum_x += x; @@ -79,6 +80,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. @@ -96,11 +101,11 @@ var p1 = g.toDomCoords(x1, y1); var p2 = g.toDomCoords(x2, y2); - var c = new RGBColor(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;