SlideShare a Scribd company logo
EPSRC – Data Visualisation
         Proof of Concept




       Alex Hardman
Topics
• Node Graph (bouncing balls)
  – (Quick) Demo
  – Libraries
  – Frontend / AJAX
• Details Graphs (bar charts etc)
  – (Quick) Demo
  – Libraries
  – Frontend / AJAX
Quick Demo
Libraries
• Node Graph  arborjs.org

• Graphs  rgraph.net



           HTML5 + Canvas
Node Graph
• Uses Canvas (via the HTML5 getContext()
  object.
• The getContext("2d") object has methods to
  draw lines, boxes, circles, and more.
• Uses the Arbor js framework to store nodes
  and edges and handle updating their
  coordinates as the simulation progresses.
Node Graph - Creation
                    arbor.ParticleSystem()

• Parameters
   –   Repulsion (the force repelling nodes from each other)
   –   Stiffness (600 the rigidity of the edges)
   –   Friction (the amount of damping in the system)
   –   Gravity (an additional force attracting nodes to the origin)
   –   Fps (frames per second)
   –   Dt (timestep to use for stepping the simulation)
   –   Precision (accuracy vs. speed in force calculations
        (zero is fast but jittery, one is smooth but cpu-intensive)

                (stored in web.config passed to the view)
Feeding the graph
• Three calls to the server for graph data

             loadInitialData

              loadChildNodes

                    search
Feed the graph… “NodeGraphDTO”
• JSON from the server  “NodeGraphDTO”
Feed the graph… “NodeGraphDTO”
• Lists of :

        Entities   Relationships
Feed the graph… API
foreach(grant in Grants){
  If (showGrants()) {
     ParticleSystem.addNode(
          Id,
          {data we define such as
          size, colour, label text
          etc })
  }
}
… Do for each type in NodeGraphDTO
Feed the graph… API
if(showPeople() && showGrants(){
    foreach (rel in grantPersons) {
      get the grant
      get the person
      ParticleSystem.addEdge(
           grantId
           personId
    }
}
Node Graph – API Callbacks
• redraw()  Gets called repeatedly for each
  frame
• We handle callbacks for:
  – particleSystem.eachEdge(edge, pt1 pt2)
     • Draw a gradient line between pt1 and pt2
  – particleSystem.eachNode(node, pt)
     • Work out what type of node we have
     • Draw it out accordingly (Shape? ,Text? Size? Colour?)
Node Graph – API Callbacks
• initMouseHandling
  – Moved  used to determine whether to display
    hover text
  – Clicked
  – Dragged
  – Dropped  determine whether to load child
    nodes and quick details
JS – (as DRY as possible?)
$(document).ready(function () {
        //Instantiate control objects
        _restoreManager = new RestoreManager();
        _state = new SystemState();
        _aData = new DataHandler();
        _controlsManager = new ControlsManager();
        _nodeController = new NodeController();

       //Initialise controls
       _controlsManager.initialiseControls();

       //Load initial data
       _aData.loadInitialData();
});
General Usage
//Define object function ‘ControlsManager’
function ControlsManager() {
     var self = this;
     //Fix context of ‘this’ to the object
     function

     self.aPublicFunction = function(param) {
          //I’m public
     }
     function aPrivateFunction (){
          I’m private//
     }
}
ControlsManager
//Define controls once as private
var showGrantsChk =
    $("input:checkbox[id=ShowGran
    ts]");

var showOutcomesChk =
    $("input:checkbox[id=ShowOutc
    omes]");

etc…
ControlsManager
//access them via public functions

self.initialiseControls =
    function () {
        …on(‘click’,…) etc.
    }

self.clearDetails =
    function() {…}
DataHandler
self.saveNodeGraphData(data) {
    //Stores NodeGraphDTO object
    //from server
}

self.childData = [];
//can contain child DataHandler(s)
//retrieved when clicking on nodes

self.addChildData(childDataHandler)
DataHandler
//Contains ajax functionilty for
//graph data.

loadInitialData()
//called on document ready

loadChildNodes()
//called after clicking on a node
NodeController
function initSystem() {
    var sys =
    arbor.ParticleSystem(..);
}

self.throttle()
self.unthrottle()
NodeController
self.doGraphObjects() {
      buildThemes();
      buildPeople();
      //and all other nodes
      buildPeopleToGrantEdges();
      //and all other edges

      for (var i = 0; i <
      _aData.childData.length; i++) {
                  var childDataHandler =
                  _aData.childData[i];
                  self.doChildObjects
                        (childDataHandler);
        }
}
NodeController - buildPeople
self.buildPeople() {
    if (_state.showPeople()){
        for(each person in
        _aData.People){
            addPersonNode(person)
            sys.addEdge(…)
        }
    }
}
NodeController - addPersonNode
addPersonNode(person){
       if (!nodeExists(person.Id)){
              sys.addNode(
                     person.Id,
                     {
                            color:pColor,
                            display:person.Id,
                            size: nodeSize,
                            type: person.Type,
                            nodeType:labelNodeType,
                            showLabel:true
                     }
              );
       }
}
NodeController -
   buildPeopleToGrantEdges
buildPeopleToGrantEdges () {
       if (_state.showPeople() && _state.showGrants()) {
            for (var i = 0; i <
              _aData.peopleToGrants.length; i++) {
              var pg = _aData.peopleToGrants[i];
              var personNode = sys.getNode(pg.PersonId);
              var grantNode = sys.getNode(pg.GrantId);
              if (personNode !=undefined && grantNode !=
                                               undefined) {
                     sys.addEdge(pg.PersonId, pg.GrantId,
                           { color: edgeColour });
                    }

             }
         }
    };
NodeControler - doChildObjects
self.doChildObjects = function(cData){
     var parent = sys.getNode
          (cData.rootData.Id);
     //If the parent is null it is not
     //a child object so do nothing
     if (parent != undefined) {
          addChildPeopleNodes(parent,
          cData.peopleData);
          //And all the other types
          //(grants…, research areas…)
     }
};
NodeController -
           addCildPeopleNodes
function addChildPeopleNodes(parentNode, peopleDataArr) {
        if (_state.showPeople()) {
            for (var i = 0; i < peopleDataArr.length; i++) {
                var person = peopleDataArr[i];
                //If the node is root it ain’t a child!
                if (!_state.isCurrentRoot(person.Id)) {
                    var exisitng = sys.getNode(person.Id);
                    if (exisitng == undefined) {
                        addPersonNode(person);
                        _aData.addNodeId(person.Id);
                    }
                    sys.addEdge(
                        parentNode.data.display,
                        person.Id, { color: edgeColour });
                }
            }
        }
    }
RestoreManager
//initialises the reset storage
//in local storage

function initResetStorage(){
    localStorage.resetData = "";
}
RestoreManager
self.addRestorePoint = function (data) {
        if (localStorage.resetData != "") {
            var resetArr = JSON.parse
                (localStorage.resetData);
            resetArr.push(data);
            localStorage.resetData =
                JSON.stringify (resetArr);
        }
        else {
            localStorage.resetData =
                JSON.stringify
                      (new Array(data));
        }
    };
RestoreManager
self.getLastRestoreData = function () {
        var resetData =
              JSON.parse (localStorage.resetData);
        if (resetData.length > 0) {
            if (resetData.length == 1) {
                 return resetData[0];
            }
            var l = resetData.length;
            var data = resetData[l - 2];
            resetData.pop();
            localStorage.resetData =
                     JSON.stringify (resetData);
            return data;
        }
        return null;
    };
Drawing out the nodes - Renderer



           arborgraph.js
             Line 1172
RGraph
Using Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data Visualisation
Using Arbor/ RGraph JS libaries for Data Visualisation
Details.js - ControlsManager
self.doResearchAreaGraph = function () {
       var canvas = getCanvas();
       var ctx = canvas.getContext('2d');
       ctx.clearRect
              (0, 0, canvas.width, canvas.height);
       if(_state.selectedGraphType() == "Bar Chart"){
              graph = new RGraph.Bar('graphCanvas',
              _dataManager.raData.GraphValues);
              graph.Set('chart.background.barcolor1',
              'white');
              graph.Set('chart.background.barcolor2',
              'white');
            graph.Set('chart.labels',
              _dataManager.raData.Themes);
       }
};

More Related Content

What's hot (20)

PPTX
Indexing and Query Optimization
MongoDB
 
PPTX
Indexing & Query Optimization
MongoDB
 
PPTX
GreenDao Introduction
Booch Lin
 
PDF
Look Ma, “update DB to HTML5 using C++”, no hands! 
aleks-f
 
PDF
Di web tech mail (no subject)
shubhamvcs
 
PDF
Green dao
Droidcon Berlin
 
PPTX
Mythbusting: Understanding How We Measure the Performance of MongoDB
MongoDB
 
DOCX
WOTC_Import
Luther Quinn
 
ODP
Slickdemo
Knoldus Inc.
 
PDF
Green dao
彥彬 洪
 
PDF
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Sages
 
PDF
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
PDF
greenDAO
Mu Chun Wang
 
PPTX
MongoDB - Aggregation Pipeline
Jason Terpko
 
PDF
Indexing and Query Optimizer (Mongo Austin)
MongoDB
 
PPTX
Reducing Development Time with MongoDB vs. SQL
MongoDB
 
PDF
Optimizing Slow Queries with Indexes and Creativity
MongoDB
 
PDF
Apache Spark - Key-Value RDD | Big Data Hadoop Spark Tutorial | CloudxLab
CloudxLab
 
PPT
Fast querying indexing for performance (4)
MongoDB
 
ZIP
Easy undo.key
zachwaugh
 
Indexing and Query Optimization
MongoDB
 
Indexing & Query Optimization
MongoDB
 
GreenDao Introduction
Booch Lin
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
aleks-f
 
Di web tech mail (no subject)
shubhamvcs
 
Green dao
Droidcon Berlin
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
MongoDB
 
WOTC_Import
Luther Quinn
 
Slickdemo
Knoldus Inc.
 
Green dao
彥彬 洪
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Sages
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
greenDAO
Mu Chun Wang
 
MongoDB - Aggregation Pipeline
Jason Terpko
 
Indexing and Query Optimizer (Mongo Austin)
MongoDB
 
Reducing Development Time with MongoDB vs. SQL
MongoDB
 
Optimizing Slow Queries with Indexes and Creativity
MongoDB
 
Apache Spark - Key-Value RDD | Big Data Hadoop Spark Tutorial | CloudxLab
CloudxLab
 
Fast querying indexing for performance (4)
MongoDB
 
Easy undo.key
zachwaugh
 

Viewers also liked (16)

PDF
Handout - Using Technology To Enhance Your Teaching
Alex Hardman
 
PDF
ASHFORD GRADUATION DIPLOMAS
VALERIE TUINEI-FLORA
 
DOCX
Rahul Gautam CV
Rahul Gautam
 
PDF
2009-10-07 IBM zExpo 2009, Current & Future Linux on System z
Shawn Wells
 
PDF
Dejan Verčič - Nikola Ljubičić
Lom Buchela
 
PDF
AD-Design1 (1)
AKADMI online
 
PDF
CURSOS INTENSIVOS DE VERANO 2016
CENEC MALAGA
 
PPTX
Aparato circulatorio POR Erika Aracely Carranza P.
AryCarranza
 
PPTX
Kan een natuurwetenschapper geloven?
Daan van Schalkwijk
 
PPSX
Grupo nossos poetas de ontem, de hoje, de sempre... agradecimentos
Luzia Gabriele
 
PDF
Fa jan 17
Sierra Goerg
 
PPSX
Gonçalves dias olhos verdes
Luzia Gabriele
 
PDF
La classification et l’identification des cultures par la télédétection
Abdessadek ELASRI
 
PDF
IMIA Chiang Spatial Computing - 2016
International Map Industry Association
 
PPTX
Proposal writing
Pankaj Wadhwa
 
Handout - Using Technology To Enhance Your Teaching
Alex Hardman
 
ASHFORD GRADUATION DIPLOMAS
VALERIE TUINEI-FLORA
 
Rahul Gautam CV
Rahul Gautam
 
2009-10-07 IBM zExpo 2009, Current & Future Linux on System z
Shawn Wells
 
Dejan Verčič - Nikola Ljubičić
Lom Buchela
 
AD-Design1 (1)
AKADMI online
 
CURSOS INTENSIVOS DE VERANO 2016
CENEC MALAGA
 
Aparato circulatorio POR Erika Aracely Carranza P.
AryCarranza
 
Kan een natuurwetenschapper geloven?
Daan van Schalkwijk
 
Grupo nossos poetas de ontem, de hoje, de sempre... agradecimentos
Luzia Gabriele
 
Fa jan 17
Sierra Goerg
 
Gonçalves dias olhos verdes
Luzia Gabriele
 
La classification et l’identification des cultures par la télédétection
Abdessadek ELASRI
 
IMIA Chiang Spatial Computing - 2016
International Map Industry Association
 
Proposal writing
Pankaj Wadhwa
 
Ad

Similar to Using Arbor/ RGraph JS libaries for Data Visualisation (20)

PDF
Reactive datastore demo (2020 03-21)
YangJerng Hwa
 
PPTX
D3 Force-Directed Graphs
Maxim Kuleshov
 
PDF
dojo.Patterns
Peter Higgins
 
PDF
this
偉格 高
 
PDF
VelocityGraph Introduction
Mats Persson
 
KEY
Introducing AlloyUI DiagramBuilder
Eduardo Lundgren
 
KEY
Txjs
Peter Higgins
 
PPTX
Using Graph Analysis and Fraud Detection in the Fintech Industry
Stanka Dalekova
 
PPTX
Using Graph Analysis and Fraud Detection in the Fintech Industry
Stanka Dalekova
 
PPTX
What’s new in ECMAScript 6.0
Eyal Vardi
 
PPTX
JS Fest 2019. Max Koretskiy. A sneak peek into super optimized code in JS fra...
JSFestUA
 
PDF
Say It With Javascript
Giovanni Scerra ☃
 
PPTX
Working with LoopBack Models
Raymond Feng
 
PDF
JavaScript Refactoring
Krzysztof Szafranek
 
PDF
Having fun with graphs, a short introduction to D3.js
Michael Hackstein
 
PDF
Design patterns in javascript
Abimbola Idowu
 
PPT
Web Optimization Summit: Coding for Performance
johndaviddalton
 
PPTX
Client Best Practices
Yuval Dagai
 
PDF
Js hacks
Nishchit Dhanani
 
PDF
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
Reactive datastore demo (2020 03-21)
YangJerng Hwa
 
D3 Force-Directed Graphs
Maxim Kuleshov
 
dojo.Patterns
Peter Higgins
 
VelocityGraph Introduction
Mats Persson
 
Introducing AlloyUI DiagramBuilder
Eduardo Lundgren
 
Using Graph Analysis and Fraud Detection in the Fintech Industry
Stanka Dalekova
 
Using Graph Analysis and Fraud Detection in the Fintech Industry
Stanka Dalekova
 
What’s new in ECMAScript 6.0
Eyal Vardi
 
JS Fest 2019. Max Koretskiy. A sneak peek into super optimized code in JS fra...
JSFestUA
 
Say It With Javascript
Giovanni Scerra ☃
 
Working with LoopBack Models
Raymond Feng
 
JavaScript Refactoring
Krzysztof Szafranek
 
Having fun with graphs, a short introduction to D3.js
Michael Hackstein
 
Design patterns in javascript
Abimbola Idowu
 
Web Optimization Summit: Coding for Performance
johndaviddalton
 
Client Best Practices
Yuval Dagai
 
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
Ad

More from Alex Hardman (11)

PPT
21st Century Research Profiles Presentation
Alex Hardman
 
DOC
21st Century Research Profiles Handout
Alex Hardman
 
PPTX
Technology Enabled Teaching
Alex Hardman
 
PDF
Research2.0 Identity Management
Alex Hardman
 
PPT
Technology Enabled Research
Alex Hardman
 
DOCX
Technology Enabled Research Handout
Alex Hardman
 
PPT
Integrating Technology Into Researcher Training Slides
Alex Hardman
 
PPT
Research Methods Online
Alex Hardman
 
PPTX
Technology Enhanced Training
Alex Hardman
 
PPT
Social Networking in Research
Alex Hardman
 
PPT
Blogging & Social Networking - Some thoughts about the social and educational...
Alex Hardman
 
21st Century Research Profiles Presentation
Alex Hardman
 
21st Century Research Profiles Handout
Alex Hardman
 
Technology Enabled Teaching
Alex Hardman
 
Research2.0 Identity Management
Alex Hardman
 
Technology Enabled Research
Alex Hardman
 
Technology Enabled Research Handout
Alex Hardman
 
Integrating Technology Into Researcher Training Slides
Alex Hardman
 
Research Methods Online
Alex Hardman
 
Technology Enhanced Training
Alex Hardman
 
Social Networking in Research
Alex Hardman
 
Blogging & Social Networking - Some thoughts about the social and educational...
Alex Hardman
 

Recently uploaded (20)

DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Digital Circuits, important subject in CS
contactparinay1
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 

Using Arbor/ RGraph JS libaries for Data Visualisation

  • 1. EPSRC – Data Visualisation Proof of Concept Alex Hardman
  • 2. Topics • Node Graph (bouncing balls) – (Quick) Demo – Libraries – Frontend / AJAX • Details Graphs (bar charts etc) – (Quick) Demo – Libraries – Frontend / AJAX
  • 4. Libraries • Node Graph  arborjs.org • Graphs  rgraph.net HTML5 + Canvas
  • 5. Node Graph • Uses Canvas (via the HTML5 getContext() object. • The getContext("2d") object has methods to draw lines, boxes, circles, and more. • Uses the Arbor js framework to store nodes and edges and handle updating their coordinates as the simulation progresses.
  • 6. Node Graph - Creation arbor.ParticleSystem() • Parameters – Repulsion (the force repelling nodes from each other) – Stiffness (600 the rigidity of the edges) – Friction (the amount of damping in the system) – Gravity (an additional force attracting nodes to the origin) – Fps (frames per second) – Dt (timestep to use for stepping the simulation) – Precision (accuracy vs. speed in force calculations (zero is fast but jittery, one is smooth but cpu-intensive) (stored in web.config passed to the view)
  • 7. Feeding the graph • Three calls to the server for graph data loadInitialData loadChildNodes search
  • 8. Feed the graph… “NodeGraphDTO” • JSON from the server  “NodeGraphDTO”
  • 9. Feed the graph… “NodeGraphDTO” • Lists of : Entities Relationships
  • 10. Feed the graph… API foreach(grant in Grants){ If (showGrants()) { ParticleSystem.addNode( Id, {data we define such as size, colour, label text etc }) } } … Do for each type in NodeGraphDTO
  • 11. Feed the graph… API if(showPeople() && showGrants(){ foreach (rel in grantPersons) { get the grant get the person ParticleSystem.addEdge( grantId personId } }
  • 12. Node Graph – API Callbacks • redraw()  Gets called repeatedly for each frame • We handle callbacks for: – particleSystem.eachEdge(edge, pt1 pt2) • Draw a gradient line between pt1 and pt2 – particleSystem.eachNode(node, pt) • Work out what type of node we have • Draw it out accordingly (Shape? ,Text? Size? Colour?)
  • 13. Node Graph – API Callbacks • initMouseHandling – Moved  used to determine whether to display hover text – Clicked – Dragged – Dropped  determine whether to load child nodes and quick details
  • 14. JS – (as DRY as possible?) $(document).ready(function () { //Instantiate control objects _restoreManager = new RestoreManager(); _state = new SystemState(); _aData = new DataHandler(); _controlsManager = new ControlsManager(); _nodeController = new NodeController(); //Initialise controls _controlsManager.initialiseControls(); //Load initial data _aData.loadInitialData(); });
  • 15. General Usage //Define object function ‘ControlsManager’ function ControlsManager() { var self = this; //Fix context of ‘this’ to the object function self.aPublicFunction = function(param) { //I’m public } function aPrivateFunction (){ I’m private// } }
  • 16. ControlsManager //Define controls once as private var showGrantsChk = $("input:checkbox[id=ShowGran ts]"); var showOutcomesChk = $("input:checkbox[id=ShowOutc omes]"); etc…
  • 17. ControlsManager //access them via public functions self.initialiseControls = function () { …on(‘click’,…) etc. } self.clearDetails = function() {…}
  • 18. DataHandler self.saveNodeGraphData(data) { //Stores NodeGraphDTO object //from server } self.childData = []; //can contain child DataHandler(s) //retrieved when clicking on nodes self.addChildData(childDataHandler)
  • 19. DataHandler //Contains ajax functionilty for //graph data. loadInitialData() //called on document ready loadChildNodes() //called after clicking on a node
  • 20. NodeController function initSystem() { var sys = arbor.ParticleSystem(..); } self.throttle() self.unthrottle()
  • 21. NodeController self.doGraphObjects() { buildThemes(); buildPeople(); //and all other nodes buildPeopleToGrantEdges(); //and all other edges for (var i = 0; i < _aData.childData.length; i++) { var childDataHandler = _aData.childData[i]; self.doChildObjects (childDataHandler); } }
  • 22. NodeController - buildPeople self.buildPeople() { if (_state.showPeople()){ for(each person in _aData.People){ addPersonNode(person) sys.addEdge(…) } } }
  • 23. NodeController - addPersonNode addPersonNode(person){ if (!nodeExists(person.Id)){ sys.addNode( person.Id, { color:pColor, display:person.Id, size: nodeSize, type: person.Type, nodeType:labelNodeType, showLabel:true } ); } }
  • 24. NodeController - buildPeopleToGrantEdges buildPeopleToGrantEdges () { if (_state.showPeople() && _state.showGrants()) { for (var i = 0; i < _aData.peopleToGrants.length; i++) { var pg = _aData.peopleToGrants[i]; var personNode = sys.getNode(pg.PersonId); var grantNode = sys.getNode(pg.GrantId); if (personNode !=undefined && grantNode != undefined) { sys.addEdge(pg.PersonId, pg.GrantId, { color: edgeColour }); } } } };
  • 25. NodeControler - doChildObjects self.doChildObjects = function(cData){ var parent = sys.getNode (cData.rootData.Id); //If the parent is null it is not //a child object so do nothing if (parent != undefined) { addChildPeopleNodes(parent, cData.peopleData); //And all the other types //(grants…, research areas…) } };
  • 26. NodeController - addCildPeopleNodes function addChildPeopleNodes(parentNode, peopleDataArr) { if (_state.showPeople()) { for (var i = 0; i < peopleDataArr.length; i++) { var person = peopleDataArr[i]; //If the node is root it ain’t a child! if (!_state.isCurrentRoot(person.Id)) { var exisitng = sys.getNode(person.Id); if (exisitng == undefined) { addPersonNode(person); _aData.addNodeId(person.Id); } sys.addEdge( parentNode.data.display, person.Id, { color: edgeColour }); } } } }
  • 27. RestoreManager //initialises the reset storage //in local storage function initResetStorage(){ localStorage.resetData = ""; }
  • 28. RestoreManager self.addRestorePoint = function (data) { if (localStorage.resetData != "") { var resetArr = JSON.parse (localStorage.resetData); resetArr.push(data); localStorage.resetData = JSON.stringify (resetArr); } else { localStorage.resetData = JSON.stringify (new Array(data)); } };
  • 29. RestoreManager self.getLastRestoreData = function () { var resetData = JSON.parse (localStorage.resetData); if (resetData.length > 0) { if (resetData.length == 1) { return resetData[0]; } var l = resetData.length; var data = resetData[l - 2]; resetData.pop(); localStorage.resetData = JSON.stringify (resetData); return data; } return null; };
  • 30. Drawing out the nodes - Renderer arborgraph.js Line 1172
  • 35. Details.js - ControlsManager self.doResearchAreaGraph = function () { var canvas = getCanvas(); var ctx = canvas.getContext('2d'); ctx.clearRect (0, 0, canvas.width, canvas.height); if(_state.selectedGraphType() == "Bar Chart"){ graph = new RGraph.Bar('graphCanvas', _dataManager.raData.GraphValues); graph.Set('chart.background.barcolor1', 'white'); graph.Set('chart.background.barcolor2', 'white'); graph.Set('chart.labels', _dataManager.raData.Themes); } };