When to Use
- Compositional time series: Show how components contribute to a total over time
- Budget allocation: Display spending across categories over months
- Market share: Track relative contributions of competitors
- Resource usage: Visualize CPU/memory/disk usage by process
- Population demographics: Show age group distribution over years
- Any part-to-whole over time: When cumulative total matters
Basic Example
Building a Chart
Step 1: Set x values
with_x() before adding any series. Accepts any numeric type via Into<f64>.
Step 2: Add series
Add each series withwith_series(), then immediately chain with_color() and with_legend() to configure that series.
Step 3: Optional normalization
Enable 100% percent-stacking withwith_normalized().
Key Methods
with_x(x: impl IntoIterator<Item = T>)
Set x-axis values shared by all series. Call before adding series.
with_series(y: impl IntoIterator<Item = T>)
Append a new series. Chain with_color() and with_legend() immediately after.
with_color(color: impl Into<String>)
Set fill color of the most recently added series. Accepts any CSS color string.
steelblue, orange, green, red, purple, brown, pink, gray (cycling for >8 series).
with_legend(label: impl Into<String>)
Set legend label of the most recently added series. Series without a label are not shown in the legend.
with_fill_opacity(opacity: f64)
Set fill opacity applied to every band (default 0.7). Valid range [0.0, 1.0].
with_stroke_width(width: f64)
Set stroke width for the top-edge line on each band (default 1.5).
with_strokes(show: bool)
Show or hide the stroke along the top edge of each band (default true).
with_normalized()
Enable 100% percent-stacking. Each column is normalized so all series sum to 100% at every x value.
with_legend_position(pos: LegendPosition)
Set legend box placement corner (default TopRight).
TopRight, TopLeft, BottomRight, BottomLeft.
Examples
Absolute Stacking
Normalized (100% Stacking)
Custom Styling
Legend
The legend shows all series with defined labels. Position is controlled bywith_legend_position() (default top-right).