JavaScript and Data Visualization Dominic DiFranzo.

Slides:



Advertisements
Similar presentations
Mashing Up Linked Open Government Data Li Ding Tetherless World Constellation Rensselaer Polytechnic Institute Nov 8, 2010.
Advertisements

PHP Form and File Handling
LiNC Developer Meetup Welcome!. Our job is to make your life easier APIs Tools and workflow Documentation Stay in touch: developers.lithium.com Join the.
By Loukik Purohit & Rohit Ghatol
JavaScript and AJAX Jonathan Foss University of Warwick
Visualizations in Drupal with d3.js – Alan Sherry
CSCI 3100 Tutorial 6 Web Development Tools 1 Cuiyun GAO 1.
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
Using JavaScript in Linked Data Applications Oshani Seneviratne Oct 12, 2010.
JQuery A Javascript Library Hard things made eas(ier) Norman White.
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
Linked Data Mashups: From Query to Visualization Dominic DiFranzo.
Multiple Tiers in Action
High Performance Faceted Interfaces Using S2S Eric Rozell, Tetherless World Constellation.
-Uday Dhokale.  What is it ??? Prototype is a JavaScript Framework that aims to ease development of dynamic web applications.  Features a unique, easy-to-use.
More APIs: Web Services CMPT 281. Announcements Project milestone Lab: – Web services examples.
Philly.NET Hands-On jQuery + Plug-ins Bill Wolff, Rob Keiser.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
Semantic Web Bootcamp Dominic DiFranzo PhD Student/Research Assistant Rensselaer Polytechnic Institute Tetherless World Constellation.
Prof. James A. Landay University of Washington Spring 2008 Web Interface Design, Prototyping, and Implementation Rich Internet Applications: AJAX, Server.
JQuery CS 268. What is jQuery? From their web site:
ITM352 PHP and Dynamic Web Pages: Server Side Processing.
Christopher Paolini Computational Science Research Center College of Engineering San Diego State University Computational Science 670 Fall 2009 Monday.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
JavaScript, jQuery & AJAX. What is JavaScript? An interpreted programming language with object oriented capabilities. Not Java! –Originally called LiveScript,
JavaScript & jQuery the missing manual Chapter 11
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
Step Outside the Box – Part II ColdFusion and Ajax.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
The Document Object Model. The Web B.D, A.D. They aren’t web pages, they’re document objects A web browser interprets structured information. A server.
Cross Site Integration “mashups” cross site scripting.
SAN DIEGO SUPERCOMPUTER CENTER Inca Data Display (data consumers) Shava Smallen Inca Workshop September 5, 2008.
Dr. Martin Zhao Sept 4, Topics HTML and related tutorials on w3schools.com Related HTML tags Adding interesting features using JavaScript What is.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
Types of Spatial Data Sites Data portals: Find and download data –Humboldt County, National Atlas “Atlases”: General information –GoogleMaps, MapQuest.
SYST Web Technologies SYST Web Technologies AJAX.
Ajax for Dynamic Web Development Gregory McChesney.
Chapter 16: Ajax-Enabled Rich Internet Applications with XML and JSON TP2543 Web Programming Mohammad Faidzul Nasrudin.
How to Use Google Charts. Using Google Charts Google Charts is used to provide a way to visualize data on your website. You can choose to use simple line.
ICM – API Server & Forms Gary Ratcliffe.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
CHAPTER 8 AJAX & JSON WHAT IS AJAX? Ajax lets you…
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
CMS 2: Advanced Web Editing - Content Presented By: Katie Pagano, Special Projects Manager Steve Pont, Product Architect.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
Google Analytics Graham Triggs Head of Repository Systems, Symplectic.
Web Services Essentials. What is a web service? web service: software functionality that can be invoked through the internet using common protocols like.
JQuery form submission CIS 136 Building Mobile Apps 1.
1 Mashup Workflow. 2 What We Have 3 Challenges with REST APIs * Only ask what its built to answer * No standard - must relearn each time * Opaque - no.
AJAX. Objectives Understand and apply AJAX Using AJAX in DOJO library.
CSCI 3100 Tutorial 5 JavaScript & Ajax Jichuan Zeng Department of Computer Science and Engineering The Chinese University of Hong.
X2R Spec 1. Change log DateVersionPeopleNote 2013/11/01V0.0.1Chien-Wei Yu, Anderson Ou First draft, add X2R files spec. 2013/12/16V0.0.2Anderson Ou, Doc.
ITM352 PHP and Dynamic Web Pages: Server Side Processing 1.
AJAX and REST.
Section 17.1 Section 17.2 Add an audio file using HTML
AJAX.
Session V HTML5 APIs - AJAX & JSON
IS 360 Course Introduction
HTML Level II (CyberAdvantage)
HTML5 AJAX & JSON APIs
Types of Spatial Data Sites
MIS JavaScript and API Workshop (Part 3)
Types of Spatial Data Sites
Introduction to AJAX and JSON
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
WCF Data Services and Silverlight
Presentation transcript:

JavaScript and Data Visualization Dominic DiFranzo

JavaScript Nothing to do with Java, a lot to do with scripts. prototype-based, dynamic, weakly typed, and first-class functions. Supports object-oriented, imperative, and functional programming. Mostly runs in client-side in web browsers Very object-based: Object property names are string keys: obj.x = 10 and obj['x'] = 10 are the same

Example function factorial(n) { if (n == 0) { return 1; } return n * factorial(n - 1); }

Example function sum() { var x = 0; for (var i = 0; i < arguments.length; ++i) { x += arguments[i]; } return x; } sum(1, 2, 3); // returns 6

Example function add1(n) { return n +1; } function map(func, list) { for (var i = 0; i < list.length; ++i) { list[i] = func(list[i]); } return list; }

Quick reference on other “things” DOM – Document Object Model AJAX - Asynchronous JavaScript and XML JSON - JavaScript Object Notation Same-origin policy and XSS (Cross Site Scripting)

JSON { "id": 1, "name": "Foo", "price": 123, "tags": ["Bar","Eek"] } data.id is 1 data.tags[0] is “Bar”

What We Have

What We Want

Start w/ Data and Query Think about the data you have, what it can mash with, how you could query it. Hardest part! What is in your data? What story do you want to tell? What is the quality of the data? What should it look like? All about visualization theory and design. A map? A pie chart? Something different? What interactions will the user have?

SPARQLProxy This is a web service that allows you to query any SPARQL endpoint, and get back the results in any format you want. A RESTful way to query any endpoint in any environment.

SPARQLProxy Paramiters: query: [required] encoded String of SPARQL query query-uri :[required] URI of SPARQL query (use as an alternative to "query" parameter. These two parameters are mutul-exclusive)

SPARQLProxy service-uri: [required] URI of SPARQL Endpoint – default is the LOGD endpoint output: output format. ''xml'' - SPARQL/XML (default) : ''exhibit'' - JSON for MIT Exhibit : ''gvds'' - JSON for Google Visualization : ''csv'' - CSV : ''html'' - HTML table : “sparql” - SPARQL JSON

Example option=text&query=PREFIX+conversion%3A+%3C http%3A%2F%2Fpurl.org%2Ftwc%2Fvocab%2Fco nversion%2F%3E%0D%0ASELECT+%3Fg+sum%28 +%3Ftriples+%29+as+%3Festimated_triples%0D% 0AWHERE+{%0D%0A++GRAPH+%3Fg++{%0D%0A +++%3Fg+void%3Asubset+%3Fsubdataset+.%0D %0A+++%3Fsubdataset+conversion%3Anum_tripl es+%3Ftriples+.%0D%0A++}%0D%0A}+%0D%0AG ROUP+BY+%3Fg%0D%0A&service- uri=&output=html&callback=&tqx=&tp=

Example // compose query $sparqlproxy_uri = " $params = array(); $params["query-uri"] = " results/datagov-list-loaded-dataset.sparql"; $params["service-uri"] = " $params["output"] = "gvds"; $query= $sparqlproxy_uri."?". http_build_query($params,,'&') ; //specific for Drupal //show query result echo file_get_contents($query);

Visualizing The Data Many JavaScript API and Libraries to help make visualizations Trades in eases of use and control/customization. We will focus on the Google Visualization API, very easy to use out-of-the-box but almost impossible to customize outside of what they provide. /docs/gallery.html /docs/gallery.html

Visualization Example Start with a dataset(s) We will look into State Library Agency Survey: Fiscal Year 2006http://logd.tw.rpi.edu/source/data- gov/dataset/353/version/1st-anniversaryhttp://logd.tw.rpi.edu/source/data- gov/dataset/353/version/1st-anniversary and Tax Year 2007 County Income Data gov/dataset/1356/version/2009-Dec-03

Example Lets make a map of "Adjusted Gross Income(AGI) per Capita” a US map where each state is colored according to the average AGI per person living in that state. We obtain a state's AGI data from Dataset 1356 and a state's population data from Dataset 353.

Lets make a query visualizations/mashup-353-population agi.sparql visualizations/mashup-353-population agi.sparql

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " AGI per Capita Map AGI per Capita Map Loading Map...

// load google visualization packages - STEP 1 google.load('visualization', '1', {'packages': ['geomap']}); // set callback function for drawing visualizations - STEP 2 google.setOnLoadCallback(drawMap);

function drawMap() { //Query data - STEP 3 var sparqlproxy = " var queryloc = " visualizations/mashup-353-population-1356-agi.sparql"; var queryurl = sparqlproxy + "?" + "output=gvds” + “&query-option=uri” + "&query-uri=" + encodeURIComponent(queryloc) ; var query = new google.visualization.Query(queryurl); query.send(handleQueryResponse); }

function handleQueryResponse(response){ // Check for query response errors. - STEP 4 if (response.isError()) { alert('Error in query: ' + response.getMessage() + ' ' + esponse.getDetailedMessage()); return; }

// read data - STEP 5 var data = response.getDataTable(); // create new data - STEP 6 var newdata = new google.visualization.DataTable(); newdata.addColumn('string', 'State'); newdata.addColumn('number', 'AGI per Capita');

// populate each row - STEP 7 var rows = data.getNumberOfRows(); for (var i = 0; i < rows; i++ ) { var state = 'US-' + data.getValue(i, 0); // AGI figure uses thousand-dollar unit var value = Math.round(data.getValue(i, 1)*1000/ data.getValue(i, 2)); newdata.addRow([state, value]); }

// configure map options - STEP 8 var options = {}; options['region'] = 'US';// show US map options['dataMode'] = 'regions'; options['width'] = 900; options['height'] = 550;

// define geomap instance - STEP 9 var viz = document.getElementById('map_canvas'); new google.visualization.GeoMap(viz).draw(newdata, options ); }//end of handleQueryResponse function //end of JavaScript Tag

See Live Version - visualizations/agi-per-capita-v2.html