Book Image

Data Visualization with D3 and AngularJS

By : Erik Hanchett, Christoph Körner
Book Image

Data Visualization with D3 and AngularJS

By: Erik Hanchett, Christoph Körner

Overview of this book

Table of Contents (16 chapters)
Data Visualization with D3 and AngularJS
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Loading external data


In a modern web application, it's a common task to load and reload data from external resources, regardless of whether we read from the database or plain text files. Thus, nearly every JavaScript framework includes its own functions to load external data, that is, in most of the cases a wrapper of the native XMLHttpRequest (XHR) object. In our application setup, we have the following options to load external data:

  • XMLHttpRequest: This is a native XHR object provided by most modern browsers

  • d3.xhr(): This is a wrapper function for the XMLHttpRequest object in D3.js

  • $http: This is an Angular wrapper module for the XMLHttpRequest object

These implementations use the unidirectional XMLHttpRequest to request data from a web server. Unidirectional means that we can solely request data from the client and then wait for the response of the server. Thus, we also don't know if there is new data available on the server. If we want a "real-time-like" behavior, we will need to continuously...