Mike
The problem here is that D3 is using string interpolation (because it
doesn't treat rgba() specially, unlike rgb() and #RRGGBB). The way this
works is it finds all numbers in the source/target strings, and then
interpolates matching numbers. However, this results in floating point
numbers, which is fine in most cases, but in this particular case, CSS
requires the red/green/blue components of rgba to be integers, hence
you're seeing black in the interim. I'm not sure why you're seeing it
in the end state - it seems to look okay for me.
One quick workaround would be to use rgb instead, and use fill-opacity
to set the alpha component.
In the meantime we'll probably figure out a way for D3 to handle rgba()
properly: https://github.com/mbostock/d3/issues/582
> The best case would actually if I
> can define both states through css and change the class in the transition
> .transition().attr("class","color2"). Is that possible?
This isn't possible at the moment using D3. It *might* be possible to
do by temporarily setting the target class, fetching the computed style
and then performing the interpolation, but I haven't tried this.
--
Jason Davies, http://www.jasondavies.com/
Another workaround is to use percentages instead, as decimal values are
allowed here i.e. rgba(r%, g%, b%, a).
Ah yes, it looks like SVG only specifies CSS2, but some browsers
(WebKit, at least) appear to have added support for rgba too e.g. see
https://bugs.webkit.org/show_bug.cgi?id=16183 - so support for rgba in
SVG may vary between browsers.