Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not expose 'auto' for infinite series #501

Merged
merged 2 commits into from
Dec 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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