Hi, I'm a bit of a Drupal newbie, but I've got your d3 module working with Graph API and Relations. However, I fail to understand where the forcedirected.js's Drupal.d3.ForceDirected = function (select, settings) function gets its inputs from. Where is this function called from and where are its parameters, select and settings set?

I hope you can push me in the right direction! I'm having a hard time understanding how JavaScript is used with modules.

Thanks! :)

Comments

asherry’s picture

Thanks for trying it out.

So Drupal 7 makes use of javascript behaviors. If you're not familiar with those there is a lot of documentation out there way better then what I could give you. The way I invoke all of the functions in the library files is with a defined behavior called d3, Drupal.behaviors.d3. This is found in js/d3.js

What drupal does in its page load is compile all js setting variables, load all html, and then call behaviors. When d3 is called it has an inventory of charts that have been defined in the global settings variable, and it runs through them, gets the #div they are going to be drawn in, and calls the appropriate function based on whatever library was specified.

So drupal core js calls line 19 of js/d3.js, and then that function actually cycles through and draws all the charts after page load.

Hope that helps.

asherry’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mattsson’s picture

Thanks for the response!

asherry’s picture

Project: » d3.js
Version: » 7.x-1.x-dev
Issue summary: View changes