I wanted to create this kind of output
var s1 = [['Sony',7],['Samsung',5],['LG',8]];
so that I could use it to pass on my graph as a variable
out from the result of my ajax
success: function(data){
//code to extract the data value here
var s1= need to create the data here
$.jqplot('chart',[s1],{ blah blah blah
}
"data" in the success function returns this table layout
<table id="tblResult">
<tr class="tblRows">
<td class="clsPhone">Sony</td><td class="clsRating">7</td>
</tr>
<tr class="tblRows">
<td class="clsPhone">Samsung</td><td class="clsRating">5</td>
</tr>
<tr class="tblRows">
<td class="clsPhone">LG</td><td class="clsRating">8</td>
</tr>
</table>
can you please help me create the logic for this?
Thanks in advance
EDIT: I'm looking for a solution something like the following:
var s1;
$(".tblRows").each(function(){
// here I don't know exactly on what to do
//s1.push($(".clsPhone").text(),$(".clsRating").text()));
});
// all I wanted is to make the resul s1=[['Sony',7],['Samsung',5],['LG',8]];
because jqplot requires this kind of parameter
s1=[['Sony',7],['Samsung',5],['LG',8]];
$.jqplot('chart',[s1],{
renderer:$.jqplot.PieRenderer,
rendererOptions:{
showDataLabels:true,
dataLabelThreshold:1
}
}
});
so I'm looking for a way to create a the value for the variable s1 out from the data could this be possible?
var s1 = [];
$(".tblRows").each(function(){
// create a temp array for this row
var row = [];
// add the phone and rating as array elements
row.push($(this).find('.clsPhone').text());
row.push($(this).find('.clsRating').text());
// add the temp array to the main array
s1.push(row);
});