I'm having a lot of trouble trying to initialize a mapped trait. Specifically a ColorTrait. I'm working on a modification to chaco.scatterplot, I'd like to be able to assign arbitrary colors to the marker and it's outline. In this case, the color is not given by a mapper but rather by an array of colors, similar to the variable marker size. Frustratingly, I think the biggest hurdle is related to the setting a default value for the fill and outline colors.
# The fill color of the marker. color = Either(ColorTrait, Array)
def _render(self, gc, points, icon_mode=False): ... # To force computing the default value c=self.color
def _color_default(self): return 'black'
Realizing that the default values are set in a lazy fashion, I decided to get self.color in an effort to debug my problem. What I've found is that although self.color will be set to 'black', self.color_ is None. It appears that Traits is not using the default value to initialize the shadow value. To work around this, I've done something like:
Which seems sort of like a hack. Can anybody explain how I can correctly initialize the shadow value?
Something else that I realize will likely be a sticking point: Is it possible to have an array of mapped traits? I don't think it makes sense because I can't see how the shadow value could be accessed, but I thought I would ask.