Chapter 06 · Java + TeaVM

Arc commands become readable proportions.

Non-negative slices are normalized into arc wedges with percentage labels, separators, and a legend. Path2D translates center-parameterized arcs for SVG.

Starting the TeaVM application…

How it works

The reusable Path2D arc command maps directly to Canvas arc() and to SVG elliptical arc commands. Full circles and clockwise or counterclockwise direction are supported.

PieChart chart = new PieChart("Library code", List.of(
    new PieChart.Slice("Drawing", 38, "#61d6c5"),
    new PieChart.Slice("Charts", 27, "#ffcb6b")));
chart.render(graphics);