I wanted to load a canvas to calculate the profile meter for user. I calculated the the value and assigned it to a angular scope variable. My canvas code is in the inline javascript. How can I assign the value to the variable in inline javascript?
here's the code to the Canvas and my jade file:
var ctx = document.getElementById('my_canvas').getContext('2d');
var al= document.getElementById('my_canvas').value;
var start = 4.72;
var cw = ctx.canvas.width;
var ch = ctx.canvas.height;
var diff;
function progressSim(){
diff = ((al / 100) * Math.PI*2*10).toFixed(2);
ctx.clearRect(0, 0, cw, ch);
ctx.lineWidth = 10;
ctx.fillStyle = '#09F';
ctx.strokeStyle = "#09F";
ctx.textAlign = 'center';
ctx.fillText(al+'%', cw*.5, ch*.5+2, cw);
ctx.beginPath();
ctx.arc(35, 35, 30, start, diff/10+start, false);
ctx.stroke();
}
progressSim();
<!-- canvas(id="my_canvas" width="70" height="70") -->
<canvas id="my_canvas" width="70" height="70" />
and also is there a better approach to do this?
here's the working Plunker ! https://plnkr.co/edit/5qKZ9fGY1miinouWC7Iy
70to be assigned instead ofal = 50?