I'm trying to chart some data using Google's charting resources. It wants the data in a certain format such as:
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
From what I can tell it wants the first series to contain the 'x' axis followed by any number of items representing the 'y' axis data points.
My data is coming from my back-end as follows:
Update (code to get chart data):
function GetChartData(ni, dn, cn) {
$.ajax({
url: '/Dashboard?handler=QualityTests' + '&NodeId=' + ni + '&DomainName=' + dn + '&ComputerName=' + cn,
success: function (json) {
google.charts.setOnLoadCallback(drawChart(json))
}
})
}
I want to plot just the averageJitterInMs for the 'x' axis and dateTime for the 'y' axis for now (I'll eventually use the rest of the data elsewhere on the page; possibly for other charts).
So is there an elegant way to pull just these values from my array (of potentially hundreds of array items) so it can feed the Google chart data requirements? By this I mean how do I get my two key/value pairs out of a JavaScript array so I can put it in the right format the charting resource wants (see the attached image)?
I've tried looping the array on the client side to pull out these two key/value pairs however the Google charting api is giving me an error:
Not an array
Is this even necessary or can I somehow grab the key/value pairs programmatically to feed the arrayToDataTable method?

myArray[0]. Show us the code you are trying to useNot an arrayit's an object, you have to either loop through it's valuesObject.valuesor convert it to and array