
JavaScript and jQuery for Data Analysis and Visualization
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
More details
Other editions
Additional editions


Persons
Content
INTRODUCTION xix
PART I: THE BEAUTY OF NUMBERS MADE VISIBLE
CHAPTER 1: THE WORLD OF DATA VISUALIZATION 3
Bringing Numbers to Life 4
Acquiring the Data 4
Visualizing the Data 4
Simultaneous Acquisition and Visualization 6
Applications of Data Visualization 7
Uses in the Public Sector 7
Business-to-Business and Intrabusiness Uses 8
Business-to-Consumer Uses 8
Web Professionals: In the Thick of It 9
Control of Presentation 9
What Tech Brings to the Table 11
Faster and Better JavaScript Processing 12
Rise of HTML5 12
Lowering the Implementation Bar 13
Summary 14
CHAPTER 2: WORKING WITH THE ESSENTIALS OF ANALYSIS 17
Key Analytic Concepts 18
Mean Versus Median 18
Standard Deviation 19
Working with Sampled Data 20
Standard Deviation Variation 20
Per Capita Calculations 21
Margin of Error 21
Detecting Patterns with Data Mining 22
Projecting Future Trends 23
Summary 25
CHAPTER 3: BUILDING A VISUALIZATION FOUNDATION 27
Exploring the Visual Data Spectrum 28
Charting Primitives 28
Exploring Advanced Visualizations 40
Candlestick Chart 42
Bubble Chart 42
Surface Charts 44
Map Charts 46
Infographics 46
Making Use of the HTML5 Canvas 49
Integrating SVG 52
Summary 54
PART II: WORKING WITH JAVASCRIPT FOR ANALYSIS
CHAPTER 4: INTEGRATING EXISTING DATA 57
Reading Data from Standard Text Files 58
Working Asynchronously 58
Reading CSV Files 59
Incorporating XML Data 61
Understanding the XML Format 61
Getting XML Data 62
Styling with XSLT 63
Displaying JSON Content 66
Understanding JSON Syntax 66
Reading JSON Data 67
Asynchronous JSON 68
Summary 71
CHAPTER 5: ACQUIRING DATA INTERACTIVELY 73
Using HTML5 Form Controls 73
Introducing HTML5 Input Types 74
Form Widgets and Data Formatting 74
Maximizing Mobile Forms 75
Using Contextual Keyboards 76
Styling Mobile Forms for Usability 77
Form Widgets for Mobile 77
Summary 77
CHAPTER 6: VALIDATING YOUR DATA 79
Server-Side Versus Client-Side Validation 80
Native HTML5 Validation 81
Native Versus JavaScript Validation 81
Getting Started with HTML5 Validation 82
HTML5 Validation for Numbers 82
Required Fields and Max Length 82
Custom HTML5 Validation Rules 83
Custom HTML5 Validation Messages 83
h5Validate Polyfi ll 84
jQuery Validation Engine 85
Getting Started with jQuery Validation Engine 85
Validators 86
Error Messages 90
Summary 91
CHAPTER 7: EXAMINING AND SORTING DATA TABLES 93
Outputting Basic Table Data 94
Building a Table 94
Using Semantic Table Markup 96
Labeling Your Table 101
Configuring the Columns 102
Assuring Maximum Readability 105
Styling Your Table 106
Increasing Readability 108
Adding Dynamic Highlighting 114
Including Computations 116
Using JavaScript for Calculations 120
Populating the Table 123
Using the DataTables Library 125
Making Pretty Tables with DataTables 126
Sorting with DataTables 128
Using Calculated Columns with DataTables 130
Relating a Data Table to a Chart 133
Mashing Visualizations Together 133
Summary 144
CHAPTER 8: STATISTICAL ANALYSIS ON THE CLIENT SIDE 145
Statistical Analysis with jStat 146
Getting Started with jStat 146
Stat 101 147
Rendering Probability Distributions with Flot 149
Getting Started with Flot 149
Rendering the Normal Curve 151
Summary 153
PART III: VISUALIZING DATA PROGRAMMATICALLY
CHAPTER 9: EXPLORING CHARTING TOOLS 157
Creating HTML5 Canvas Charts 158
HTML5 Canvas Basics 158
Linear Interpolation 159
A Simple Column Chart 160
Implementing Axes 176
Adding Animation 183
Starting with Google Charts 194
Google Charts API Basics 195
A Basic Bar Chart 195
A Basic Pie Chart 197
Working with Chart Animations 198
Summary 201
CHAPTER 10: BUILDING CUSTOM CHARTS WITH RAPHAËL 203
Introducing Raphaël 204
SVG Versus Canvas Charts 204
Getting Started with Raphaël 204
Drawing Paths 205
Importing Custom Shapes into Raphaël 206
Animating Raphaël Graphics 208
Handling Mouse Events with Raphaël 208
Working with gRaphaël 209
Creating Pie Charts 209
Creating Line Charts 211
Creating Bar and Column Charts 213
Extending Raphaël to Create Custom Charts 216
Setting Up with Common Patterns 216
Drawing an Arc 217
Massaging Data into Usable Values 221
Adding Mouse Interactivity 225
Labeling the Data 227
Wrapping Up 229
Summary 232
CHAPTER 11: INTRODUCING D3 233
Getting Started 235
DOM and SVG 236
.select 237
.selectAll 238
.data() (Also Known As Data Joining) 239
Key Functions 249
.transition() 250
Object Constancy 253
Nested Selections 255
D3 Helper Functions 257
Drawing Lines 257
Scales 258
D3 Helper Layouts 260
Summary 264
CHAPTER 12: INCORPORATING SYMBOLS 265
Working with SVG Symbols with D3 266
Creating a D3 Line Chart 266
Adding Symbols to the Line 271
Making the Symbols Interactive 273
Canvas Symbols with Ignite UI igDataChart 276
Creating a Line Chart with Ignite UI igDataChart 277
Adding Symbols to the Chart 281
Creating a Bubble Chart 284
Summary 289
CHAPTER 13: MAPPING GLOBAL, REGIONAL, AND LOCAL DATA 291
Working with Google Maps 292
The Basics of Mapping Visualizations 292
The Google Maps API v3 294
Customizing Maps with Iconography 297
Displaying a Map Marker 297
Preparing Data to Plot on a Map 299
Plotting Point Data Using Markers 303
Plotting an Additional Statistic Using Marker Area 307
Displaying Data Density with Heat Maps 310
Plotting Data on Choropleth Maps 314
Obtaining Geometry to Plot on a Map 314
Converting Geometry for Display Using Topojson 315
Rendering Map Geometry Using D3 316
Displaying Statistics Using a Choropleth Map 319
Summary 326
CHAPTER 14: CHARTING TIME SERIES WITH IGNITE UI IGDATACHART 327
Working with Stocks 328
The Basics of Stock Data 328
Obtaining Some Stock Data 329
Candlesticks and OHLC Visualizations 329
Implementing Ignite UI igDataChart 331
Obtaining Ignite UI 332
Implementing a Stock Chart Using igDataChart 333
Adding a Zoom Bar to the Chart 342
Adding a Synchronized Chart 344
Working with Technical Analysis Tools 347
Plotting Real-Time Data 348
Creating a Node Push Data Service 349
Receiving Updates in the Client 353
Exploring Update Rendering Techniques 359
Plotting Massive Data 361
Summary 366
PART IV: INTERACTIVE ANALYSIS AND VISUALIZATION PROJECTS
CHAPTER 15: BUILDING AN INTERCONNECTED DASHBOARD 371
The U.S. Census API 372
Rendering Charts 373
Sex Chart 373
Race Chart 375
Household Size Chart 377
Household Tenure Chart 378
Age by Sex Chart 379
Population History Chart 384
Creating the Dashboard 386
Basic Markup and Styling 386
Responsive Layer 389
Connecting Components with Backbone 390
Establishing Models and Collections 391
Converting the Chart Markup to a JavaScript Template 392
Creating the State Drop-down Menu 394
Rendering State Changes 396
Next Steps 410
Rerendering on Resize 411
Other Improvements 411
Summary 411
CHAPTER 16: D3 IN PRACTICE 413
Making D3 Look Perfect 414
Inline Styles Versus CSS 414
Margin 414
Ordering 415
Pointer Events 416
Crisp Edges 416
Working with Axes 417
Working with the Voronoi Map 421
A Basic Voronoi Map 421
Voronoi Point Picking 424
Making Reusable Visualizations 427
Summary 434
INDEX 435
Chapter 1
The World of Data Visualization
What's in This Chapter
- Overview of chart design options
- Comparison of different business applications for data visualization
- Rundown of technological advancements that have made data visualization what it is today
When thinking about data visualization, it's hard to resist the comparison to natural metamorphosis. Consider raw data as the caterpillar: functional, multi-faceted, able to get from here to there, but a little ungainly and really appreciated only by a select few. After data is transformed via visualization, it becomes the butterfly: sleek, agile, and highly recognizable to the point of inspiring and evoking an emotional response. The world of data visualization is an ecosystem unto itself, constantly spawning new nodes of details that-under the proper nourishing conditions-evolve into relatable depictions that consolidate concepts into an understandable, and hopefully compelling, form.
And where does the web professional fit in this metaphor? Why, they are the spinners and caretakers of the cocoon that transforms raw numbers into meaningful representation, of course. Putting the linguistic paraphrasing aside, web designers and developers are a vital component in visualizing data. Naturally, the current and evolving technological landscape has made this role possible-and increasingly efficient.
Overall, JavaScript and jQuery for Data Analysis and Visualization serves as a practical field guide to the robust world of data visualization, from the acquisition and nurturing of data to its transfiguration into the optimal visual format. This chapter is intended to provide an overview of the present environment, highlighting its capabilities and limitations and discussing how you, the web professional, are a key player in visualizing data.
Bringing Numbers to Life
Appreciating numeric data can be a challenge. Data visualization with relational graphics and evocative imagery helps make raw data meaningful. But before you can transform the data into a meaningful representation, you have to get it first.
Acquiring the Data
The data sphere is enormous and growing dramatically, if not exponentially, every day. Data is streaming in from everywhere-and when you consider that the Mars Rover, Curiosity, continually sends its data findings back to Earth, you understand that "everywhere" is no exaggeration.
With the tremendous amount of data already available, its acquisition is often just a matter of logistics. If the information is in a non-digital form-that is, written records-it will need to be transcribed into the proper format. Should the desired data be accessible digitally, it may need to be converted from its current structure to one compatible with the display or visualization application.
When your information is in the proper format, you next need to ensure it is exactly the data you need and nothing more. The wealth of data available today makes targeting your data selection, typically through a process known as filtering, pretty much a requirement in all situations. Even when organizations fine-tune their data input from the beginning, changes in the sample or desired output over time will force a filtering adjustment.
Why is it so important to restrict your data stream? One clear reason is processing efficiency. Working with an overload of unnecessary information increases application execution time-which corresponds directly to increased bandwidth and, thus, costs. Additionally, filtering makes raw data more meaningful. Focused information is easier to analyze and also more easily digested by end users.
Visualizing the Data
In a sense, the most difficult aspect of data visualization is deciding exactly how the information should be depicted. The web designer must select the optimum representation that communicates the data in the clearest, most desired manner with the highest degree of impact. More importantly, the representation should be a discovery tool that leads the user to meaningful insights. Here's an incomplete list of available formats:
-
Area chart
-
Bar chart
-
Bubble chart
-
Candlestick chart
-
Gauge chart
-
Geographic chart
-
Heat map
-
Hierarchical edge bundling
-
Infographics
-
Line chart
-
Marimekko chart
-
Network node map
-
OLHC (Open-high-low-close) chart
We've really just scratched the surface with ways data can be presented. Most of these formats can be shown in either 2D or 3D. You can include interactive elements and animation to add dimensions to the data. But be careful to balance these bells and whistles with meaningful data. No amount of eye candy is worth compromising the representation of information.
NOTE It's important to realize that a key factor in visualization is intent. Raw data on almost every subject can be interpreted in any number of ways. What message is intended to be communicated should be among the first decisions made when beginning the process of representing data visually.
There are other primary options to consider as well. Do you expose the underlying data or not? If so, are the numbers always visible or are they visible only when some interaction occurs, such as when the viewer's mouse hovers over a data point? Is the initial visualization all there, or does the online version allow the user to drill down for more details? Is animation used to represent a dynamic change? Is there other interactivity available, such as horizontal scrolling along a timeline or zooming into it?
Then, of course, there is styling. With simple bar and pie charts, you'll not only need to decide which colors represent which elements, but also the size, color, style, and font to be applied for labels and legends, if any-yet another choice. Many such selections will be governed by other factors, such as the creating organization's branding or in-house standards; however, just as many will have no such foundation to work from, and the designer's vision will become paramount.
Moving beyond the basics of charting primitives, the visualization designer can choose to include graphics. Not only can background images frame a presentation-both literally and thematically-but symbols can be used as data points, like logos pinned in a map of third-quarter sales. An entire field of data visualization-infographics-is devoted to the combination of information and visual imagery.
The truth is that the web professional's current options for depicting data are a bounty of riches. Although the possibilities may appear to be overwhelming, it's up to the visualization designer to identify the optimum representation and bring it into reality.
Simultaneous Acquisition and Visualization
The world of data visualization doesn't just consume existing data: New data is constantly being added to the stores, even in real time. Information can be collected directly through an HTML form on a website and incorporated into the representation programmatically. One of the most common examples of this is an online poll, such as the one shown in Figure 1.1. After a site visitor has chosen his or her desired response and clicked Vote, the current relative standing of all entries, including the one just entered, is displayed.
Figure 1.1 Some polls allow the user to instantly see the current results.
Source: www.dailykos.com/story/2014/08/18/1322337/-Cheers-and-Jeers-Monday
Collecting live data has a number of challenges, but the recent advances made by the widespread acceptance of HTML5 have ameliorated many of them. When combined with a few key JavaScript libraries, it is now possible to use advanced form elements, such as slider controls, across the full spectrum of modern browsers.
Acquiring the data in real time is just the first step. The web developer is also responsible for validating and standardizing the data. Validation is critical in two ways: first, to ensure that all required information is supplied, and second, to verify that the data is in the proper format. Naturally, if you're trying to find out where your clientele is based, you can't if the requested postal code is left blank. Likewise, if the postal code is in the wrong format, such as a four-digit entry for a U.S. address, the data is worthless. Both of these issues can be corrected by proper validation, whether handled on the client-side with JavaScript, server-side via PHP or another server language, or some combination of the two.
Standardized data is just as important and typically applies to time and date details. There are numerous ways to enter a date: March 10, 2011 could be 03/10/11, 10/03/11, or 11/03/10 depending on whether you're in the United States, Australia, or China, respectively. To make sure the intended date is collected correctly, the entered information will need to be standardized to a format the visualization application recognizes before it is saved. Read Chapter 6 for more information about data validation.
Applications of Data Visualization
So there's all this wonderful data out there, just waiting to be brought to life by this almost magical...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.