Question about D3 example and requireJS

Hi,

I tried D3 example on D3 gallery. I found D3's web site. D3.js is published 4.1.1 version. 

but KNIME supported D3 3.5.5? version. So I will try to requireJS because of 4.1.1 version D3. 

I try example about requireJS (http://bl.ocks.org/jasondavies/37e8d3ec0c5125e7e5dd). I change paths "http://d3js.org/d3.v3.min" to "http://d3js.org/d3.v4.min" and it dosen't have any error. Output print "Successfully loaded D3 version 4.1.1" good.

But I try other example like this(http://bl.ocks.org/mbostock/4060366). It didn't work good. It doesn't any respond. So I try other example that use D3 version 3.x.x. Version 3 example work good. 

 

Is any configuration need on D3 version 4? or Doesn't KNIME support D3 version 4 yet?

1 Like

I guess you have some mistakes somewhere because it works as expected for me.

See the attached workflow.

Cheers,
Marco.

thank you for your reply.

It is difference example code. 

Your code: 

d3.select("body").append("svg").attr("width", 960).attr("height", 500);

var svg = d3.select("svg").on("touchmove mousemove", moved),
    width = +svg.attr("width"),
    height = +svg.attr("height");

My code:

var svg = d3.select("svg").on("touchmove mousemove", moved),
    width = +svg.attr("width"),
    height = +svg.attr("height");

When I change my source code to your source code, Generic JavaScript View nodes worked good. 

 

That makes sense. When you are importing D3 manually via RequireJS, the JavaScript View node doesn't create by default the svg element you need to work with in the DOM, hence the need to specifically add and size it.

Glad this solved your problem.

Cheers,
Marco.