A gauge in D3.js
This D3.js v5 example renders an SVG gauge to visualize a battery’s state of charge, showing a value of 80 percent as a red percentage text in the center. The gauge consists of three arc segments with distinct gradients: a left arc with a green-to-red vertical gradient indicating full-to-empty battery status, and two right arcs using horizontal gradients to delineate minimum and recommended charge levels. The code uses `d3.arc` to generate the arc paths, computes coordinates from degrees, and applies CSS-defined gradients via SVG `<defs>` elements with classes like `stop-battery-full` and `stop-left`. The visualization is constructed procedurally in `index.js` using D3’s selection and attribute methods on an SVG canvas.