X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Flinear-regression-addseries.html;h=c77020d9ba17cb5df4e1d79ba8788b3c6373e331;hb=6e20721120a88fcf451c19559dfc62e2d316dd85;hp=4445f471f14694585454afb3d7df1bd0df15ad00;hpb=895b3657b0ab22bb35815a1687c71116b2d8b36c;p=dygraphs.git
diff --git a/tests/linear-regression-addseries.html b/tests/linear-regression-addseries.html
index 4445f47..c77020d 100644
--- a/tests/linear-regression-addseries.html
+++ b/tests/linear-regression-addseries.html
@@ -1,13 +1,10 @@
+
+
Linear Regression
-
-
-
-
-
+
+
@@ -61,6 +58,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,13 +74,17 @@
var b = (sum_y - a * sum_x) / num;
coeffs[series] = [b, a];
- if (console) {
+ if (typeof(console) != 'undefined') {
console.log("coeffs(" + series + "): [" + b + ", " + a + "]");
}
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 = [];
@@ -92,11 +97,11 @@
// Darken the series by 50% to generate its regression.
var label = labels[i] + " Regression";
new_labels.push(label);
- var c = new RGBColor(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