-
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
completed
hook/event
#78
Comments
so strange, just came on here to ask about an So I'm also interested in whether such a hook exists, both for layers and for the chart as a whole. |
@samselikoff sounds like fate 😉 I'm also in agreement about having one for the chart as a whole. |
In principle you should be able to accommodate both use cases by simply overriding |
@knuton That's true in principle (so Sam and Ilya aren't stuck today), but if this is a common enough use case, it may make sense for d3.chart to implement it. This would be monumental: the first "native" Chart event! |
I'm in favour of it! |
@knuton so how would I call super in the |
@samselikoff You could do this in a few ways. One would be to gain access to the d3.chart("MyChart", {
initialize: function() {
this._superDraw = this.draw;
this.draw = this.drawAndTell;
},
drawAndTell: function() {
var ret = this._superDraw.apply(this, arguments);
this.trigger('draw');
return ret;
}
}); If possible, please share a demo of what you build with us. Seeing real-world use cases really helps the feature design process. |
@jugglinmike, it should be supported via // ...
draw: function (data) {
this.constructor.__super__.draw.call(this, data);
// do your thing
}
// ... |
@knuton It would, but that attribute is also undocumented, so I don't endorse its usage. |
Would you be open to making it official? It is actually a valuable feature with respect to our project as it allows perfect integration with CoffeeScript's class mechanism. (Sorry for borderline OT, might want to take this to a new issue.) |
Maybe! Inheritance patterns in JavaScript are notoriously thorny, and we mostly passed the buck on this by copping |
Thanks for the clarification! |
@jugglinmike Does what you've said here also apply to In this case, would I need to store the original |
@samselikoff
But I'm not sure this will suit your use case, since you explicitly want to do work after the parent's transform is called. Can you share more details on the data manipulation you're trying to achieve? |
I'm updating the domains of my scales in the |
It sounds like using |
Well the base chart sets the Y scale domain as the extent, so that would override any changes I make in my subclass - correct? |
Ah, I didn't realize that your base chart was setting the same chart attribute. In this case, it sounds like the subclass isn't just extending the parent chart--it's contradicting it. To more clearly reflect this relationship (and to avoid this problem), I would consider re-defining the chart inheritance hierarchy. Currently, I imagine it looks something like this:
...where
...where |
Having a |
The idea is to have a
completed
(or similar) hook or event that runs after all of the elements in a layer have been through themerge
process. Basically this will give you a needed context of performing anything that needs to be done once the layer has finished rendering.My use-case is updating the position of another layer, based on how this layer get's rendered, or even repositioning this layer based on it's size, etc..
At the moment it's possible to
trigger
an event in themerge
hook, but this would be fired for every node, or before the layer has finished rendering. Is this a valid use-case, or am I missing something basic that will allow me to accomplish this?The text was updated successfully, but these errors were encountered: