Here is my situation: I'd like to draw two representations of a set of data, a line chart, and a pie chart. The pie chart can reflect the line chart, but the data has to be processed into a pie chart format first.
My controller has the lineData and pieData
My line chart directive draws the line chart and has a button on it to add data. It also watches the the data and updates accordingly. The data is passed to it with 2-way binding so whenever I press this button the data on the controller is updated as well.
What I'd like to do is set a watch on the controller. When it sees that the data has been updated by a directive, it should process/change the data for the pie chart. The pie chart should update automatically like the line chart. The pie chart updating is straightforward.
The issue is I am creating a lot of these line/pie pairs and I'm not sure how to set the watch statement on the controller. If I have a data set of [A,B,C] (3 pairs of graphs) I'd have to loop through and attach a watch statement to watch each of A,B, and C. (If I set the watch statement on the entire array, is there a way for it to know which of A,B, or C changed?) This seems kind of messy though so I just wanted a second opinion and how I should do this or if the entire process can be done in a more simple way.
Currently the changes to the data happens within the line chart directive, propagate up into the controller where it is processed, and then transmitted into the pie chart directive.