From fae3e11e8b5e3b423c0b062710a65ac1841780df Mon Sep 17 00:00:00 2001 From: mmavka Date: Tue, 14 Apr 2026 23:13:11 +0200 Subject: [PATCH] feat: add public plot_area_bounds() getter Returns Option with the current pixel rectangle of the plot area (excluding axes, labels, legend). Reads from the widget's cached camera_bounds state, which is kept in sync on every pan/zoom/resize via the internal RenderUpdate flow. Useful for applications that need the plot area's pixel dimensions to make pixel-aware decisions (e.g. choosing an LOD level when requesting downsampled data from a streaming source, or laying out overlay UI relative to the plot area). --- src/plot_widget.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/plot_widget.rs b/src/plot_widget.rs index 3305e50..0d308e5 100644 --- a/src/plot_widget.rs +++ b/src/plot_widget.rs @@ -281,6 +281,16 @@ impl PlotWidget { self.y_lim = Some((min, max)); } + /// Pixel rectangle of the plot area (excluding axes, labels, legend). + /// + /// Returns `None` before the first frame has been rendered. Useful for + /// pixel-aware downsampling requests against a streaming data source + /// when only the pixel dimensions are needed. + #[must_use] + pub fn plot_area_bounds(&self) -> Option { + self.camera_bounds.as_ref().map(|(_, r)| *r) + } + /// Set the y-axis scale mode. /// /// This does not modify tick producer/formatter settings.