Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Not applicable

Extension with d3 dependency

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});

4 Replies
Employee
Employee

Re: Extension with d3 dependency

Hi,

I think, you have to include the declared variable dependency see here => RequireJS API

so instead of the relative path "./d3tip" use "d3tip" in you define([...]).

I hope this helps.

Not applicable

Re: Extension with d3 dependency

Thanks for replying. I tried this

define ( ['jquery','./properties', "./d3v3","d3tip"],

function($,props, dthree, dthreetip) {//stuff}

which didn't work (it couldn't find the d3tip file). Any idea what I'm doing wrong here?

jvi
New Contributor II

Re: Extension with d3 dependency

Hi,

Try to use full url under your paths.

Employee
Employee

Re: Extension with d3 dependency

If you are using an up to date version of D3-tip then it supports requirejs

See this for an example: d3-tip/requirejs.html at master · Caged/d3-tip · GitHub

Community Browser