X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=tests%2Flinear-regression-addseries.html;h=3fd3a85c01f3a507b8e4870363d9d4d2c1cbfa60;hb=7aedf6fee4cad9a3fc6de49476fc176e48a090fa;hp=530cea319de90e207db94a5f8b5b37ae1b93c465;hpb=de0445fc1b969ab85a3d985dbd1e6747f3ddac0b;p=dygraphs.git
diff --git a/tests/linear-regression-addseries.html b/tests/linear-regression-addseries.html
index 530cea3..3fd3a85 100644
--- a/tests/linear-regression-addseries.html
+++ b/tests/linear-regression-addseries.html
@@ -2,7 +2,7 @@
Linear Regression
@@ -61,6 +61,10 @@
var y = data[i][series];
if (y == null) continue;
+ if (y.length == 2) {
+ // using fractions
+ y = y[0] / y[1];
+ }
num++;
sum_x += x;
@@ -73,7 +77,7 @@
var b = (sum_y - a * sum_x) / num;
coeffs[series] = [b, a];
- if (console) {
+ if (typeof(console) != 'undefined') {
console.log("coeffs(" + series + "): [" + b + ", " + a + "]");
}
@@ -88,16 +92,16 @@
for (var i = 0; i < labels.length; i++) {
new_labels.push(labels[i]);
if (i) new_colors.push(orig_colors[i - 1]);
- new_opts[new_colors.length] = null;
if (coeffs[i]) {
// Darken the series by 50% to generate its regression.
- new_labels.push(labels[i] + " Regression");
+ var label = labels[i] + " Regression";
+ new_labels.push(label);
var c = new RGBColor(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_opts[new_colors.length] = {
+ new_opts[label] = {
drawPoints: false,
strokeWidth: 1.0
};