You must be logged in to post your query.
Home › Forums › Chart Support › Unable to get pass the variable values into graph
Tagged: html, jquery, JSON, parameter variable
Team, I am using the jquery to manipulate the json.
Once i got the data from json like regress_opendefect=5, regress_inprogressdefect=3,regress_resolveddefect=6. I am passing the values inside the chart. but the values are “0” always. Please find the highlighted and help me
<!DOCTYPE HTML>
<html>
<head title=”Autodesk Dashboard”>
<script type=”text/javascript” src=”canvasjs.min.js”></script>
<script type = “text/javascript”
src = “https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js”></script>
<script type=”text/javascript”>
window.onload = function () {
var regress_opendefect=0;
var regress_closeddefect=0;
var regress_inprogressdefect=0;
var regress_resolveddefect=0;
var regress_reopeneddefect=0;
var bic_opendefect=0;
var bic_closeddefect=0;
var bic_inprogressdefect=0;
var bic_resolveddefect=0;
var bic_reopeneddefect=0;
var ddws_opendefect=0;
var ddws_closeddefect=0;
var ddws_inprogressdefect=0;
var ddws_resolveddefect=0;
var ddws_reopeneddefect=0;
var portal_opendefect=0;
var portal_closeddefect=0;
var portal_inprogressdefect=0;
var portal_resolveddefect=0;
var portal_reopeneddefect=0;
var openStatus=”Open”;
var resolvedStatus=”Resolved”;
var inprogresStatus=”In Progress”;
var closedStatus=”Closed”;
var reopenedStatus=”Reopened”;
$(“#driver”).click(function(event){
$.getJSON(‘EIS-QA-Bug.json’, function(jd) {
$.each(jd,function(i,tweet) {
if(i==”issues”) {
$.each(tweet, function(k1, v1) {
if(v1.fields.components.length!=0) {
$.each(v1.fields.components, function(s1, j1) {
$.each(j1, function(k1, g1) {
if(k1==”name”){
if(g1==”Regression-BFR”){
if(v1.fields.status.name==openStatus){ regress_opendefect+=1;
}else if(v1.fields.status.name==resolvedStatus){regress_resolveddefect+=1;
}else if(v1.fields.status.name==inprogresStatus){regress_inprogressdefect+=1;
}else if(v1.fields.status.name==closedStatus){regress_closeddefect+=1;
}else if(v1.fields.status.name==reopenedStatus){regress_reopeneddefect+=1;}
}else if(g1==”BIC”){
if(v1.fields.status.name==openStatus){ bic_opendefect+=1;
}else if(v1.fields.status.name==resolvedStatus){bic_resolveddefect+=1;
}else if(v1.fields.status.name==inprogresStatus){bic_inprogressdefect+=1;
}else if(v1.fields.status.name==closedStatus){bic_closeddefect+=1;
}else if(v1.fields.status.name==reopenedStatus){bic_reopeneddefect+=1;}
}else if(g1==”DDWS”){
if(v1.fields.status.name==openStatus){ ddws_opendefect+=1;
}else if(v1.fields.status.name==resolvedStatus){ddws_resolveddefect+=1;
}else if(v1.fields.status.name==inprogresStatus){ddws_inprogressdefect+=1;
}else if(v1.fields.status.name==closedStatus){ddws_closeddefect+=1;
}else if(v1.fields.status.name==reopenedStatus){ddws_reopeneddefect+=1;}
}else if(g1==”Portal(IAE/GCE)”){
if(v1.fields.status.name==openStatus){ portal_opendefect+=1;
}else if(v1.fields.status.name==resolvedStatus){portal_resolveddefect+=1;
}else if(v1.fields.status.name==inprogresStatus){portal_inprogressdefect+=1;
}else if(v1.fields.status.name==closedStatus){portal_closeddefect+=1;
}else if(v1.fields.status.name==reopenedStatus){portal_reopeneddefect+=1;}
}
}
});
});
}
});
}
});
alert(‘No of regress open=’+regress_opendefect+’ No of Resolved=’+regress_resolveddefect +’ No of inprogress=’+ regress_inprogressdefect+’ No of Closed=’+ regress_closeddefect +’No of reopened=’+ regress_reopeneddefect);
var chart1 = new CanvasJS.Chart(“chartContainer2”,
{
animationEnabled: true,
title: {
text: “Overall Defect Summary”,
},
data: [
{
type: “pie”,
showInLegend: true,
dataPoints: [
{ y: regress_opendefect, legendText: “Open”, indexLabel: “Open” },
{ y: regress_inprogressdefect, legendText: “In Progress”, indexLabel: “In Progress” },
{ y: regress_resolveddefect, legendText: “Resolved”, indexLabel: “Resolved/Closed” },
{ y: regress_reopeneddefect, legendText: “ReOpened”, indexLabel: “ReOpened” },
]
},
]
});
chart1.render();
});
});
}
</script>
</head>
<body width=”70%”>
<input type = “button” id = “driver” value = “Pull Overall Defect Data” />
<div id=”chartContainer1″ style=”width: 550px; height: 320px;float:left;”></div>
<div id=”chartContainer2″ style=”width: 550px; height: 300px;”></div> </br>
<div id=”chartContainer3″ style=”width: 550px; height: 320px; align:centre”></div>
</body>
</html>
Seems like your JSON is not matching with your code. Can you kindly create a jsfiddle with your sample JSON so that we can look into it ? Also please have a look at this example on creating chart from external JSON.
___
Suyash Singh
Team CanvasJS
Tagged: html, jquery, JSON, parameter variable
You must be logged in to reply to this topic.