Home Forums Chart Support Why does my pie chart only shows one data?

Why does my pie chart only shows one data?

Viewing 3 posts - 1 through 3 (of 3 total)
  • #31735

    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
    }
    `

    #31750

    @angelesguerra,

    Parsing Male and Female categories to separate dataPoints should work fine in your case. Please take at this JSFiddle.

    —-
    Manoj Mohan
    Team CanvasJS

    #31774

    Thanks! It worked

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.