PlotStyle

Struct PlotStyle 

Source
#[non_exhaustive]
pub struct PlotStyle { /* private fields */ }
Expand description

Styling options for the plot

Implementations§

Source§

impl PlotStyle

Source

pub fn with_drawing_area(self, drawing_area: impl Into<(u32, u32)>) -> Self

Set the pixel dimensions of the plot (width, height). Default is 1920x1200.

Source

pub fn with_title(self, title: impl Into<String>) -> Self

Override the title of the plot. By default, the title is derived from the metric name and common labels.

Source

pub fn with_utc_offset(self, offset: FixedOffset) -> Self

Set the timezone offset for timestamp labels. Default is UTC. Supports fractional-hour timezones like UTC+5:30.

Source

pub fn with_line_width(self, width: u32) -> Self

Set the stroke width for data lines in pixels. Default is 1.

Source

pub fn with_skip_labels(self, labels: Vec<String>) -> Self

Set label names to exclude from the legend (e.g., “job”, “instance”).

Source

pub fn with_background(self, color: impl Into<RGBAColor>) -> Self

Set the background color of the plot. Default is white.

Source

pub fn with_grid_color(self, color: impl Into<RGBAColor>) -> Self

Set the color of the grid lines. Default is semi-transparent gray.

Source

pub fn with_axis_color(self, color: impl Into<RGBAColor>) -> Self

Set the color of the axis lines. Default is black.

Source

pub fn with_text_color(self, color: impl Into<RGBAColor>) -> Self

Set the color of axis labels and legend text. Default is black.

Source

pub fn with_text_font(self, font: impl Into<String>) -> Self

Set the font family for text. Default is “sans-serif”.

Source

pub fn with_text_size(self, size: u32) -> Self

Set the font size for axis labels and legend in pixels. Default is 18.

Source

pub fn with_caption_size(self, size: u32) -> Self

Set the font size for the plot title/caption in pixels. Default is 36.

Source

pub fn with_data_colors(self, colors: Vec<RGBAColor>) -> Self

Set the colors to cycle through for data lines. If there are more series than colors, colors will repeat.

Source

pub fn with_threshold_color(self, color: impl Into<RGBAColor>) -> Self

Set the color used to shade the threshold region in alert plots. Default is semi-transparent red.

Source§

impl PlotStyle

Source

pub fn dark_mode(self) -> Self

Switch to a dark color scheme: black background with white text and axes.

Source

pub fn plot_timeseries<KV, K, V>( &self, path: impl AsRef<Path>, mts: &[MetricTimeseries<KV>], plot_threshold: Option<PlotThreshold>, ) -> Result<(), Box<dyn Error + Send + Sync>>
where KV: Clone + Debug, K: Display, V: Display, for<'a> &'a KV: IntoIterator<Item = (&'a K, &'a V)>,

Plot a collection of metric timeseries data from prometheus, and possibly a “threshold” defined in an alert. Write the result to a path. The file extension of the path will determine the format, e.g. png, gif, etc.

Trait Implementations§

Source§

impl Default for PlotStyle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more