SlideShare a Scribd company logo
1 of 35
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
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

Indexing and Query Optimization
Indexing and Query OptimizationIndexing and Query Optimization
Indexing and Query Optimization
MongoDB
 
Indexing & Query Optimization
Indexing & Query OptimizationIndexing & Query Optimization
Indexing & Query Optimization
MongoDB
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! 
aleks-f
 
Di web tech mail (no subject)
Di web tech mail   (no subject)Di web tech mail   (no subject)
Di web tech mail (no subject)
shubhamvcs
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
Optimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and CreativityOptimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and Creativity
MongoDB
 
Easy undo.key
Easy undo.keyEasy undo.key
Easy undo.key
zachwaugh
 

What's hot (20)

Indexing and Query Optimization
Indexing and Query OptimizationIndexing and Query Optimization
Indexing and Query Optimization
 
Indexing & Query Optimization
Indexing & Query OptimizationIndexing & Query Optimization
Indexing & Query Optimization
 
GreenDao Introduction
GreenDao IntroductionGreenDao Introduction
GreenDao Introduction
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! 
 
Di web tech mail (no subject)
Di web tech mail   (no subject)Di web tech mail   (no subject)
Di web tech mail (no subject)
 
Green dao
Green daoGreen dao
Green dao
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
WOTC_Import
WOTC_ImportWOTC_Import
WOTC_Import
 
Slickdemo
SlickdemoSlickdemo
Slickdemo
 
Green dao
Green daoGreen dao
Green dao
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
 
greenDAO
greenDAOgreenDAO
greenDAO
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
 
Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)
 
Reducing Development Time with MongoDB vs. SQL
Reducing Development Time with MongoDB vs. SQLReducing Development Time with MongoDB vs. SQL
Reducing Development Time with MongoDB vs. SQL
 
Optimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and CreativityOptimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and Creativity
 
Apache Spark - Key-Value RDD | Big Data Hadoop Spark Tutorial | CloudxLab
Apache Spark - Key-Value RDD | Big Data Hadoop Spark Tutorial | CloudxLabApache Spark - Key-Value RDD | Big Data Hadoop Spark Tutorial | CloudxLab
Apache Spark - Key-Value RDD | Big Data Hadoop Spark Tutorial | CloudxLab
 
Fast querying indexing for performance (4)
Fast querying   indexing for performance (4)Fast querying   indexing for performance (4)
Fast querying indexing for performance (4)
 
Easy undo.key
Easy undo.keyEasy undo.key
Easy undo.key
 

Viewers also liked

Handout - Using Technology To Enhance Your Teaching
Handout - Using Technology To Enhance Your TeachingHandout - Using Technology To Enhance Your Teaching
Handout - Using Technology To Enhance Your Teaching
Alex Hardman
 
Dejan Verčič - Nikola Ljubičić
Dejan Verčič - Nikola LjubičićDejan Verčič - Nikola Ljubičić
Dejan Verčič - Nikola Ljubičić
Lom Buchela
 
Grupo nossos poetas de ontem, de hoje, de sempre... agradecimentos
Grupo nossos poetas de ontem, de hoje, de sempre... agradecimentosGrupo nossos poetas de ontem, de hoje, de sempre... agradecimentos
Grupo nossos poetas de ontem, de hoje, de sempre... agradecimentos
Luzia Gabriele
 

Viewers also liked (16)

Handout - Using Technology To Enhance Your Teaching
Handout - Using Technology To Enhance Your TeachingHandout - Using Technology To Enhance Your Teaching
Handout - Using Technology To Enhance Your Teaching
 
ASHFORD GRADUATION DIPLOMAS
ASHFORD GRADUATION DIPLOMASASHFORD GRADUATION DIPLOMAS
ASHFORD GRADUATION DIPLOMAS
 
Rahul Gautam CV
Rahul Gautam CVRahul Gautam CV
Rahul Gautam CV
 
2009-10-07 IBM zExpo 2009, Current & Future Linux on System z
2009-10-07 IBM zExpo 2009, Current & Future Linux on System z2009-10-07 IBM zExpo 2009, Current & Future Linux on System z
2009-10-07 IBM zExpo 2009, Current & Future Linux on System z
 
Dejan Verčič - Nikola Ljubičić
Dejan Verčič - Nikola LjubičićDejan Verčič - Nikola Ljubičić
Dejan Verčič - Nikola Ljubičić
 
AD-Design1 (1)
AD-Design1 (1)AD-Design1 (1)
AD-Design1 (1)
 
CURSOS INTENSIVOS DE VERANO 2016
CURSOS INTENSIVOS DE VERANO 2016CURSOS INTENSIVOS DE VERANO 2016
CURSOS INTENSIVOS DE VERANO 2016
 
Aparato circulatorio POR Erika Aracely Carranza P.
Aparato circulatorio POR Erika Aracely Carranza P.Aparato circulatorio POR Erika Aracely Carranza P.
Aparato circulatorio POR Erika Aracely Carranza P.
 
Kan een natuurwetenschapper geloven?
Kan een natuurwetenschapper geloven?Kan een natuurwetenschapper geloven?
Kan een natuurwetenschapper geloven?
 
Grupo nossos poetas de ontem, de hoje, de sempre... agradecimentos
Grupo nossos poetas de ontem, de hoje, de sempre... agradecimentosGrupo nossos poetas de ontem, de hoje, de sempre... agradecimentos
Grupo nossos poetas de ontem, de hoje, de sempre... agradecimentos
 
Fa jan 17
Fa jan 17Fa jan 17
Fa jan 17
 
Gonçalves dias olhos verdes
Gonçalves dias olhos verdesGonçalves dias olhos verdes
Gonçalves dias olhos verdes
 
CAT
CATCAT
CAT
 
La classification et l’identification des cultures par la télédétection
La classification et l’identification des cultures par la télédétectionLa classification et l’identification des cultures par la télédétection
La classification et l’identification des cultures par la télédétection
 
IMIA Chiang Spatial Computing - 2016
IMIA Chiang Spatial Computing - 2016IMIA Chiang Spatial Computing - 2016
IMIA Chiang Spatial Computing - 2016
 
Proposal writing
Proposal writingProposal writing
Proposal writing
 

Similar to Using Arbor/ RGraph JS libaries for Data Visualisation

From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 
Js info vis_toolkit
Js info vis_toolkitJs info vis_toolkit
Js info vis_toolkit
nikhilyagnic
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
偉格 高
 

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

node.js and the AR.Drone: building a real-time dashboard using socket.io
node.js and the AR.Drone: building a real-time dashboard using socket.ionode.js and the AR.Drone: building a real-time dashboard using socket.io
node.js and the AR.Drone: building a real-time dashboard using socket.io
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of Things
 
.NET Database Toolkit
.NET Database Toolkit.NET Database Toolkit
.NET Database Toolkit
 
JS Fest 2019 Node.js Antipatterns
JS Fest 2019 Node.js AntipatternsJS Fest 2019 Node.js Antipatterns
JS Fest 2019 Node.js Antipatterns
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile services
 
Building an api using golang and postgre sql v1.0
Building an api using golang and postgre sql v1.0Building an api using golang and postgre sql v1.0
Building an api using golang and postgre sql v1.0
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
 
NoSQL meets Microservices
NoSQL meets MicroservicesNoSQL meets Microservices
NoSQL meets Microservices
 
Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015
Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015
Michael Hackstein - NoSQL meets Microservices - NoSQL matters Dublin 2015
 
Js info vis_toolkit
Js info vis_toolkitJs info vis_toolkit
Js info vis_toolkit
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 
Ajax for dummies, and not only.
Ajax for dummies, and not only.Ajax for dummies, and not only.
Ajax for dummies, and not only.
 
Javascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionJavascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introduction
 
Road to react hooks
Road to react hooksRoad to react hooks
Road to react hooks
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
 
MongoDB and RDBMS
MongoDB and RDBMSMongoDB and RDBMS
MongoDB and RDBMS
 

More from Alex Hardman (11)

21st Century Research Profiles Presentation
21st Century Research Profiles Presentation21st Century Research Profiles Presentation
21st Century Research Profiles Presentation
 
21st Century Research Profiles Handout
21st Century Research Profiles Handout21st Century Research Profiles Handout
21st Century Research Profiles Handout
 
Technology Enabled Teaching
Technology Enabled TeachingTechnology Enabled Teaching
Technology Enabled Teaching
 
Research2.0 Identity Management
Research2.0   Identity ManagementResearch2.0   Identity Management
Research2.0 Identity Management
 
Technology Enabled Research
Technology Enabled ResearchTechnology Enabled Research
Technology Enabled Research
 
Technology Enabled Research Handout
Technology Enabled Research HandoutTechnology Enabled Research Handout
Technology Enabled Research Handout
 
Integrating Technology Into Researcher Training Slides
Integrating Technology Into Researcher Training SlidesIntegrating Technology Into Researcher Training Slides
Integrating Technology Into Researcher Training Slides
 
Research Methods Online
Research Methods OnlineResearch Methods Online
Research Methods Online
 
Technology Enhanced Training
Technology Enhanced TrainingTechnology Enhanced Training
Technology Enhanced Training
 
Social Networking in Research
Social Networking in ResearchSocial Networking in Research
Social Networking in Research
 
Blogging & Social Networking - Some thoughts about the social and educational...
Blogging & Social Networking - Some thoughts about the social and educational...Blogging & Social Networking - Some thoughts about the social and educational...
Blogging & Social Networking - Some thoughts about the social and educational...
 

Recently uploaded

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

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
  • 32.
  • 33.
  • 34.
  • 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); } };