I am using coldfusion to load data into my pie chart but instead of a pie chart I get a list of 35 datapoints, and no chart displayed.
This is my code:
<script type="text/javascript">
$(document).ready(function () {
$.getJSON("display.cfc?method=getData&lob=all", function (result) {
alert(result);
var chart2 = new CanvasJS.Chart("piechart", {
theme: "theme2",
legend: {
fontSize: 12,
horizontalAlign: "right",
verticalAlign: "center"
},
data: [{
type: "pie",
showInLegend: true,
dataPoints: result
}]
});
chart2.render();
});
});
</script>
<div id="piechart" style="display: inline-block; height: 200px; width: 400px;"></div>
my coldfusion function is returning this:
{y: 142, legendtext: "In Progress"}, {y: 1083, legendtext: "New"},{y: 48, legendtext: "Error"}
This is the function:
<cffunction name="getData" access="remote" returnformat="json">
<cfargument name="lob" type="string" required="yes" />
<cfset var theQuery = getTransitionStatusCounts(#arguments.lob#)>
<cfset var rObj = "">
<cfset var rObjArray = []>
<cfoutput query="theQuery">
<cfset rObj = '{y: #count#, legendtext: "#status#"}'>
<cfset arrayAppend(rObjArray, rObj)>
</cfoutput>
<cfreturn rObjArray>
</cffunction>
Has anyone else had this problem?