This is a work-in-progress very early stage project/proposal.
Decl3 is a side project trying to create a composable/declarative d3-react bridge.
In most React-D3 wrapper libraries, the flow of graph configs (scale, axis colors...) are either one of those:
- pull-up to container and pass-down multiple times
- provide a wrapper for each kind of charts, which does the passing down.
The problem with the first way is, obviously, duplicity. And for the second one is that you would have to create and maintain a wrapper object for each kind of graph.
Inspired by react-redux interface. We add a makeGlobalSettings(globalProps, ownProps)
static method onto those components that might generate a reusable value. In the D3 container, we simply iterate through children, collecting those reusable values and reapply them to those children to be used in render time.
It's like a React context, but children to children.
- We probably would not be able to recursively do this.
- Key in the config would need to be consistent.
- Do I miss some libraries that has already implemented in this way?
- Is there some potential downside I have not think through?
- Is this scalable to a large chart?
Some draft code follows.