background preloader

Manipulating data like a boss with d3

Manipulating data like a boss with d3

How Selections Work Any sufficiently advanced technology is indistinguishable from magic. –Arthur C. Clarke In the past I have presented simplified descriptions of D3’s selections, providing only enough detail to get started. The structure of this article may at first seem arbitrary. D3 is a visualization library, so this article incorporates visual explanations to accompany the text. var array = [42]; Wherever possible, the code that generates the given selection appears immediately above the diagram. Let’s begin. #A Subclass of Array You were probably told that selections are arrays of DOM elements. #Grouping Elements Another reason selections aren’t literally arrays of elements is that they are arrays of arrays of elements: a selection is an array of groups, and each group is an array of elements. var selection = d3.select("body"); In the JavaScript console, try running this command and inspecting the group as selection[0] and the node as selection[0][0]. d3.selectAll("h2"); #Non-Grouping Operations

2011-D3 InfoVis.pdf Data Structures D3.js Accepts The Goal In this section, you will understand how to structure data for better use of D3.js. We will cover where we have been, how D3.js thinks of selections, the basics of JavaScript objects and how to best structure our data. What we have seen thus far Every example we have done with D3.js thus far has included a data set at the top of the example like this one: 1var spaceCircles = [30, 70, 110]; This variable spaceCircles is a JavaScript Array. In the spaceCircles case if we type the following into the JavaScript Console, we'll get: 1var spaceCircles = [30, 70, 110]; 2 3spaceCircles[0] 4 5 6spaceCircles[1] 7 8 9spaceCircles[2] 10 Note: the // characters designate a comment in JavaScript and are not evaluated. JavaScript Arrays can hold any type of information you want to put into them. D3.js Selections are Arrays D3.js Selections are JavaScript Arrays. If you run a simple selection in through the JavaScript console.log in the JavaScript Console: 1console.log(d3.select("body"));

d3.js A Brief History of Human Computer Interaction Technology Brad A. Myers Carnegie Mellon University School of Computer Science Technical Report CMU-CS-96-163and Human Computer Interaction Institute Technical Report CMU-HCII-96-103 December, 1996 Please cite this work as: Brad A. Myers. Human Computer Interaction Institute School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213-3891 bam@a.gp.cs.cmu.edu Abstract This article summarizes the historical development of major advances in human-computer interaction technology, emphasizing the pivotal role of university research in the advancement of the field. Copyright (c) 1996 -- Carnegie Mellon University A short excerpt from this article appeared as part of "Strategic Directions in Human Computer Interaction," edited by Brad Myers, Jim Hollan, Isabel Cruz, ACM Computing Surveys, 28(4), December 1996 This research was partially sponsored by NCCOSC under Contract No. Keywords: Human Computer Interaction, History, User Interfaces, Interaction Techniques. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.

The world’s top 50 billionaires: A demographic breakdown. Top 50 Billionaire Breakdown If you asked anyone to picture the wealthiest person in the world at any given time, you could bet on some common denominators: probably a man; probably somehow attached to the words “multinational” or “conglomerate”; probably on a yacht off a private island. With Slate’s Top 50 Billionaire Breakdown, we attempt to visualize the richest of the rich by paring them into demographic categories: age, location, industry, source of wealth, education, and religious affiliation. Some of the sortings are heartening: There are more self-made men than born-rich kids in the top 50, and the self-made billionaires’ total wealth is bigger. Some are less so: The entire African continent has the same number of billionaires as Canada (one each), and there isn’t a single woman in the top 50 who’s self-made. Correction, Nov. 18, 2013: The interactive originally mislabeled the Koch brothers as Jewish.

Authoring Data-Driven Documents Over the last few months I’ve been learning D3 (Data-Driven Documents), which is a really powerful data visualization library built for javascript. The InfoVis paper gets to the gritty details of how it supports data transformations, immediate evaluation of attributes, and a native SVG representation. These features can be more or less helpful depending on what kind of visualization you’re working on. For instance, transformations don’t really matter if you’re just building static graphs. But being able to inspect the SVG representation of your visualization (and edit it in the console) is really quite helpful and powerful. But for all the power that D3 affords, is programming really how we should be (want to be?) Here’s something that I recently made with D3. Now, of course, the exploratory data analysis, storyboarding, and research needed to tell this story were time-consuming. But, really, where’s the flash-like authoring tool of data visualization?

CSV To JSON Converter Convert CSV to JSON Use the tool on this page to convert CSV data to JSON From CSV/Excel To CSV/Excel Data Tools What can this tool do? What are my options? Choose your attribute names to be upper or lower case Choose to limit the number of records processed Select the fields to output and also rearrange JSON fields Filter JSON output by using the query tool Create nested JSON output by using / in the column headings of CSV. What else? Step 1: Select your input Encoding Step 2: Choose input options (optional) Step 3: Choose output options (optional) Step 4: Create Custom Output via Template (optional) Step 5: Generate output Choose Conversion Type: .json You can Save the complete data and settings, and then later Load them from your saved file.

D3 And JavaScript: Working With JSON | D3.js Screencasts | DashingD3js.com This example covers the basics of how to use JSON when working with D3 and JavaScript. Why Working With JSON Is Important: JSON is a human readable data interchange format. JSON makes moving data around your JavaScript Application/Data Visualization easier. This helps you get the benefit of organizing your data as well as the benefits of interoperability and openness. The Concept Behind JSON The concept behind JSON is that it is a lightweight data exchange format. It consists of a collection of name / value pairs. Each value can be a string, number, array or another JSON object. Because you can nest JSON objects within JSON objects, you can highly complex data objects. Here is an example of a JSON object representing the 1972 movie "The Godfather": In the above example the keys are in blue font color. The values are in red font color (except for the number 1972 which is in green). Notice that the blue writing is always double quoted. Next, lets assign this JSON object to a JavaScript Variable

How the Human/Computer Interface Works (Infographics) The long history of user interfaces spans the decades from the primitive punched-card days of the 1950s, through the typed command lines of the 1960s, to the familiar windows and icons of today and beyond. Three factors work to both limit and enable human/computer interface development: Computing Power: Increasingly powerful computer hardware enables more sophisticated software interactions. The Imagination of Inventors: Software designers envision new interactions that take advantage of increasing computer power. The Market: Driven by both large corporate customers and also super-popular consumer gadgets like iPad. A timeline of computer interface milestones: 1822: The Babbage Analytical Engine was a Victorian-era concept envisioned more than a century before its time, this mechanical computer would have been programmed by physically manipulating cams, clutches, cranks and gears. 1950s: Punched cards were first used in the 18th century to control automatic textile looms.

Related: