pub struct ChartPainter { /* private fields */ }Expand description
Draws what is around a chart’s series: gridlines at the ticks, the axis edges and the
tick labels, right of the plot for y and under it for x, and a crosshair over it.
Owns the label font’s character map; glyphs come from the canvas’s shared cache.
Painting allocates nothing once the label characters are cached (see
prewarm).
Implementations§
Source§impl ChartPainter
impl ChartPainter
Sourcepub fn new(font: Font, px: f32, palette: ChartPalette) -> Self
pub fn new(font: Font, px: f32, palette: ChartPalette) -> Self
A painter writing labels in font at px pixels per em, with room for y labels
of 8 characters.
Sourcepub fn with_label_chars(self, chars: u16) -> Self
pub fn with_label_chars(self, chars: u16) -> Self
The painter with room for y labels of chars characters.
Sourcepub fn palette(&self) -> &ChartPalette
pub fn palette(&self) -> &ChartPalette
The colors this painter draws with.
Sourcepub fn set_palette(&mut self, palette: ChartPalette)
pub fn set_palette(&mut self, palette: ChartPalette)
Draws with palette from now on.
Sourcepub fn prewarm(&mut self, cache: &mut GlyphCache) -> usize
pub fn prewarm(&mut self, cache: &mut GlyphCache) -> usize
Rasterizes every character a label can use into cache at every subpixel position
now, so frames never rasterize (or allocate) for labels. Returns how many glyphs could
not be cached.
Sourcepub fn plot_area(&mut self, bounds: Rect, x_labels: bool) -> Rect
pub fn plot_area(&mut self, bounds: Rect, x_labels: bool) -> Rect
The area of bounds left for the plot once the y labels (right) and, if
x_labels, the x labels (below) have their room; edges on whole pixels. Charts
stacked on one time axis label x under the lowest only.
Sourcepub fn paint_axes(
&mut self,
canvas: &mut Canvas<'_>,
plot: &Plot,
x_labels: bool,
)
pub fn paint_axes( &mut self, canvas: &mut Canvas<'_>, plot: &Plot, x_labels: bool, )
Draws the gridlines, the axis edges and the y labels of plot, and its x labels
if x_labels. Call it before the series so they draw over the grid.
Sourcepub fn paint_crosshair(
&mut self,
canvas: &mut Canvas<'_>,
plot: &Plot,
at: Point,
x_label: bool,
)
pub fn paint_crosshair( &mut self, canvas: &mut Canvas<'_>, plot: &Plot, at: Point, x_label: bool, )
Draws a crosshair at at over plot: a line down the plot through at, and, if
at is within the plot, a line across it with the y there in a box right of the
plot; with x_label, the x there in a box under the plot. The values are written
finer than the tick labels. For stacked plots, give each one the same at and label
x under the lowest.