D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
basilesimon
Full window
Github gist
Canvas concentric circles
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { background-color: #F5EFEB; margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } </style> </head> <body> <script> // Feel free to change or delete any of the code you see in this editor! var canvas = d3.select("body").append("canvas") .attr("width", 960) .attr("height", 500); var context = canvas.node().getContext('2d'); var total = 100; var turnout = 68; var x = d3.scaleLinear().range([0,100]).domain([0,100]); context.fillStyle = '#ddd' context.beginPath(); context.arc(100, 100, x(total), 0, 2 * Math.PI, true); context.fill(); context.closePath(); context.fillStyle = '#383838'; context.beginPath(); context.arc(100, 100, x(turnout), 0, 2 * Math.PI, true); context.fill(); context.closePath(); context.strokeStyle = '#383838'; context.lineWidth = 5; context.beginPath(); context.moveTo(100, 100); context.lineTo(250, 100); context.stroke(); context.font = '40pt Times'; context.fillText('68,4%', 250, 100); </script> </script> </body>
https://d3js.org/d3.v4.min.js