Comments (4)
Hey @fscofield, thanks for taking the time to write such a detailed report!
How about adding an initialize
method to your original "overlay" chart? You
can then explicitly pass the "overlay" exactly what it needs:
this.mixin("overlay", this.base.append("g"), {
xScale: this.x,
yScale: this.y,
// If these properties are dynamic, you'll want to define getter
// functions and bind them to the chart
width: this.w - this.margins.left,
height: this.h - this.margins.bottom
});
If you want to go brute force, you could just initialize the overlay chart with
a reference to the parent chart:
this.mixin("overlay", this.base.append("g"), { parent: this });
This second approach is functionally equivalent to the solution that you've
suggested. I have been hesitant to facilitate this at an API level because I
think it will encourage people to create less-reusable charts. When authoring a
chart, you want the requirements to be as obvious as possible so that if anyone
else wants to use it, they have a clear contract to fulfill.
Will this work for your use case?
from d3.chart.
Mike,
Your solution works great, although as you point out it allows for the creation of graphs that rely on a parent. This works fine for what we're working on however.
Thanks!
from d3.chart.
I'm glad that will work for you, Forrest!
Regarding the issue of dependency on the parent: Unless I'm mistaken, doesn't your proposal also produce graphs that rely on their parent? It seems like this is actually a requirement of the use case. Don't mean to beat a dead horse, but I want to make sure I understand your proposal before I forget about all this :)
from d3.chart.
Yep it does, even though it sort of goes against the mantra of creating fully reusable charts. After reading your suggestion I don't think there's any need to change d3.chart's functionality.
I've been implementing d3.charts for a few weeks now -- I've been really impressed at it's simplicity so far. Thanks to you and Irene for all the hard work!
from d3.chart.
Related Issues (20)
- Set 'new' chart width based on y-axis width
- Is there a hook to redraw the chart on window resize? HOT 5
- Release notes for version 0.2 HOT 4
- Question - Has anyone integrated this with Angular yet? HOT 1
- Is d3.chart still being developed/maintained/used? HOT 7
- Not deleted when data is updated. HOT 1
- to attach or to extend? HOT 1
- d3 dependency difference HOT 1
- Spam entry in http://misoproject.com/d3-chart/charts.html HOT 3
- compatibility with d3.js version 4? HOT 7
- How to properly enter/update/exit new data HOT 5
- Wrong link on the Api Wiki page
- misoproject.com suggests visitors "Buy this domain"
- d3.chart + requirejs HOT 8
- Idiomatic way to add x-axis, y-axis and tooltips HOT 5
- Assert that an added layer has .insert function
- Detect when a layer has been inserted HOT 4
- Where can I "short-circuit" the draw process? HOT 2
- `beforeDraw` hook HOT 7
- Uniform access HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3.chart.