• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Processing & Dataviz
 

Processing & Dataviz

on

  • 1,030 views

Slides from my Processing & Data VIsualization workshop. Probably won't make a great deal of sense to those of you who haven't attended.

Slides from my Processing & Data VIsualization workshop. Probably won't make a great deal of sense to those of you who haven't attended.

Statistics

Views

Total Views
1,030
Views on SlideShare
1,030
Embed Views
0

Actions

Likes
2
Downloads
23
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Processing & Dataviz Processing & Dataviz Presentation Transcript

  • “this is going to be AWESOME!"
  • & Data Visualization
  • Why ?
  • complex interactiveexploratory novel
  • 1. Get the data into Processing
  • 1. Get the data into Processing2. Parse the data into useful Objects
  • 1. Get the data into Processing2. Parse the data into useful Objects3. Render the objects on screen
  • CSV, JSON, XML
  • 1. Get the data into Processing
  • JSON XML CSV FlexibleStructured Easy
  • CSV (Comma-Separated Values) • Values (columns) are typically delimited by commas • Rows are typically delimited by carriage returns • Works for most data that can go in a simple spreadsheet • Not good for any kind of complex or relational data • Processing doesn’t have built in support for CSV but we can use JAVA libraries like opencsv
  • 4,14,26,17,98,35,128,362,9,18,45 dave,28,male,no erica,28,female,no roger,52,male,yes
  • XML (eXtensible Markup Language) • Data is stored in nested nodes • Structure of data is extremely flexible to define but not as flexible to change • Processing has built-in support for XML • Many APIs will return data in XML format
  • <patients> <patient name=”dave” age=28 gender=”male” smoker=”no”/> <patient name=”erica” age=28 gender=”female” smoker=”no”/> <patient name=”roger” age=52 gender=”male” smoker=”yes”/></patients>
  • JSON (JavaScript Object Notation) • Data is as JavaScript Objects • Extraordinarily flexible and lightweight • Lack of named structures can make stored data difficult to understand • JAVA and JavaScript do not play as nicely as you might think
  • { patients:[ {name:”dave”, age:28, gender:”male”, smoker:false}, {name:”erica”, age:28, gender:”female”, smoker:false}, {name:”roger”, age:52, gender:”male”, true} ]}
  • { Curly Braces - OBJECT};
  • [ Square Brackets - ARRAY ]
  • { name:”Peter”, age:18, smoker:false, friends:[“April”, “Ron”, “Valerie”]};
  • { name:”Peter”, age:18, smoker:false, friends:[“April”, “Ron”, “Valerie”]}; myJSONObject.age
  • { name:”Peter”, age:18, smoker:false, friends:[“April”, “Ron”, “Valerie”]}; myJSONObject.friends[1]
  • { name:”Peter”, age:18, smoker:false, friends:[“April”, “Ron”, “Valerie”]}; myJSONObject.getInt(“age”);
  • { name:”Peter”, age:18, smoker:false, friends:[“April”, “Ron”, “Valerie”] };JSONArray a = myJSONObject.getJSONArray[“friends”];a.getString(1);
  • myJSONObject = new JSONObject(stringData);JSONArray a = myJSONObject.getJSONArray[“friends”];println(a.getString(1));
  • try { myJSONObject = new JSONObject(stringData); JSONArray a = myJSONObject.getJSONArray[“friends”]; println(a.getString(1));} catch (Exception e) { println(“JSON LOAD FAILED.”);}
  • try { String url = “http://test.com/?getStuff”; String stringData = join(loadStrings(url), “”); myJSONObject = new JSONObject(stringData); JSONArray a = myJSONObject.getJSONArray[“friends”]; println(a.getString(1));} catch (Exception e) { println(“JSON LOAD FAILED.”);}
  • http://www.blprnt.com/processing/json.zip
  • 2. Parse the data into useful Objects
  • class Patient { XML String name; int age;JSON String gender; ArrayList<Patient> patientList boolean smoker; CSV Patient(); }
  • ArrayList: Store lists of objectsHashMap: Keep counts of categories
  • Arrays vs. ArrayLists
  • Arrays fast easy to usegood for known quantities
  • ArrayLists flexible full-featuredgood for changing quantities
  • Basic ArrayLists ArrayList myList = new ArrayList(); CheeseBurger cb = new CheeseBurger(); myList.add(cb);
  • Basic ArrayLists CheeseBurger cb = myList.get(0); cb.eat();
  • Basic ArrayLists CheeseBurger cb = myList.get(0);X cb.eat();
  • Basic ArrayLists CheeseBurger cb = (CheeseBurger) myList.get(0); cb.eat();
  • ArrayLists w/ Generics ArrayList<CheeseBurger> myList = new ArrayList(); CheeseBurger cb = new CheeseBurger(); myList.add(cb);
  • ArrayLists w/ Generics CheeseBurger cb = myList.get(0);√ cb.eat();
  • HashMaps
  • HashMapsStore objects by a keyHelpful for keeping counts of categoriesUseful for keeping checklists
  • HashMapsHashMap<keyType, valueType>myMap = new HashMap();CustomObject o = new CustomObject();myMap.put(key, o);CustomObject o = myMap.get(key)
  • 3. Render the objects on screen
  • <insert wisdom here>
  • position size# colour rotation sound ?
  • position size# map() colour rotation sound ?
  • map(5,0,10,0,100) 50
  • map(5,0,10,0,1000) 500
  • map(5,0,10,20,30) 25