clintnash
asked on
Accessing data in JSON response.d multiple objects
I am trying to populate a chart with data retrieved from SQL. Using the following code I am able to access the first object d(0)
This all works for the first row (object) but I realized I have no idea how to get the additional rows and all attempts have failed.
The objects includes 7 rows (one for each day of the week). My working example above shows Monday.
Any help or advise is greatly appreciated.
This all works for the first row (object) but I realized I have no idea how to get the additional rows and all attempts have failed.
function OnSuccess(response) {
var weekDay = response.d[0].DayofWeek;
var sName = response.d[0].ShortName;
var loutput = response.d[0].List_Output;
//roated chart
c3.generate({
bindto: '#roated-chart',
data: {
columns: [
['Weekday', loutput]
],
names: {
Weekday: 'Requested Practice',
data2: 'Data Name 2',
},
types: {
Weekday: 'bar',
labels: true
},
colors: {
Weekday: '#0b62a4'
},
},
axis: {
rotated: true,
x: {
type: 'categorized',
categories: [sName]
}
}
});
};
The objects includes 7 rows (one for each day of the week). My working example above shows Monday.
Any help or advise is greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<code> for (var i=0; i<response.d.length; i++) {
sName.push(response.d[i].S
loutput.push(response.d[i]
}
</code>
Thanks again!!!