X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=gallery%2Flinear-regression.js;h=43daecd927f7483678147c08e79698a9fb32e89e;hb=214083b469aec7f51223ec5c1532924d75c6eb2f;hp=77f69c51ae02d6077963c6a06150aeaadc610d1a;hpb=e14dc3feda3e6d429bb953dab83c593d851d90af;p=dygraphs.git diff --git a/gallery/linear-regression.js b/gallery/linear-regression.js index 77f69c5..43daecd 100644 --- a/gallery/linear-regression.js +++ b/gallery/linear-regression.js @@ -1,21 +1,20 @@ -// Use this as a template for new Gallery entries. Gallery.register( 'linear-regression', { name: 'Linear Regressions', title: 'Linear Regression Demo', setup: function(parent) { - parent.innerHTML = - "

Click the buttons to generate linear regressions over either data "+ - "series. If you zoom in and then click the regression button, the regression "+ - "will only be run over visible points. Zoom back out to see what the local "+ - "regression looks like over the full data.

"+ - "
" + - "
" + - " " + - " " + - "" + - "
"; + parent.innerHTML = [ + "

Click the buttons to generate linear regressions over either data ", + "series. If you zoom in and then click the regression button, the regression ", + "will only be run over visible points. Zoom back out to see what the local ", + "regression looks like over the full data.

", + "
", + "
", + " ", + " ", + "", + "
"].join("\n"); }, run: function() { document.getElementById("ry1").onclick = function() { regression(1) }; @@ -29,17 +28,6 @@ Gallery.register( 30.0 - i / 5.0 - 10.0 * Math.sin(i / 3.0 + 1.0)]); } - g = new Dygraph( - document.getElementById("demodiv"), - data, - { - labels: ['X', 'Y1', 'Y2'], - underlayCallback: drawLines, - drawPoints: true, - strokeWidth: 0.0 - } - ); - // coefficients of regression for each series. // if coeffs = [ null, [1, 2], null ] then we draw a regression for series 1 // only. The regression line is y = 1 + 2 * x. @@ -116,5 +104,17 @@ Gallery.register( ctx.restore(); } } + + g = new Dygraph( + document.getElementById("demodiv"), + data, + { + labels: ['X', 'Y1', 'Y2'], + underlayCallback: drawLines, + drawPoints: true, + drawAxesAtZero: true, + strokeWidth: 0.0 + } + ); } });