pub struct ChartRenderer<'a> { /* private fields */ }Expand description
Renders charts using a GeometryRenderer, with optional GPU acceleration.
Implementations§
Source§impl<'a> ChartRenderer<'a>
impl<'a> ChartRenderer<'a>
Sourcepub fn new(geometry: &'a mut GeometryRenderer) -> Self
pub fn new(geometry: &'a mut GeometryRenderer) -> Self
Create a new chart renderer wrapping a geometry renderer.
Sourcepub fn with_gpu_line_renderer(
geometry: &'a mut GeometryRenderer,
gpu_line_renderer: &'a mut GpuChartLineRenderer,
) -> Self
pub fn with_gpu_line_renderer( geometry: &'a mut GeometryRenderer, gpu_line_renderer: &'a mut GpuChartLineRenderer, ) -> Self
Create a chart renderer with GPU acceleration for line series.
When GPU acceleration is enabled and a line chart has more than
GPU_RENDER_THRESHOLD points, it will use GPU instancing for
much faster rendering.
Sourcepub fn draw(&mut self, chart: &Chart, bounds: Rect)
pub fn draw(&mut self, chart: &Chart, bounds: Rect)
Render a chart within the given bounds.
This method accumulates geometry commands. Call render() afterwards
to draw everything to a render pass.
For GPU-accelerated line charts, use draw_with_gpu_lines() instead.
Sourcepub fn draw_with_gpu_lines(&mut self, chart: &Chart, bounds: Rect) -> Rect
pub fn draw_with_gpu_lines(&mut self, chart: &Chart, bounds: Rect) -> Rect
Render a chart with GPU-accelerated line series.
This method accumulates non-line geometry commands. Large line series
(>500 points) will NOT be drawn - they should be rendered separately
via GpuChartLineRenderer for much better performance.
Returns the plot area rectangle for use with GPU line rendering.
Sourcepub fn pixel_to_data(
&self,
chart: &Chart,
plot_area: &Rect,
pixel: Vec2,
) -> DataPoint
pub fn pixel_to_data( &self, chart: &Chart, plot_area: &Rect, pixel: Vec2, ) -> DataPoint
Convert pixel coordinates to data coordinates.
Sourcepub fn render(&mut self, pass: &mut RenderPass<'_>, viewport: Viewport)
pub fn render(&mut self, pass: &mut RenderPass<'_>, viewport: Viewport)
Render the accumulated draw commands.
Sourcepub fn render_with_gpu_lines(
&mut self,
pass: &mut RenderPass<'_>,
viewport: Viewport,
chart: &Chart,
plot_area: &Rect,
)
pub fn render_with_gpu_lines( &mut self, pass: &mut RenderPass<'_>, viewport: Viewport, chart: &Chart, plot_area: &Rect, )
Render with GPU-accelerated line series.
Call this after draw_with_gpu_lines(). The GPU line renderer must
have been prepared with GpuChartLineRenderer::prepare() before this call.
§Arguments
pass- The render pass to draw intoviewport- The viewport for renderingchart- The chart being rendered (for data ranges)plot_area- The plot area returned bydraw_with_gpu_lines()
Auto Trait Implementations§
impl<'a> Freeze for ChartRenderer<'a>
impl<'a> !RefUnwindSafe for ChartRenderer<'a>
impl<'a> Send for ChartRenderer<'a>
impl<'a> Sync for ChartRenderer<'a>
impl<'a> Unpin for ChartRenderer<'a>
impl<'a> UnsafeUnpin for ChartRenderer<'a>
impl<'a> !UnwindSafe for ChartRenderer<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more