Styling

Keep plot appearance separate from data and application state.

Styles and local overrides

For Cartesian charts, CartesianStyle contains axes, layer defaults, grid, legend, metrics, empty-state presentation, and series overrides. Pass a static value or a CartesianStyleProvider to .style(...).

Rust
use gpui::{px, rgb};
use xgpui_luma_plot::{
    AxisPresentation, CartesianChartBuilder, CartesianChartView, Dataset,
    GridPresentation, LineLayer, LinePresentation, CartesianStyle,
};

fn styled_chart(data: Dataset) -> CartesianChartView {
    let style = CartesianStyle::new(
        AxisPresentation::new(rgb(0x64748b).into()),
        LinePresentation::new(rgb(0x2563eb).into()),
    );
    CartesianChartBuilder::new(data)
        .id("styled-chart")
        .line(LineLayer::new("temperature"))
        .style(style)
        .style_override(|style| {
            style.line.stroke.width = px(3.0);
            style.grid = GridPresentation::new(rgb(0xe2e8f0).into());
        })
        .build()
}

Supply a dataset containing the temperature series. The explicit colors above are a static example, not a theme-aware palette.

Providers resolve on each render, then local overrides run in call order. Call .style(...) first: it replaces the previous style source and its overrides. A per-series .line_style(...) replaces that series’ line presentation, including its width; it does not merely recolor the global line.

PlotStyle and PlotStyleProvider remain compatibility names for CartesianStyle and CartesianStyleProvider. Prefer the family-specific names in new code; existing implementations and callers continue to work.

Theme changes

Implement CartesianStyleProvider::resolve, or pass a Send + Sync + 'static closure returning CartesianStyle, to read current theme state each render. Resolve palette colors and chart metrics there; apply chart-specific adjustments with .style_override(...).

Request an owner redraw when the theme changes. A provider alone does not schedule redraws. Style resolution and override callbacks should only compute appearance, without mutating application state.

Look integration

The plot crate is Look-independent. Shadcn and Radix do not currently export dedicated chart builders or plot style adapters. Built-in plot defaults are static and do not automatically follow an application Look.

The luma-plot-viz gallery is a native SDK application with no Radix or Shadcn dependency. Its application-local SdkCartesianStyle provider resolves SDK tokens for axes, labels, grids, and spacing, while named HSLA chart palettes supply series colors independently of the monochrome UI. Both the provider and retained SDK control themes read shared light/dark mode state; switching modes redraws the app without recreating controls. These application-local helpers are reference implementations, not exported plot APIs.

Other chart families

PieChartBuilder uses PiePresentation / PieStyleProvider and supports local style overrides. Radar and radial builders accept style closures returning RadarPresentation and RadialPresentation. These are family-specific contracts; do not pass CartesianStyle to them.

Source

Cartesian style contract · App-local SDK style example · Independent HSLA chart palettes · Presentation exports