-
Notifications
You must be signed in to change notification settings - Fork 85
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
pass key function to draw
call
#12
Comments
Hello @iros! When we talked about this on Friday, I suggested implementing That said, the API you've outlined would grant a little more flexibility: users could dynamically change the |
I see your point. I think because we are unsure of how necessary this I wrote one example today on the miso website (forget which of the The use case I'm thinking about has to do with a chart being defined |
I think I understand what you're getting at now. Even though the users of a given chart might want to define a custom |
Yes. Precisely. Hmm. Maybe that should have happened in the transform... So maybe less |
Maybe, but I think this still warrants some further thought. That use case it a lot more compelling than my initial interpretation (the crazy dynamic As implemented,
A chart author needs to control the first responsibility (and consumers aren't interested in changing it), but the opposite is true of the second responsibility. At first glance, it looks like we might be limited by d3's API. |
Well our options are:
My favorite probably is still #2. While we are focusing on drawing, we I can also see #1 working but it's adding another method which would |
If I understand correctly, the only way
I don't understand |
For instance, here is an awful idea that probably won't work: // draw
// Bind the data to the layer, make lifecycle selections, and invoke all
// relevant handlers.
Layer.prototype.draw = function(data) {
var bound, entering, events, selection, handlers, eventName, idx, len;
bound = this.dataBind.call(this.base, data);
+ // If the layer has a custom `key` function, use it to re-bind the data
+ // to the selection.
+ if (this.key) {
+ bound = bound.data(data, this.key);
+ }
if (!(bound instanceof d3.selection)) {
throw new Error('Invalid selection defined by `dataBind` method.');
} |
Here is why the above won't work. The |
Since Of of version 0.2, d3.chart honors all |
I realized that even though we have
transform
, we may still want to allow a user to pass a key function that will be used in the dataBind routine.Given the chart:
For example the following calls:
It would be unfortunate to define a generic
transform
function on the chart that would just rename the propertiesid
orname
. In practice it would be nicer to just call:The text was updated successfully, but these errors were encountered: