var employees = $("#employees").val();
//var fairs = $("#fairs").val();
$.ajax({
url : 'php_script/chart_values.php',
method : 'POST',
data : {employees:employees},
success : function(data){
$("#page_content").fadeIn();
$("#bar_chart_div").fadeOut();
var obj = JSON.parse(data);
var a = obj[0]; // labele data "Won","Contracted","Intersted"
var b = obj[1]; // label values "100","90","70"
var labeldata=[];
for( i=0; i<a.length;i++){
labeldata.push({label:a[i],y:parseInt(b[i]),legendText:a[i]});
}
debugger;
console.log(JSON.stringify(labeldata));
var chart = new CanvasJS.Chart("chartContainer", {
title: {
fontSize:15
},
axisY: {
title: "Products in %"
},
legend :{
verticalAlign: "center",
horizontalAlign: "right"
},
data: [{
type: "pie",
showInLegend: true,
toolTipContent: "{label} <br/> {y} ",
indexLabel: "{y} %",
dataPoints: labeldata
}]
});
chart.render();
}
});
});