Harish Batchu

Harish Batchu

  • NA
  • 255
  • 64.9k

When Parsing the data into pie chart i am getting last row?

Nov 2 2018 1:03 PM
I am reading the data from database and ploat into piechart. But i have an issue when ploating the data into the pie chart. I am getting only last value. I don't know how to do it.
 
I am put code below. 
 
function OnSuccess(response) {
// var table = $("#dvCustomers table").eq(0).clone(true);
console.log(response);
var customers = response.d;
var arr = [];
var arr1 = [];
var inval = "";
var ic = "";
var data = {};
var i = 0;
//var fruits = new Array();
$(customers).each(function () {
data['value'] = this.IncomeAmount;
data['name']= this.IncomeType;
i++;
ic += "'" + getRandomColor() + "',";
});
 
When return sucess am put database code into data array here each time new value is assign the new when loop ends the last value only place in their. 
 
 
series: [
{
name: 'Month Income',
type: 'pie',
radius: '80%',
center: ['50%', '50%'],
roseType: 'radius',
color: [ic],
label: {
normal: {
fontFamily: 'Poppins, sans-serif',
fontSize: 12
}
},
data: [
data
].sort(function (a, b) { return a.value - b.value; }),
 
 
In above code the data variable have only last value i need all rows of data.  i am getting only last row of data
 
 
please fix it... 
 

Answers (4)