GithubHelp home page GithubHelp logo

Comments (4)

jugglinmike avatar jugglinmike commented on July 20, 2024

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.

fscofield avatar fscofield commented on July 20, 2024

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.

jugglinmike avatar jugglinmike commented on July 20, 2024

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.

fscofield avatar fscofield commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.