diff --git a/chaco/plot.py b/chaco/plot.py index 5b17199f1..cb4a690b6 100644 --- a/chaco/plot.py +++ b/chaco/plot.py @@ -1276,7 +1276,7 @@ def _handle_range_changed(self, name, old, new): if new is not None: new.add(datasource) range_name = name + "_range" - for renderer in itertools.chain(six.itervalues(self.plots)): + for renderer in itertools.chain(*six.itervalues(self.plots)): if hasattr(renderer, range_name): setattr(renderer, range_name, new) diff --git a/chaco/tests/plot_test_case.py b/chaco/tests/plot_test_case.py index 3234dcf20..ceb4207a0 100644 --- a/chaco/tests/plot_test_case.py +++ b/chaco/tests/plot_test_case.py @@ -3,7 +3,7 @@ from numpy import arange # Chaco imports -from chaco.api import ArrayPlotData, Plot +from chaco.api import ArrayPlotData, Plot, DataRange1D class PlotTestCase(unittest.TestCase): @@ -18,5 +18,18 @@ def test_plot_from_unsupported_array_shape(self): data.update_data(x=arr, y=arr) self.assertRaises(ValueError, plot.plot, ("x", "y")) + def test_range_change(self): + arr = arange(10) + data = ArrayPlotData(x=arr, y=arr) + plot = Plot(data) + renderer = plot.plot(('x', 'y'))[0] + new_range = DataRange1D() + old_range = plot.index_range + self.assertIsNot(old_range, new_range) + self.assertIs(renderer.index_range, old_range) + plot.index_range = new_range + self.assertIs(plot.index_range, new_range) + self.assertIs(renderer.index_range, new_range) + if __name__ == "__main__": unittest.main()