X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Flinear-regression.html;h=873e7ca4791614014884a19d83d38df9dcbb1e0a;hb=93a5bb4c827d6665f395c48b216438f95e94d76e;hp=6a469b8d8290d4193f083aee07e80d5c3aeb4922;hpb=1f75a05ce24d88587871a7305f1982010577cd33;p=dygraphs.git diff --git a/tests/linear-regression.html b/tests/linear-regression.html index 6a469b8..873e7ca 100644 --- a/tests/linear-regression.html +++ b/tests/linear-regression.html @@ -1,13 +1,14 @@ + + Linear Regression - - - - - + + + @@ -55,6 +56,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 +84,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 +105,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;