From 70724a44b37a79c072a03963749464dc97331dda Mon Sep 17 00:00:00 2001 From: JosefNevrly Date: Sun, 16 Mar 2014 15:13:43 +0100 Subject: [PATCH] Added check for zero ViewBox width when calculating automatic downsampling ratio. (Prevents zero-division when downsampling is set before Plot is properly created and drawn within a container). --- pyqtgraph/graphicsItems/PlotDataItem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index d2d18fd9..14a39dba 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -532,7 +532,8 @@ class PlotDataItem(GraphicsObject): x0 = (range.left()-x[0]) / dx x1 = (range.right()-x[0]) / dx width = self.getViewBox().width() - ds = int(max(1, int(0.2 * (x1-x0) / width))) + if width != 0.0: + ds = int(max(1, int(0.2 * (x1-x0) / width))) ## downsampling is expensive; delay until after clipping. if self.opts['clipToView']: