Skip to content

Instantly share code, notes, and snippets.

@josteinaj
Last active July 7, 2020 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save josteinaj/f35ccef3513d6e6f031c68e339745ba9 to your computer and use it in GitHub Desktop.
Save josteinaj/f35ccef3513d6e6f031c68e339745ba9 to your computer and use it in GitHub Desktop.
window.setInterval(function(){
var paths = $("#scatter-chart > svg > g > g > g.nv-scatterWrap.nvd3-svg > g > g:nth-child(2) > g.nv-groups > g").children();
var x = [];
var y = [];
var mean_x = 0;
var mean_y = 0;
var ab = 0;
var a2 = 0;
var b2 = 0;
for (var p = 0; p < paths.length; p++) {
var xy = $(paths[p]).attr("transform").replace(/.*\(/,'').replace(/\).*/,'').split(',');
x[p] = parseFloat(xy[0]);
y[p] = parseFloat(xy[1]);
mean_x += x[p];
mean_y += y[p];
}
mean_x /= paths.length;
mean_y /= paths.length;
for (var p = 0; p < x.length; p++) {
x[p] -= mean_x;
y[p] -= mean_y;
ab += x[p]*y[p];
a2 += x[p]*x[p];
b2 += y[p]*y[p];
}
var result = ab / Math.sqrt(a2*b2);
$("#guess-input").val(""+(Math.round(Math.abs(result)*100)/100));
$("#submit-btn").click();
window.setTimeout(function(){
$("#next-btn").click();
},100);
},500)
@Yemeen
Copy link

Yemeen commented Jul 6, 2020

How do run

@josteinaj
Copy link
Author

I don't remember what this is, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment