There's a graph that has measurements ranging from -100 to 0 and 0 to 100. What I need to do is adjust the calculation of the ball's position with the number according to the gradientDataChart input, which can be a value between -100 and 100, the problem is proportionality, depending on the screen, the ball is disappearing, I was using distance 16, but it only worked for a width of 586px;
I tested it here if that might make it easier.
Just writing this code, I used 38 for 900 width, the problem is that if you change it to 1000, it goes out of position... it needs to be responsive:
var widthDefault = 900, metric = -100, calcPos = 38 * ((metric / widthDefault) * 100);
ctx.beginPath();
canvas.width = widthDefault;
ctx.translate(calcPos, 0);
var centerX = canvas.width / 2;
var centerY = canvas.height / 2;
ctx.arc(centerX, centerY, 24, 0, Math.PI * 2, false);
ctx.fillStyle ="#ffffff";
ctx.fill()
ctx.font = 'bold 14pt sans-serif';
ctx.textAlign = 'center';
ctx.strokeStyle ='#622BCF'
ctx.stroke();
ctx.fillStyle ="#622bcf80";
ctx.fillText(`${medida}`, centerX, centerY+8);
ctx.globalCompositeOperation = 'destination-over';
