Implementing nvd3.js Charts in KNIME using Generic JavaScript View node

Greetings all,

I have installed KNIME analytics tool and trying to implement nvd3.js based charts using generic javascript view node.I need to implement different types of charts using nvd3 library.When I try to load nvd3 library through require js, seems nvd3.js is not loading properly in the KNIME node.

When execute the following code through javascript generic node, getting error nv variable as undefined. The code is implemented as following way.

require.config({
    paths: {
        "d3": "https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min",
        "nv": "https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.6/nv.d3"
    }
  });

  $('body').append('<div id="chart1"><svg></svg></div>');

  require(["d3","nv"], function (d3, nv) {

    var historicalBarChart = [
        {
            key: "Cumulative Return",
            values: [
                {
                    "label" : "A" ,
                    "value" : 29.765957771107
                } ,
                {
                    "label" : "B" ,
                    "value" : 0
                } ,
                {
                    "label" : "C" ,
                    "value" : 32.807804682612
                }
            ]
        }
    ];

    nv.addGraph(function() {
        var chart = nv.models.discreteBarChart()
            .x(function(d) { return d.label })
            .y(function(d) { return d.value })
            .staggerLabels(true)
            .showValues(true)
            .duration(250);
            
        d3.select('#chart1 svg')
            .datum(historicalBarChart)
            .call(chart);
        nv.utils.windowResize(chart.update);
        return chart;
    });
    
});

Very much appreciate any advice.
Thank you.

Hi @sampathsl,

Sorry for the late response. We are aware of the problem and will try to make it possible to include external libraries with RequireJS in the future releases.

Best,
Anna