دنبال کننده ها

۱۳۹۷ فروردین ۸, چهارشنبه

javascript - correct way to call D3.js object in Drupal module

[ad_1]



I am trying to visualize a network using D3 with Drupal 7.x and I don't know what is the right way to refer to D3 within my js file.



So far I can build the json and use a render array to pass it to my js script (and show it in console), but then I fail calling D3.js:



Uncaught ReferenceError: d3 is not defined


Here's my js code so far:



(function($)
Drupal.behaviors.mymodule =
attach : function(context, settings)
if(Drupal.settings.mymodule.graph_json !== '')
// visualize the json
console.log(Drupal.settings.mymodule.graph_json);
// create the newtork
d3.json(Drupal.settings.mymodule.graph_json, function (error, json)
if (error)
return console.warn(error);

);


;
(jQuery));


Should I add a reference in the array? Or since D3.js is in sites/all/libraries/d3 then there is a common way to call it?




[ad_2]

لینک منبع