i want to set dataset value dynamically of chart.js to create a bar graph which i am trying to do with the following code
getmths();
mthlen=marr.length;
xdistid=$('#mdistid').val();
mdistid=xdistid.split(',');
mdilen=mdistid.length;
var distdata=[];
for(i=0;i<mdilen;i++)
{
glc=mdistid[i];
for(j=0;j<mthlen;j++)
{
mth=marr[j];
switch(mth)
{
case '1':
distdata[j]=$('#qty1'+glc).val();
break;
case '2':
distdata[j]=$('#qty2'+glc).val();
break;
case '3':
distdata[j]=$('#qty3'+glc).val();
break;
case '4':
distdata[j]=$('#qty4'+glc).val();
break;
case '5':
distdata[j]=$('#qty5'+glc).val();
break;
case '6':
distdata[j]=$('#qty6'+glc).val();
break;
case '7':
distdata[j]=$('#qty7'+glc).val();
break;
case '8':
distdata[j]=$('#qty8'+glc).val();
break;
case '9':
distdata[j]=$('#qty9'+glc).val();
break;
case '10':
distdata[j]=$('#qty10'+glc).val();
break;
case '11':
distdata[j]=$('#qty11'+glc).val();
break;
case '12':
distdata[j]=$('#qty12'+glc).val();
break;
}
}
//Month Loop Ends here;
alert("Distributor data:"+distdata);
if(i==0)
{
datasetValue[0]=
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,0.8)",
highlightFill: "rgba(151,187,205,0.75)",
highlightStroke: "rgba(151,187,205,1)",
data: distdata
};
}
if(i==1)
{
datasetValue[1]=
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,0.8)",
highlightFill: "rgba(151,187,205,0.75)",
highlightStroke: "rgba(151,187,205,1)",
data: distdata
};
}
}
//Distributor Loop Ends here;
alert("Datasets: "+datasetValue[0].data);
alert(datasetValue.length);
mkchart();
mklinechart();
my problem is that after the loop finishes when i am checking the value of datasetValue[0].data i am getting the same value which sholud be of datasetValue[1].data please help me with this problem.........Thanks in advance