Hi,
I've been playing with d3 for about a week now, and it certainly makes my life easier. I'm doing both textual and visual data rendering. My data is quite volatile, with different parts of complex datasets updating asynchronously.
One thing I've stumbled over several times is data were I have an array of values with a custom key function and some of this data is being updated periodically by a json call. Sometimes this fits the d3 paradigm of new data being added or old data being removed, but sometimes data is updated, as distinct from just persisting. That is, it maintains the same key but the values change.
So far, with d3's join model, I can't find a way to distinguish between existing keys with unchanged values and existing keys with new values. This has lead me to some fairly ugly hacks to apply styling to the updated values only.
Is there some way to achieve this within d3? If not, and I'm probably overstepping here, the obvious extension to me would be to
a: add isUpdateValue as an additional optional argument to data e.g.
selection.data(theValues, keyFunction, isUpdatedValue)
For any value were there's an old data value with an existing key, the old value and the new value would be passed to isUpdateValue. This would return 'true' if this represents an update, 'false' if it is the same old data.
b: add a .update() selector
This could be used after .enter() and would contain exactly those elements were isUpdatedValue was called and returned true.
With this, we could do things like:
.update().selectAll(".value")
.style("color", "red").transition(1000).style("color", "black");
This would only apply to the updated values, not to all pre-existing values.
Sorry to come barrelling in blind and making big feature requests. Perhaps this functionality is already covered and I've just not stumbled over it yet.
Thanks,
Matthew