pub struct ContourLabelConfig {
pub visible: bool,
pub font_size: f32,
pub color: Color,
pub format: LabelFormat,
pub significant_digits: u8,
pub spacing_px: f32,
pub anchors: Vec<ContourLabelAnchor>,
pub bg_color: Option<Color>,
pub bg_padding_px: f32,
}Expand description
Inline level labels on contour lines.
Fields§
§visible: bool§font_size: f32§color: ColorText colour, independent of the contour stroke and any per-level ramp colours. Labels are annotations; changing a line palette must not make their typography unreadable.
format: LabelFormat§significant_digits: u8§spacing_px: f32Target minimum screen distance between labels selected by the normal automatic sweep. Must be finite and greater than zero even when labels are hidden or explicit anchors override automatic placement.
Read by the anchor pass, which seeds a lattice at this pitch over the data area, projects each seed onto its level’s isoline, and keeps the ones that stay this far apart. A per-level fallback may keep a closer candidate rather than omit that level. Labels are not arc-length-even: the seed lattice is even, the curve is not. Ignored when the resolved override is non-empty.
anchors: Vec<ContourLabelAnchor>Where the labels go — an override.
Empty is the normal case: the GPU projects a seed lattice onto each
level’s isoline and selects a separated subset. For an explicit list, the
renderer removes anchors whose level_index is outside levels, keeps at
most 1024 in input order, and uses that resolved list as the override. If
resolution leaves it empty, automatic placement remains active. Automatic
and explicit placement share the same 1024-label draw capacity. Either way
the same anchor record reaches the same draw.
bg_color: Option<Color>Fill painted behind the text, so a label over a line stays readable.
None draws the text alone. This is a property of the label, not of the
chart — which is why it can live here at all: the renderer composites the
chrome over the data and does not know what colour is behind it, but the
label knows what it wants behind itself.
bg_padding_px: f32Space around the text. This pads bg_color when one is present and is
also the contour-line gap around a transparent label.