Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today

D3 v5 in Qlik Sense Mashup


I'm trying to build a mashup using d3 v5 using require.js to load it.
This seems to be working fine as long as I try to use it within the scope of my main function in the script.
However, when trying to use it within the callback of app.createCube() d3 v3 is used instead. I have checked this by writing d3 to the console log from within the main function and from within the callback.

Why is this and how can I fix it?

Thankful for any tips

Best regards

Below are some code snippets

baseUrl: (config.isSecure ? "https://" : "http://") + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources",
paths: {
d3: "https://d3js.org/d3.v5.min"

require(["js/qlik", "d3"], function (qlik, d3) {
var control = false;
qlik.setOnError(function (error) {
$('#popupText').append(error.message + "<br>");
if (!control) {
control = true;
$("body").css("overflow: hidden;");

var app = qlik.openApp('XXXXXXXXX, config);

console.log(d3); //This will log all functions of d3 v5 as expected

app.createCube(<CUBE_CONFIG>, doSomethingWithCube); //CUBE_CONFIG can be any cube


function doSomethingWithCube(reply, app) {
  console.log(d3); //This will log all functions from d3 v3 instead of v5 for some reason

1 Reply
Honored Contributor

Re: D3 v5 in Qlik Sense Mashup

Yes, the dependencies you define in your require call will be defined inside the function you send in to require, but outside of that function it will  not, so you will get the global D3 used by Qlik Sense.

You need to move the function where you use D3 to inside the require callback.