#[non_exhaustive]pub struct PlotStyle { /* private fields */ }Expand description
Styling options for the plot
Implementations§
Source§impl PlotStyle
impl PlotStyle
Sourcepub fn with_drawing_area(self, drawing_area: impl Into<(u32, u32)>) -> Self
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.
Sourcepub fn with_title(self, title: impl Into<String>) -> Self
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.
Sourcepub fn with_utc_offset(self, offset: FixedOffset) -> Self
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.
Sourcepub fn with_line_width(self, width: u32) -> Self
pub fn with_line_width(self, width: u32) -> Self
Set the stroke width for data lines in pixels. Default is 1.
Sourcepub fn with_skip_labels(self, labels: Vec<String>) -> Self
pub fn with_skip_labels(self, labels: Vec<String>) -> Self
Set label names to exclude from the legend (e.g., “job”, “instance”).
Sourcepub fn with_background(self, color: impl Into<RGBAColor>) -> Self
pub fn with_background(self, color: impl Into<RGBAColor>) -> Self
Set the background color of the plot. Default is white.
Sourcepub fn with_grid_color(self, color: impl Into<RGBAColor>) -> Self
pub fn with_grid_color(self, color: impl Into<RGBAColor>) -> Self
Set the color of the grid lines. Default is semi-transparent gray.
Sourcepub fn with_axis_color(self, color: impl Into<RGBAColor>) -> Self
pub fn with_axis_color(self, color: impl Into<RGBAColor>) -> Self
Set the color of the axis lines. Default is black.
Sourcepub fn with_text_color(self, color: impl Into<RGBAColor>) -> Self
pub fn with_text_color(self, color: impl Into<RGBAColor>) -> Self
Set the color of axis labels and legend text. Default is black.
Sourcepub fn with_text_font(self, font: impl Into<String>) -> Self
pub fn with_text_font(self, font: impl Into<String>) -> Self
Set the font family for text. Default is “sans-serif”.
Sourcepub fn with_text_size(self, size: u32) -> Self
pub fn with_text_size(self, size: u32) -> Self
Set the font size for axis labels and legend in pixels. Default is 18.
Sourcepub fn with_caption_size(self, size: u32) -> Self
pub fn with_caption_size(self, size: u32) -> Self
Set the font size for the plot title/caption in pixels. Default is 36.
Sourcepub fn with_data_colors(self, colors: Vec<RGBAColor>) -> Self
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.
Sourcepub fn with_threshold_color(self, color: impl Into<RGBAColor>) -> Self
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
impl PlotStyle
Sourcepub fn dark_mode(self) -> Self
pub fn dark_mode(self) -> Self
Switch to a dark color scheme: black background with white text and axes.
Sourcepub fn plot_timeseries<KV, K, V>(
&self,
path: impl AsRef<Path>,
mts: &[MetricTimeseries<KV>],
plot_threshold: Option<PlotThreshold>,
) -> Result<(), Box<dyn Error + Send + Sync>>
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>>
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.