Skip to content

Commit

Permalink
Merge pull request #501 from enthought/fix/functionplotter.py
Browse files Browse the repository at this point in the history
Do not expose 'auto' for infinite series in functionplotter.py demo
  • Loading branch information
midhun-pm authored Dec 31, 2019
2 parents bc40b07 + 3b91e3f commit f3cefa6
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions examples/demo/functionplotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
),
),
Expand All @@ -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()

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f3cefa6

Please sign in to comment.