I am looking for the best practices (good practice) placement for the 
following code.

I have a Rails endpoint that currently gives back json objects like [{data: 
"A", date: "2014-01-02T14:42:01-08:00"}, {data: "B", date: 
"2014-01-03T14:42:01-08:00"}, {data: "C", date: 
"2014-01-03T14:42:01-08:00"}].  I am using 
highcharts<http://www.highcharts.com/>and 
highcharts-ng  <https://github.com/pablojim/highcharts-ng>to display this 
data in bar charts based on the date.  So I'll need this data to be 
formatted in a way that counts the number of objects in the array by date, 
like [{name: 'Jan 2nd', y: 1}, {name: 'Jan 3rd', y: 2}], and this will be 
defined to the scope in the angular controller.  If I was just using a 
filter in the template I could do something simple like "(json_array | 
filter:{date:<date>}).length" to display the amount of objects for each 
date. 

Where would be the best place and setup to do the filtering?  Changing the 
rails endpoint to allow queries is an option, but only if that is really 
the best option (there will be other examples of filtered data that will be 
given to highcharts needed besides just date). I was thinking something 
like a service, which just returns the array with the out of range dates 
rejected?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to