Skip to content

Commit

Permalink
fix: centred errorbars on dot
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierSwaak committed Jul 14, 2024
1 parent b7b1b7a commit 7fb0a41
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions docs/assets/uncertainty/uncertainty.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const ys = [];
function addPoint(e) {
const click_box = document.getElementById("click_box");
var rect = click_box.getBoundingClientRect();
var x = (e.clientX - rect.left - 6) / rect.width * 100;
var y = (e.clientY - rect.top - 6) / rect.width * 100;
var x = (e.clientX - rect.left - 5) / rect.width * 100;
var y = (e.clientY - rect.top - 5) / rect.width * 100;

xs.push(x);
ys.push(y);
Expand Down Expand Up @@ -53,18 +53,21 @@ function updateCentre() {
var dx = Math.pow(x_square_sum, 0.5) / xs.length
var dy = Math.pow(y_square_sum, 0.5) / ys.length

const display_box = document.getElementById("display_box");
var rect = display_box.getBoundingClientRect();

const xbar = document.getElementById("xbar");
const ybar = document.getElementById("ybar");

xbar.x1.baseVal.value = x - dx;
xbar.x2.baseVal.value = x + dx;
xbar.y1.baseVal.value = y;
xbar.y2.baseVal.value = y;
xbar.x1.baseVal.value = x - dx + 5 / rect.width * 100;
xbar.x2.baseVal.value = x + dx + 5 / rect.width * 100;
xbar.y1.baseVal.value = y + 5 / rect.width * 100;
xbar.y2.baseVal.value = y + 5 / rect.width * 100;

ybar.x1.baseVal.value = x;
ybar.x2.baseVal.value = x;
ybar.y1.baseVal.value = y - dy;
ybar.y2.baseVal.value = y + dy;
ybar.x1.baseVal.value = x + 5 / rect.width * 100;
ybar.x2.baseVal.value = x + 5 / rect.width * 100;
ybar.y1.baseVal.value = y - dy + 5 / rect.width * 100;
ybar.y2.baseVal.value = y + dy + 5 / rect.width * 100;

const meanpoint = document.getElementById("mean_point");
meanpoint.style.left = x + "%";
Expand Down

0 comments on commit 7fb0a41

Please sign in to comment.