SlideShare a Scribd company logo
JavaScript para
Gráficos y Visualización
      de Datos

   Nicolas Garcia Belmonte   -   @philogb
Uso estándares web para crear visualizaciones de datos.




                     @philogb
Soy el autor de dos frameworks de visualización en
                     JavaScript



     PhiloGL                 JavaScript InfoVis Toolkit
Visualización en la Web con JavaScript

                            Extraer
                            Gather       DB


Datos / Servidor /        Transformar
                           Transform     Python
    Cliente
                             Servir
                             Serve       JSON / Binary


                          Cargar Data
                           Load Datos    XHR2



                         Build Models
                         Crear Modelos   Workers / TypedArrays
     Viz / Cliente

                           Renderear
                            Render       WebGL / 2D Canvas


                          Interactuar
                            Interact     DOM Events / HTML Forms
Primer Ejemplo
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
Data Source
Video / Camera
                 Rendering
                  WebGL
  Interaction
     Forms
Recolección de Datos
                 HTML5 Video & Media Source
<video id="movie" autoplay controls class="shadows" width="480">
  <source src="movie/shrek.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
  <source src="movie/shrek.ogv" type='video/ogg; codecs="theora, vorbis"' />
</video>


var video = document.getElementById('movie');
video.play();
video.pause();
video.volume += 0.1;



navigator.getUserMedia({ 'video': true }, function(localMediaStream) {
    video.src = window.URL.createObjectURL(localMediaStream);
}, function() {
    //error...
});
Transformación de Datos
               Obtener pixel data usando 2D Canvas

<canvas id="pastie" width="50" height="50" style="display:none;"></canvas>



var canvas = document.getElementById('pastie'),
    ctx = canvas.getContext('2d'),
    rgbaArray;

ctx.drawImage( movie, 0, 0, 50, 50);

rgbaArray =  ctx.getImageData(0, 0, 50, 50).data;
Crear Modelos 3D
                               Web Workers

var worker = new Worker('task.js');

worker.addEventListener('message', function(e) {
    var models = e.data;
    //do something with the models once they're built...
}, false);

worker.postMessage();


//in task.js
self.addEventListener('message', function(e) {
    var models;
    //build models...
    self.postMessage(models);
});
Renderear la Escena
       Canvas / WebGL / PhiloGL

   function loop() {
     //send data to GPU
     program.setUniform('size', sizeValue);
     program.setBuffer('histogram', {
       value: new Float32Array(createColorArray(movie)),
       size: 1
     });
     //rotate histogram a little bit
     theta += 0.007;
     histogramModel.rotation.set(-Math.PI / 4, theta, 0.3);
     histogramModel.update();
     //clear the screen
     gl.clearColor(color, color, color, 1);
     gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
     //render the scene
     scene.render();
     //request next frame for loop
     Fx.requestAnimationFrame(loop);
   }
Segundo Ejemplo
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
Interaction
   Forms




       Rendering / Interaction
              WebGL


                Interaction
                   Forms
Datos
• 1200 estaciones de meteorología
• 72 horas de datos
• 5 variables - latitud, longitud, velocidad y
  dirección del viento, temperatura


   = 460.000 items
Datos
                    Datos Binarios

direction   speed   temperature   direction   speed   temperature

                     unsigned ints



                       [10, 1, 100, ...]


                            JSON
Datos
          Datos Binarios

             Binary           JSON

1500000

1125000

 750000

 375000

      0
                      Bytes
Cargar Datos
                       XHR2
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://some.binary.data/', true);

//track file loading progress
xhr.addEventListener('progress', function(e) {
    console.log(Math.round(e.loaded / e.total * 100));
}, false);

//set to receive array buffer
xhr.responseType = 'arraybuffer';

//get data when available
xhr.addEventListener('readystatechange', function(e) {
    if (xhr.readyState == 4 /* COMPLETE */) {
        if (xhr.status == 200 /* OK */) {
            //binary data here!
            handleBinaryData(xhr.response); //ArrayBuffer
        }                    
    }
}, false);

//send request
xhr.send();
Cargar Datos
Typed Arrays: Ultra rápidos Arrays

function handleBinaryData(arraybuffer) {
    var typedArray = new Uint16Array(arraybuffer);
    //do stuff like with a regular array
    for (var i = 0, l = typedArray.length; i < l; ++i) {
        typedArray[i] += 2;        
    }
}

                                     Uint8Array


                                    Float32Array
       ArrayBuffer

                                     Int16Array


                                        etc.
Interacción
                                 HTML5 Forms

     <input id='time' type='range' value='0' min='0' max='71' step='1'>


                 var slider = document.getElementById('time');

                 slider.addEventListener('change', function(e) {
                     var value = slider.valueAsNumer;
                 }, false);




Otros tipos: color, date, datetime, email, month, number, range, search, tel, time, url, week, etc.
  //Create application
  PhiloGL('canvasId', {
    program: {
      from: 'uris',
      vs: 'shader.vs.glsl',
                                  WebGL / PhiloGL
      fs: 'shader.fs.glsl'
    },                                            Rendering
    camera: {
      position: {
        x: 0, y: 0, z: -50
      }
    },
    textures: {
      src: ['arroway.jpg', 'earth.jpg']
    },
    events: {
      onDragMove: function(e) {
        //do things...
      },
      onMouseWheel: function(e) {
        //do things...
      }
    },
    onError: function() {
      alert("There was an error creating the app.");
    },
    onLoad: function(app) {
      /* Do things here */
    }
  });
Conclusión
                    En mi opinión:

   HTML5 APIs Puras
           +
        Polyfills
           +
                         >     Monolithic Application
                                  Frameworks
Lightweight Frameworks
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
Gracias!

@philogb

http://philogb.github.com/

More Related Content

PPTX
Taming that client side mess with Backbone.js
PPTX
AngularJS Compile Process
PDF
Databinding and Performance-Tuning in Angular 2
PPT
AngularJS and SPA
PPTX
AngularJS Services
PDF
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
PDF
The Beauty Of Java Script V5a
PDF
JavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
Taming that client side mess with Backbone.js
AngularJS Compile Process
Databinding and Performance-Tuning in Angular 2
AngularJS and SPA
AngularJS Services
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
The Beauty Of Java Script V5a
JavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires

What's hot (20)

PPT
Backbone js
PDF
JavaScript APIs - The Web is the Platform - MDN Hack Day, Santiago, Chile
PPTX
Performance Optimization In Angular 2
PPTX
jQuery Data Manipulate API - A source code dissecting journey
PDF
Prototype UI
PDF
JavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
PDF
Joe Walker Interactivewebsites Cometand Dwr
PPTX
Lecture 6: Client Side Programming 2
PPTX
Nodejs do teste de unidade ao de integração
PPTX
Lecture 5: Client Side Programming 1
PDF
Javascript & Ajax Basics
PDF
The Open Web and what it means
PPTX
Angular 2 Architecture
PDF
jQuery Effects
PPTX
Angular 2 - Ahead of-time Compilation
PPTX
Template syntax in Angular 2.0
PDF
Backbone.js — Introduction to client-side JavaScript MVC
ODP
JQuery introduction
PPTX
01 Introduction - JavaScript Development
PDF
History of jQuery
Backbone js
JavaScript APIs - The Web is the Platform - MDN Hack Day, Santiago, Chile
Performance Optimization In Angular 2
jQuery Data Manipulate API - A source code dissecting journey
Prototype UI
JavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
Joe Walker Interactivewebsites Cometand Dwr
Lecture 6: Client Side Programming 2
Nodejs do teste de unidade ao de integração
Lecture 5: Client Side Programming 1
Javascript & Ajax Basics
The Open Web and what it means
Angular 2 Architecture
jQuery Effects
Angular 2 - Ahead of-time Compilation
Template syntax in Angular 2.0
Backbone.js — Introduction to client-side JavaScript MVC
JQuery introduction
01 Introduction - JavaScript Development
History of jQuery
Ad

Viewers also liked (11)

PPTX
Bringing Networks to Life Using Visualization for User Engagement
PPTX
Object oriented javascript
PDF
Using Web Standards to create Interactive Data Visualizations for the Web
PDF
Object Oriented JavaScript
PDF
New Tools for Visualization in JavaScript - Sept. 2011
PPT
WCAG 2.0, Simplified
PPTX
Introdcution to Adobe CQ
PDF
Advanced Object-Oriented JavaScript
PPTX
REST & RESTful Web Services
PDF
WCAG 2.0 for Designers
PPTX
JSON and REST
Bringing Networks to Life Using Visualization for User Engagement
Object oriented javascript
Using Web Standards to create Interactive Data Visualizations for the Web
Object Oriented JavaScript
New Tools for Visualization in JavaScript - Sept. 2011
WCAG 2.0, Simplified
Introdcution to Adobe CQ
Advanced Object-Oriented JavaScript
REST & RESTful Web Services
WCAG 2.0 for Designers
JSON and REST
Ad

Similar to JavaScript para Graficos y Visualizacion de Datos - BogotaJS (20)

PDF
Webgl para JavaScripters
PDF
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
PDF
soft-shake.ch - Hands on Node.js
PDF
Pushing the Web: Interesting things to Know
PDF
Is HTML5 Ready? (workshop)
PDF
Is html5-ready-workshop-110727181512-phpapp02
PPTX
Ajax for dummies, and not only.
PDF
node.js and the AR.Drone: building a real-time dashboard using socket.io
PDF
Taking Web Apps Offline
PDF
Javascript Frameworks for Joomla
PDF
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
PDF
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
PDF
Intro to HTML5
PPTX
NodeJS
KEY
Writing robust Node.js applications
PDF
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
PDF
jQuery and Rails: Best Friends Forever
PDF
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
PDF
droidQuery: The Android port of jQuery
PDF
Understanding backbonejs
Webgl para JavaScripters
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
soft-shake.ch - Hands on Node.js
Pushing the Web: Interesting things to Know
Is HTML5 Ready? (workshop)
Is html5-ready-workshop-110727181512-phpapp02
Ajax for dummies, and not only.
node.js and the AR.Drone: building a real-time dashboard using socket.io
Taking Web Apps Offline
Javascript Frameworks for Joomla
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
Intro to HTML5
NodeJS
Writing robust Node.js applications
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
jQuery and Rails: Best Friends Forever
From Hello World to the Interactive Web with Three.js: Workshop at FutureJS 2014
droidQuery: The Android port of jQuery
Understanding backbonejs

More from philogb (20)

PDF
OpenVisConf - WebGL for graphics and data visualization
PDF
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
PDF
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
PDF
The Geography of Tweets - BBC Developer Conference
PDF
Hacking public-facing data visualizations at Twitter
PDF
#interactives at Twitter
PDF
#interactives at Twitter
PDF
La visualisation de données comme outil pour découvrir et partager des idées ...
PDF
Exploring Web standards for data visualization
PDF
JavaScript para Graficos y Visualizacion de Datos
PDF
InfoVis para la Web: Teoria, Herramientas y Ejemplos.
PDF
Una web todos los dispositivos.
PDF
Nuevas herramientas de visualizacion en JavaScript
PDF
Data visualization for the web
PDF
Leaving Flatland: Getting Started with WebGL- SXSW 2012
PDF
Principles of Analytical Design - Visually Meetup - Sept. 2011
PDF
PhiloGL - WebGLCamp Google HQs - June 2011
PDF
Creating Interactive Data Visualizations for the Web - YOW! Developer Confere...
PDF
JavaScript InfoVis Toolkit - Create interactive data visualizations for the web
PDF
JavaScript InfoVis Toolkit Overview
OpenVisConf - WebGL for graphics and data visualization
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
From Data Journalism to Data Illustration - Visualizing Data with JavaScript ...
The Geography of Tweets - BBC Developer Conference
Hacking public-facing data visualizations at Twitter
#interactives at Twitter
#interactives at Twitter
La visualisation de données comme outil pour découvrir et partager des idées ...
Exploring Web standards for data visualization
JavaScript para Graficos y Visualizacion de Datos
InfoVis para la Web: Teoria, Herramientas y Ejemplos.
Una web todos los dispositivos.
Nuevas herramientas de visualizacion en JavaScript
Data visualization for the web
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Principles of Analytical Design - Visually Meetup - Sept. 2011
PhiloGL - WebGLCamp Google HQs - June 2011
Creating Interactive Data Visualizations for the Web - YOW! Developer Confere...
JavaScript InfoVis Toolkit - Create interactive data visualizations for the web
JavaScript InfoVis Toolkit Overview

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPT
Teaching material agriculture food technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Approach and Philosophy of On baking technology
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation theory and applications.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation_ Review paper, used for researhc scholars
Advanced methodologies resolving dimensionality complications for autism neur...
Machine learning based COVID-19 study performance prediction
OMC Textile Division Presentation 2021.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
MIND Revenue Release Quarter 2 2025 Press Release
Teaching material agriculture food technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.
Approach and Philosophy of On baking technology
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Empathic Computing: Creating Shared Understanding
Encapsulation theory and applications.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
SOPHOS-XG Firewall Administrator PPT.pptx
A Presentation on Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars

JavaScript para Graficos y Visualizacion de Datos - BogotaJS

  • 1. JavaScript para Gráficos y Visualización de Datos Nicolas Garcia Belmonte - @philogb
  • 2. Uso estándares web para crear visualizaciones de datos. @philogb
  • 3. Soy el autor de dos frameworks de visualización en JavaScript PhiloGL JavaScript InfoVis Toolkit
  • 4. Visualización en la Web con JavaScript Extraer Gather DB Datos / Servidor / Transformar Transform Python Cliente Servir Serve JSON / Binary Cargar Data Load Datos XHR2 Build Models Crear Modelos Workers / TypedArrays Viz / Cliente Renderear Render WebGL / 2D Canvas Interactuar Interact DOM Events / HTML Forms
  • 7. Data Source Video / Camera Rendering WebGL Interaction Forms
  • 8. Recolección de Datos HTML5 Video & Media Source <video id="movie" autoplay controls class="shadows" width="480">   <source src="movie/shrek.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />   <source src="movie/shrek.ogv" type='video/ogg; codecs="theora, vorbis"' /> </video> var video = document.getElementById('movie'); video.play(); video.pause(); video.volume += 0.1; navigator.getUserMedia({ 'video': true }, function(localMediaStream) {     video.src = window.URL.createObjectURL(localMediaStream); }, function() {     //error... });
  • 9. Transformación de Datos Obtener pixel data usando 2D Canvas <canvas id="pastie" width="50" height="50" style="display:none;"></canvas> var canvas = document.getElementById('pastie'),     ctx = canvas.getContext('2d'),     rgbaArray; ctx.drawImage( movie, 0, 0, 50, 50); rgbaArray =  ctx.getImageData(0, 0, 50, 50).data;
  • 10. Crear Modelos 3D Web Workers var worker = new Worker('task.js'); worker.addEventListener('message', function(e) {     var models = e.data;     //do something with the models once they're built... }, false); worker.postMessage(); //in task.js self.addEventListener('message', function(e) {     var models;     //build models...     self.postMessage(models); });
  • 11. Renderear la Escena Canvas / WebGL / PhiloGL   function loop() {     //send data to GPU     program.setUniform('size', sizeValue);     program.setBuffer('histogram', {       value: new Float32Array(createColorArray(movie)),       size: 1     });     //rotate histogram a little bit     theta += 0.007;     histogramModel.rotation.set(-Math.PI / 4, theta, 0.3);     histogramModel.update();     //clear the screen     gl.clearColor(color, color, color, 1);     gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);     //render the scene     scene.render();     //request next frame for loop     Fx.requestAnimationFrame(loop);   }
  • 14. Interaction Forms Rendering / Interaction WebGL Interaction Forms
  • 15. Datos • 1200 estaciones de meteorología • 72 horas de datos • 5 variables - latitud, longitud, velocidad y dirección del viento, temperatura = 460.000 items
  • 16. Datos Datos Binarios direction speed temperature direction speed temperature unsigned ints [10, 1, 100, ...] JSON
  • 17. Datos Datos Binarios Binary JSON 1500000 1125000 750000 375000 0 Bytes
  • 18. Cargar Datos XHR2 var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://some.binary.data/', true); //track file loading progress xhr.addEventListener('progress', function(e) {     console.log(Math.round(e.loaded / e.total * 100)); }, false); //set to receive array buffer xhr.responseType = 'arraybuffer'; //get data when available xhr.addEventListener('readystatechange', function(e) {     if (xhr.readyState == 4 /* COMPLETE */) {         if (xhr.status == 200 /* OK */) {             //binary data here!             handleBinaryData(xhr.response); //ArrayBuffer         }                         } }, false); //send request xhr.send();
  • 19. Cargar Datos Typed Arrays: Ultra rápidos Arrays function handleBinaryData(arraybuffer) {     var typedArray = new Uint16Array(arraybuffer);     //do stuff like with a regular array     for (var i = 0, l = typedArray.length; i < l; ++i) {         typedArray[i] += 2;             } } Uint8Array Float32Array ArrayBuffer Int16Array etc.
  • 20. Interacción HTML5 Forms <input id='time' type='range' value='0' min='0' max='71' step='1'> var slider = document.getElementById('time'); slider.addEventListener('change', function(e) {     var value = slider.valueAsNumer; }, false); Otros tipos: color, date, datetime, email, month, number, range, search, tel, time, url, week, etc.
  • 21.   //Create application   PhiloGL('canvasId', {     program: {       from: 'uris',       vs: 'shader.vs.glsl', WebGL / PhiloGL       fs: 'shader.fs.glsl'     }, Rendering     camera: {       position: {         x: 0, y: 0, z: -50       }     },     textures: {       src: ['arroway.jpg', 'earth.jpg']     },     events: {       onDragMove: function(e) {         //do things...       },       onMouseWheel: function(e) {         //do things...       }     },     onError: function() {       alert("There was an error creating the app.");     },     onLoad: function(app) {       /* Do things here */     }   });
  • 22. Conclusión En mi opinión: HTML5 APIs Puras + Polyfills + > Monolithic Application Frameworks Lightweight Frameworks