PieChart and PieSeries classes. All three Anvil2 themes apply design-token-based colors and chart styling automatically.
For design guidelines on donut chart spacing, direct labeling, and variable ordering, see Donut Charts design guidelines.
Basic donut chart
A donut chart is aPieChart with an innerRadius set. The theme styles slice labels with a white semi-transparent background and pointer cursors, while this example configures the label text to show percentages inside each slice.
Adding a legend
Add a legend to display category names alongside the chart. Set the chart layout tohorizontalLayout and position the legend vertically beside the donut.
Hover behavior
The theme registerspointerover and pointerout event handlers on all Slice elements. When a user hovers over a slice, all sibling slices dim to 20% opacity. This behavior applies to every pie and donut chart using the theme and cannot be disabled without overriding the theme rules.
Pie chart (without inner radius)
The design guidelines recommend donut charts over pie charts for dashboard layouts. Donut charts provide a cleaner layout and allow central labeling of key metrics. Use a pie chart only when the open center is not needed. To create a standard pie chart instead of a donut, omit theinnerRadius property:
Using different themes
Change the theme import to apply a different color palette. The chart structure stays the same.Monochrome theme
UseThemeMonochrome for data with a natural order or progression, or when displaying 4 or fewer variables. This is the default theme used in the examples above.
Categorical theme
UseThemeCategorical when displaying 5 or more distinct categories that need maximum color differentiation.
Semantic theme
UseThemeSemantic when data represents status values. Colors follow the order: Success, Neutral, Warning, Danger.