JSFiddle - React, Tailwind, and code Playground
HTML
<canvas id="lifeline" width="500" height="500"></canvas>
JavaScript
function rad(deg){
return (Math.PI/180)*deg;
}
function percentToRad(percent){
return rad(270) + rad ((360 * percent) / 100);
}
var ctx = document.getElementById('lifeline').getContext('2d');
function draw(x,y, percent){
ctx.lineWidth = 5;
ctx.beginPath();
ctx.strokeStyle ='rgb(221,221,221)';
ctx.arc(x,y, 45, rad(270), percentToRad(100), false);
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = 'rgba(255,65,54,.8)';
ctx.arc(x, y, 45, rad(270), percentToRad(percent), false);
ctx.stroke();
ctx.beginPath();
ctx.fillStyle = 'rgb(57,204,204)';
ctx.arc(x,y, 40, 0, 2*Math.PI, false);
ctx.fill();
}
draw(50,50, 0);
draw(200,50, 60);
draw(50,200, 44);
draw(200,200, 100);