Repository: biolab/orange3

Issue:
Visualizations do not work with pyqtgraph 0.11.0 release candidate
**Describe the bug**
After successful installation of orange3, when visualization tools such as scatterplot, line plot, distributions widget are opened, even without connecting them to a dataset, they throw an error of some sort.

**To Reproduce**
Steps to reproduce the behavior:
1. Open orange canvas
2. Right click to add a new widget in the workflow
3. Select scatter plot or distributions or line plot
4. See the error

**Orange version:**
Orange version 3.24.0

**Expected behavior**
Functioning scatter plot when dataset is provided.

**Screenshots**
![image](https://user-images.githubusercontent.com/59823980/72524434-3c6dca00-3862-11ea-91ce-6e8bf3fb8ea3.png)


**Operating system:**
Ubuntu 18.04

**Additional context**
Add any other context about the problem here.



Discussion:
We had some similar error reports. I strongly believe you have pyqtgraph version 0.11.0rc0 installed. As of yet, this version is not supported in Orange.

Until Orange supports 0.11.0, please install version 0.10.0 for new, perhaps with `conda install pyqtgraph=0.10.0`.
Hello! Thank you so much. It really solved my problem.. really appreciate your help. :)
@SamiurRahman1, thanks. I am leaving this open until we have a permanent solution.
The pyqtgraph issue directly connected with this report has been noted in pyqtgraph/pyqtgraph#1094 and solved in its develop branch, but this is not the only problem.  
Another pyqtgraph issue has an open PR pyqtgraph/pyqtgraph#1063.
(Copied from #4468, written by @markotoplak)

Line plot tests fail in pyqtgraph 0.11 pre-release.

At least one of the bugs can be solved upstream (there is a PR in pyqtgraph pyqtgraph/pyqtgraph#1063), but as they are not that keen on accepting PR, we should try to avoid it.

They are some other fails which should be checked.

Resolving patch:
diff --git a/Orange/widgets/visualize/owdistributions.py b/Orange/widgets/visualize/owdistributions.py
--- a/Orange/widgets/visualize/owdistributions.py
+++ b/Orange/widgets/visualize/owdistributions.py
@@ -228,8 +228,8 @@ def __init__(self, orientation, pen=None, linkView=None, parent=None,
                  maxTickLength=-5, showValues=True):
         self.show_unit = False
         self.tick_dict = {}
-        super().__init__(orientation, pen, linkView, parent, maxTickLength,
-                         showValues)
+        super().__init__(orientation, pen=pen, linkView=linkView, parent=parent,
+                         maxTickLength=maxTickLength, showValues=showValues)
 
     def setShowUnit(self, show_unit):
         self.show_unit = show_unit


Test patch:
diff --git a/Orange/widgets/visualize/tests/test_owlineplot.py b/Orange/widgets/visualize/tests/test_owlineplot.py
--- a/Orange/widgets/visualize/tests/test_owlineplot.py
+++ b/Orange/widgets/visualize/tests/test_owlineplot.py
@@ -9,6 +9,7 @@
 
 from AnyQt.QtCore import Qt
 
+from pyqtgraph import PlotCurveItem
 from pyqtgraph.Point import Point
 
 from Orange.data import Table
@@ -137,8 +138,8 @@ def test_saved_selection(self):
     def test_selection_line(self):
         event = Mock()
         event.button.return_value = Qt.LeftButton
-        event.buttonDownPos.return_value = Point(2.5, 5.8)
-        event.pos.return_value = Point(3, 4.7)
+        event.buttonDownPos.return_value = Point(0, 0)
+        event.pos.return_value = Point(1, 1)
         event.isFinish.return_value = True
 
         # drag a line before data is sent
@@ -147,6 +148,12 @@ def test_selection_line(self):
 
         # drag a line after data is sent
         self.send_signal(self.widget.Inputs.data, self.data)
+
+        # set view-dependent click coordinates
+        vb = self.widget.graph.view_box
+        event.buttonDownPos.return_value = vb.mapFromView(Point(2.49, 5.79))
+        event.pos.return_value = vb.mapFromView(Point(2.99, 4.69))
+
         self.widget.graph.view_box.mouseDragEvent(event)
         line = self.widget.graph.view_box.selection_line
         self.assertFalse(line.line().isNull())
@@ -249,7 +256,8 @@ def test_plot_only_mean(self):
         settings["show_range"] = False
         w = self.create_widget(OWLinePlot, stored_settings=settings)
         self.send_signal(w.Inputs.data, self.data, widget=w)
-        self.assertEqual(len(w.graph.items()), 31)
+        curves = [i for i in w.graph.items() if isinstance(i, PlotCurveItem)]
+        self.assertEqual(len(curves), 3)
 
     def test_sparse_data(self):
         table = Table("iris").to_sparse()
diff --git a/Orange/widgets/visualize/tests/test_owscatterplot.py b/Orange/widgets/visualize/tests/test_owscatterplot.py
--- a/Orange/widgets/visualize/tests/test_owscatterplot.py
+++ b/Orange/widgets/visualize/tests/test_owscatterplot.py
@@ -851,7 +851,7 @@ def test_regression_line_coeffs(self):
         line1 = graph.reg_line_items[1]
         self.assertEqual(line1.pos().x(), 0)
         self.assertAlmostEqual(line1.pos().y(), -0.6180339887498949)
-        self.assertEqual(line1.angle, 58.28252558853899)
+        self.assertAlmostEqual(line1.angle, 58.28252558853899)
         self.assertEqual(line1.pen.color().getRgb(), graph.palette[0].getRgb())
 
         line2 = graph.reg_line_items[2]
@@ -868,7 +868,7 @@ def test_orthonormal_line(self):
             np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)
         self.assertEqual(line.pos().x(), 0)
         self.assertAlmostEqual(line.pos().y(), -0.6180339887498949)
-        self.assertEqual(line.angle, 58.28252558853899)
+        self.assertAlmostEqual(line.angle, 58.28252558853899)
         self.assertEqual(line.pen.color(), color)
         self.assertEqual(line.pen.width(), width)