Repository: enthought/chaco

Issue:
Demo functionplotter.py range editor error
**Problem Description**
functionplotter.py break when `auto` is chosen from enum editor.
**Reproduction Steps:**
Run the file and change the enum to `auto`.
**Expected behavior:**
Plot disappear and raise the error
```
functionplotter.py:47: RuntimeWarning: invalid value encountered in double_scalars
  real_high = ceil(high/dx) * dx
/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:124: RuntimeWarning: invalid value encountered in greater_equal
  return ((data.view(ndarray) >= self._low_value) &
/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:125: RuntimeWarning: invalid value encountered in less_equal
  (data.view(ndarray) <= self._high_value))
functionplotter.py:46: RuntimeWarning: invalid value encountered in double_scalars
  real_low = ceil(low/dx) * dx
functionplotter.py:52: RuntimeWarning: divide by zero encountered in divide
  return sin(1.0/x)
functionplotter.py:52: RuntimeWarning: invalid value encountered in sin
  return sin(1.0/x)
/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:148: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if low == 'track':
/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:232: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._low_setting != val:
/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:239: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if val == 'auto':
/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:245: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  elif val == 'track':
/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:285: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._high_setting != val:
/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:292: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if val == 'auto':
/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:298: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  elif val == 'track':
```

**OS, Python version:** 
OSX, Python 2.7

splits from #385 


Discussion:

Resolving patch:
diff --git a/examples/demo/functionplotter.py b/examples/demo/functionplotter.py
--- a/examples/demo/functionplotter.py
+++ b/examples/demo/functionplotter.py
@@ -9,8 +9,8 @@
 
 # Enthought library imports
 from enable.api import Component, ComponentEditor
-from traits.api import HasTraits, Instance, Int
-from traitsui.api import Item, Group, HGroup, View
+from traits.api import HasTraits, Instance, Int, Enum
+from traitsui.api import Item, Group, HGroup, View, TextEditor
 
 # Chaco imports
 from chaco.api import ScatterPlot, DataView, LinePlot
@@ -22,18 +22,35 @@ class PlotExample(HasTraits):
     plot = Instance(Component)
     numpoints = Int(500)
 
+    low_mode = Enum("value", "track")
+    high_mode = Enum("value", "track")
+
+
     traits_view = View(
         Group(
             Item('plot', editor=ComponentEditor(), show_label=False),
             HGroup(
                 HGroup(
-                    Item('object.plot.x_mapper.range.low_setting', label='Low'),
-                    Item('object.plot.x_mapper.range.high_setting', label='High'),
+                    Item('object.plot.x_mapper.range.low_setting', label='Low',
+                         editor=TextEditor(),
+                         visible_when='object.low_mode == "value" ', ),
+                    Item('low_mode', label='Low Mode'),
+                    Item('object.plot.x_mapper.range.high_setting',
+                         label='High', editor=TextEditor(),
+                         visible_when='object.high_mode == "value" '),
+                    Item('high_mode', label='High Mode'),
+                    Item('object.plot.x_mapper.range.tracking_amount',
+                         label='Tracking Amount',
+                         editor=TextEditor(read_only=True),
+                         visible_when='object.high_mode == "track" or '
+                                      'object.low_mode == "track"'),
                     label='X', show_border=True
                 ),
                 HGroup(
-                    Item('object.plot.y_mapper.range.low_setting', label='Low'),
-                    Item('object.plot.y_mapper.range.high_setting', label='High'),
+                    Item('object.plot.y_mapper.range.low_setting',
+                         label='Low', editor=TextEditor()),
+                    Item('object.plot.y_mapper.range.high_setting',
+                         label='High', editor=TextEditor()),
                     label='Y', show_border=True
                 ),
             ),
@@ -51,6 +68,14 @@ def yfunc(self, low, high):
         x = self.xfunc(low, high)
         return sin(1.0/x)
 
+    def _low_mode_changed(self, newvalue):
+        if newvalue != "value":
+            self.plot.x_mapper.range.low_setting = newvalue
+
+    def _high_mode_changed(self, newvalue):
+        if newvalue != "value":
+            self.plot.x_mapper.range.high_setting = newvalue
+
     def _plot_default(self):
         container = DataView()
 
@@ -78,7 +103,8 @@ def _plot_default(self):
                         color = "lightgray")
 
         container.add(plot2, plot)
-        plot.tools.append(PanTool(plot, constrain_direction="x", constrain=True))
+        plot.tools.append(PanTool(plot, constrain_direction="x",
+                                  constrain=True))
         plot.tools.append(ZoomTool(plot, axis="index", tool_mode="range"))
 
         return container


Test patch: