In this chapter, you learned about two different XHR techniques to load external data for the visualization: d3.xhr
with D3.js and $http
with AngularJS. If we include an already existing chart application in the AngularJS application, we can wrap the D3.js loading component into a service. In order to test this component, we need to write asynchronous unit tests.
If we write the visualization from scratch, we'd better implement the data loading technique with the $http
module of Angular JS. This allows you to mock the behavior of $httpBackend
and automatically serve data for specified routes. With this method, we can continue to write synchronous tests, which are more readable and expressive.
In the second part of this chapter, we parsed a string of log entries into an array of JavaScript objects. In addition to the parser service, we implemented a grouping service based on the d3.nest()
function. In the end, we brought all the parts together and plotted an aggregated view of the log...