This took me waaaaaay longer than I wanted it to, so I’m making a point of posting it.
In order to take an API call to Piwik and use the returned JSON to generate a custom graph with jqPlot, do this:
$.getJSON(url, function(data) {
var i = 0;
var line1 = new Array();
$.each(dates, function(x, y) {
line1[i] = [x,y];
i++;
});
$.jqplot("chartdiv", [line1],
{
// the rest of your jqPlot options
});
});
The part that took me a while to wrap my head around was that jqPlot requires an array of arrays for the data points. Hopefully this is helpful to whomever finds it.





