Code Monkey home page Code Monkey logo

Comments (7)

brendon9x avatar brendon9x commented on August 29, 2024

I've also run into this attempting to integrate DagreD3 into an iPython notebook. D3 no longer exports the d3 global in the presence of an APM framework (d3/d3#1693). iPython manages dependencies through requirejs so this is a problem. It is meant to be possible to solve the problem using an approach similar to @pats, except you don't need to shim D3.

So I expected to be able to do this:

require.config({
    paths: {
        'd3': 'd3.min',
        'dagre-d3': 'dagre-d3'
    },
    shim: {
        'dagre-d3': {
            deps: ["d3"],
            exports: 'dagreD3'
        }
   }
});

// then use require or define

Unfortunately this doesn't work. I am a bit a noob regarding the bower stuff and I have managed to work around this with a fairly ugly hack, but is there any recommended way you would solve this problem?

Regards,
Brendon

from dagre-d3.

cpettitt avatar cpettitt commented on August 29, 2024

I don't have any experience with bower, but I'm open to someone contributing the required changes to enable it. It looks like someone did some work to enable bower with dagre here: https://github.com/passelin/dagre. Maybe it can be used as a starting point for dagre-d3?

from dagre-d3.

brendon9x avatar brendon9x commented on August 29, 2024

Chris, thanks for responding. I don't really know what I'm talking about with Bower as I've never used it. If I get some headspace, I'll try and dig into what you're doing, what Bower is, and how to solve this issue.

from dagre-d3.

andrvb avatar andrvb commented on August 29, 2024

I think it's the issue CommonJS vs. AMD (browserify vs. requrejs). Check this build of dagre-d3 https://github.com/andrvb/dagre-d3-umd.

from dagre-d3.

brendon9x avatar brendon9x commented on August 29, 2024

@andrvb Thanks so much! Completely solved the problem.

from dagre-d3.

cpettitt avatar cpettitt commented on August 29, 2024

@andrvb - thanks for doing this. Is this something that we can fold back into the dagre-d3 build?

from dagre-d3.

ixtli avatar ixtli commented on August 29, 2024

I think it is. You just have to do a bit of boilerplate that detects whether you're bring loaded in a place that already exposes a requirejs install. If so, just require('d3') which should allow maximum flexibility in allowing the embedder to specify what 'd3' means to them (that is an absolute url to a cdn, or to a local version.)

Edit: That boilerplate is here: https://github.com/andrvb/dagre-d3-umd/blob/master/dagre-d3.js#L2

from dagre-d3.

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.