Tuesday, January 20th 2015
I'm building out this feature to display a basic graph of page views on my blog using google analytics. I'm totally open to redesigning how the data is being delivered if anyone has suggestions. What I really want is the correct way to do this :)
Here is the current running branch on GitHub. The code as of right now is using Rails to consume the google analytics API. Then in the index controller action I run a method that formats the data in columns for C3.js. The data looks like this:
{
"analytics": [
["date","2015-01-01","2015-01-02","2015-01-03","2015-01-04","2015-01-05","2015-01-06","2015-01-07","2015-01-08","2015-01-09","2015-01-10","2015-01-11","2015-01-12","2015-01-13","2015-01-14","2015-01-15","2015-01-16"],
["Pageviews",10,11,5,10,13,13,7,12,14,59,135,44,22,10,13,16]
]
}
In Ember land I pull the data by doing getJSON
, but I want to use ember data so I can pass my auth token and secure my API. So instead I could do something like this.store.find("analytics");
. Does anyone have suggestions? Basically I want to give the C3.js charts data using ember data.