-
Notifications
You must be signed in to change notification settings - Fork 87
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
Passing a chart in the options of a mixin #66
Comments
this.xAxis = this.mixin('xAxis', this.base.select('g').append('g'), {
parent: this
}); If your desire to share the same method namespace is a hard requirement, d3.chart('xAxis').extend('ChartThatHasAnXAxis', {
// etc.
}); This relationship is kind of the inverse of what you described. I assume you Will either of those approaches work for you? |
Hmm I'm getting a little confused...
|
|
Right, I think I understand. So my question was more about conventions. If I asked for the parent chart in the constructor, it's more along the lines of interfaces - something like, "My xAxis component will work with any chart that exposes width and height methods". Alternatively, I could simply ask for both the width and height in the constructor. The former seems easier for reuse for consumers of the component, but it doesn't really matter to me. More a question of best practices/what you all have been doing at Bocoup. |
@jugglinmike I have another question about this. Say I have a bar chart with a What's the best way to accomplish this? |
I could get the height from the |
@jugglinmike this popped up again. This time I have a 'Legend' component that updates the Have you encountered situations like this? How could I accomplish this without passing a reference to the parent chart into my |
I was experimenting with passing a chart to its mixin, like so:
Then, in the xAxis chart (really, more of a component) I could access the main chart's scale and height. The idea would be to build the xAxis component to work as a mixin with any chart that implements a scale and height method.
Do you have any comments on this approach? Would you prefer some other approach, like passing in the height and scale directly? If so, why?
Thanks!
The text was updated successfully, but these errors were encountered: