Dear Chris Henn,
I loved your talk at EmberConf this year. Thanks so much for sharing that with us!
I had recently spiked on replacing our graphing library with some components and happened upon a very similar solution to what you described. What I didn't know is that there was an existing grammar for these concepts. I knew a few terms like axes and series, so those became nouns (or components) in my world. My template looks like this:
viz-chart yields a ChartDimensions object and the axes and series register themselves with it. This is as opposed to you giving the whole dataset to your equivalent of viz-chart and having the various series slice it up.
One reason I chose this approach is that when the user toggles the visibility of a series, that series will deregister itself from the ChartDimensions, which can then adjust the scaling functions.
What do you think of this approach? As I watched your talk, I felt my version didn't align to the existing visualizations grammar, which worries me a little.
Thanks! I'm glad you enjoyed the talk.
I certainly don't want to make what I presented seem like the one way of graphic composition—there are many different good solutions. I think what you've got here is an interesting approach. I definitely like the idea of limiting the scope that the parent component yields to it's children.
Without knowing more about the
ChartDimensionsobject though, I'm not sure I entirely understand it's role. Could you talk a little more about what that looks like? It sounds like you may be using as a way of passing around mutable state to child components. In general, allowing child components to mutate data supplied to them can lead to some confusing code. Instead, I usually prefer to have child components send actions to the parent component when they need to mutate state belonging to the parent. If you have heard the phrase “data down, actions up” recently, this is exactly what it refers to.That may not be the right way of looking at this, depending on how you are using the
ChartDimensionsobject. If that's where axes and series are registered, what state left belongs to theviz-chartcomponent? Right now it looks like you have a line layer each fordroppedRequestsand forcacheHits. Does aviz-chartalways have these two particular layers, or is the number of layers more variable (could there be additional datasets plotted on top)?