Skip to content

LineVisualCallbacks

Inherits: VisualCallbacks
Namespace: TauPlot

Callback-driven per-sample style overrides for LINE overlays.

Description

LineVisualCallbacks is the LINE specific subclass of VisualCallbacks. It carries the two callbacks inherited from that base class, color_callback and alpha_callback, and adds no overlay-specific callbacks of its own.

Assign an instance to TauLineConfig.line_visual_callbacks. Any other subclass on a line overlay is a validation error and TauPlot.plot_xy() aborts. The plot invokes each valid callback once per sample on each draw pass and applies the returned values on top of the per-series color and alpha resolved from TauXYStyle.

Each callback is optional. An invalid Callable means no override for that property, and the resolved style value applies to every sample of the series. Each callback receives the dataset series index, the logical sample index, and the X and Y values of the sample, as described in VisualCallbacks.

Both callbacks override the stroke of the curve. The area painted around it takes its color from TauLineFill and is left untouched.

See TauPaneOverlayConfig for the order a callback resolves in against a LineVisualAttributes buffer and the style property.

Example

# Color the curve by threshold: samples over the limit read as an alert.
var callbacks := TauPlot.LineVisualCallbacks.new()
callbacks.color_callback = func(series_index: int, sample_index: int, x_value: Variant, y_value: float) -> Color:
    return Color.CRIMSON if y_value > 100.0 else Color.STEEL_BLUE

var line_overlay := TauLineConfig.new()
line_overlay.line_visual_callbacks = callbacks

Notes

  1. A returned color colors a sample, not a segment. Each sample carries its returned color into the curve, and the segment between two samples fades from the color of one to the color of the other. A threshold crossing therefore reads as a fade across the segment rather than as a sharp break at the crossing point, whatever the interpolation mode.

  2. y_value is the value stored in the dataset. In STACKED mode the curve is drawn at the running total, and the callback still receives the value the Dataset holds, never the running total and never the normalized value.

Constructor

new()

LineVisualCallbacks.new() -> LineVisualCallbacks

Creates a new LineVisualCallbacks instance with all callbacks set to an invalid Callable.