Skip to main content
100%

Circular Segment

✓ Published0🌍 Public
Mmbostock
Last edited Dec 6, 2019
Created on Aug 22, 2012

This example visualizes how the height *h* of a circular segment varies with the fraction *k* of the circle’s area it covers. A slider adjusts *k*, and the segment is drawn clipped within the circle, updating a live label for *h*. The code computes *h* numerically via Newton’s method when *k* is not 0, 0.5, or 1. It uses D3 v3’s selection API (`d3.select`) to update SVG attributes (`attr`), including the clip path and marker arrows, with the circle and lines rendered as SVG elements.

AI-generated description

This example demonstrates how to compute the height h of a circular segment given the fraction k of the circle’s area that should be covered by the segment. For example, for values of k 0, 0.5 and 1, the value of h is k. For other values, h is computed numerically via Newton’s method; I am unaware of an analytical solution to this problem.

gpl-3.0 Licensed

Similar vizzes