-
Notifications
You must be signed in to change notification settings - Fork 190
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
chartBuilder - a component that associates components with the chartLayout #188
Conversation
Is this maybe getting a little high level for what we were trying to achieve with this project? This is not a criticism, the changes make the users life a lot easier and from an architectural point of view is very tidy. The other view is that as the Chart Layout component is essentially a utility and not a D3 component as such, maybe this is a useful change. Thoughts? |
Every time we create a component we pass it the X and Y scales using the xScale and yScale setters. If we used the approach suggested in this PR then we could allow the components to grab the default X and Y scales from the plotArea. Also, I'm not sure the xScale and yScale values should have default values, maybe they should be undefined and log some form of error if not set. |
Perhaps - however, this change only effects chart layout, it doesn't have any impact on how the other components are written, other than the fact that they must adhere to the D3 component pattern. |
As discuss in our meeting, this concept has been split out into a separate component. Here's what it looks like from a user-perspective:
|
chartBuilder - a component that associates components with the chartLayout
Currently resizing the chart, or updating the data, requires quite a lot of structural code:
https://github.com/ScottLogic/d3-financial-components/blob/gh-pages/getting-started.md#rendering-dynamic-charts
My suggestion is to use our chartLayout component to manage the axes, series and any other components that make up a chart.
In order to render a chart, you construct axes, scales, series and add these to the layout. It is then responsible for setting the axis/scale ranges and invoking 'call' on each component.
I like the way that the components still follow the D3 pattern and remain unchanged. Furthermore, it should be possible to wrap up the resize logic so that a chart layout can resize itself automatically.
Here's a chart that supports re-sizing with my changes: