Some traits in `BaseXYPlot` don't fire change handlers when passed on init
- Dominant language
- Python
- Stars
- 305
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Description
The way `BaseXYPlot.__init__` is implemented, `index`, `value`, `index_mapper`, and `value_mapper` prevents their traits-events handlers from getting called if these traits are passed on init. Basically, these traits are set in a specific order and, as such, they aren't initialized by the usual mechanisms; see code above this line:
https://github.com/enthought/chaco/blob/master/chaco/base_xy_plot.py#L187
Code demonstrating the problem below:
``` python
from chaco.abstract_plot_renderer import AbstractPlotRenderer
from chaco.array_data_source import ArrayDataSource
from chaco.api import BaseXYPlot
from traits.api import Instance
class PlotRenderer(AbstractPlotRenderer):
index = Instance(ArrayDataSource)
def _index_changed(self):
print ' -- index changed --'
class XYRenderer(BaseXYPlot):
index = Instance(ArrayDataSource)
def _index_changed(self):
print ' -- index changed --'
index = ArrayDataSource()
other = ArrayDataSource()
print 'AbstractPlotRenderer init:'
r1 = PlotRenderer(index=index)
print 'AbstractPlotRenderer update:'
r1.index = other
print
print 'BaseXYPlot init:'
r2 = XYRenderer(index=index)
print ' *** no trait notifications when index passed to __init__ ***'
print 'BaseXYPlot update:'
r2.index = other
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.