You must be logged in to post your query.
Home › Forums › Chart Support › Why does my pie chart only shows one data?
Tagged: PieChart
I am new at this. My pie chart only shows the data in the y axis
js file: ` $(document).ready(function(){ var dataPoints = []; var pieGraph = new CanvasJS.Chart(“pieGraph”,{ animationEnabled: true, title:{ text:”Pie Graph” }, data: [{ type: “pie”, dataPoints : dataPoints, }] }); function addData(data) {
dataPoints.push({ x: data.Male, y: parseInt(data.Female) //it only shows this });
pieGraph.render(); } $.getJSON(“localhost:8080/genderRatio”, addData);
});
` Here is my json: ` { “Male”: 5, “Female”: 4 } `
@angelesguerra,
Parsing Male and Female categories to separate dataPoints should work fine in your case. Please take at this JSFiddle.
—- Manoj Mohan Team CanvasJS
Thanks! It worked
You must be logged in to reply to this topic. Login/Register