A chart directive
Next, we want to create a reusable and testable chart directive. The first question that comes into one's mind is where to put which functionality? Should we create a
svg element as parent for the directive or a
div element? Should we draw a data point as a circle in
svg and use
ng-repeat to replicate these points in the chart? Or should we better create and modify all data points with D3.js? I will answer all these question in the following sections.
A directive for SVG
As a general rule, we can say that different concepts should be encapsulated so that they can be replaced anytime by a new technology. Hence, we will use AngularJS with an element directive as a parent element for the visualization. We will bind the data and the ...