4 Replies Latest reply: Oct 13, 2016 2:45 PM by Alexander Karlsson RSS

    Extension with d3 dependency

    Tom Roth

      I'm making an extension that uses both d3 and d3-tip, a library for tooltips.

       

      The problem is that d3-tip depends on d3. It needs two modules from d3: d3-selection and d3-collection.

       

      Here's my attempt at loading it. I tried first

      requirejs.config({
          paths:{
              properties: "/Extensions/helloWorld/properties",
              d3: "/Extensions/helloWorld/d3v3",
              d3tip: "/Extensions/helloWorld/d3tip"
          },
          shim: {
              d3tip: {
                  deps: ['d3']
                  }
          }
      });
      define (['jquery','./properties', './d3v3', './d3tip'],
      function($,props, dthree, dthreetip) {
          //stuff });
      
      

       

      but I get the error that require.js can't find d3-collection or d3-selection.

       

      So I tried defining them explicitly, but this doesn't work either.

      requirejs.config({
          paths:{
              properties: "/Extensions/helloWorld/properties",
              d3: "/Extensions/helloWorld/d3v3",
              d3collection: "/Extensions/helloWorld/d3-collection",
              d3selection: "/Extensions/helloWorld/d3-selection",
              d3tip: "/Extensions/helloWorld/d3tip"
          },
          shim: {
              d3tip: {
                  deps: ['d3', 'd3collection', 'd3selection']
                  }
               // all the dependencies go here
          }
      });
      define ( ['jquery','./properties', './d3v3','./d3-collection', './d3-selection', './d3tip'],
      function($,props, dthree, dthreecoll, dthreeselec, dthreetip){
          //stuff});