X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=inline;f=tests%2Flinear-regression-addseries.html;h=81f7f43476e81e6b6dc90eff5d0f5b3ae684f3e3;hb=77a1405a7dea7e9de770583598a50e5907e6b1a1;hp=2a746b5e2d5e600bd38b985f5ff2ceeae389fa7a;hpb=fb25c8b6d070c7e347b260ef39917220b6159e4e;p=dygraphs.git
diff --git a/tests/linear-regression-addseries.html b/tests/linear-regression-addseries.html
index 2a746b5..81f7f43 100644
--- a/tests/linear-regression-addseries.html
+++ b/tests/linear-regression-addseries.html
@@ -1,13 +1,13 @@
+
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;
@@ -80,6 +84,10 @@
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 +100,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