简体   繁体   中英

Pie Chart is not coming with dynamic data in HIghChart

I am making a pie chart with json data but pie chart is not coming with data backend data.I am generating the data with this format which is actually the format given by HighCharts.I am pasting my code

function createChart(array){
//alert(array);
 var arrJobName = [];
var arrRevenue = [];

for(var i=0; i<array.length; i++){
    searchResultArray = array[i].split("$$##$$##");   

    //var label = '\''+ searchResultArray[1]+ '\'';
    //var value = parseInt(searchResultArray[5]);

    //arrJobName.push(searchResultArray[1]);
    //arrRevenue.push(parseInt(searchResultArray[5]));
    //alert(parseFloat(searchResultArray[5]))
    // arrRevenue.push(['\''+ searchResultArray[1]+ '\'',""(parseFloat(searchResultArray[5]))]);

    arrRevenue.push('['+searchResultArray[1]+","+parseFloat(searchResultArray[5])+']');

}

alert(arrRevenue)
//

$(function () {
    $('.containerForDiagram').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: 'Browser market shares at a specific website, 2014'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                }
            }
        },
        series: [{
            type: 'pie',
            name: 'Job By Revenue',
            data: [

                    [arrRevenue]
//['Director - Inventory/Planning Systems',36800],['DevOps Engineer',20000],   ['Java Developer',0],['Software Development Manager',0],['Sr. Business Analyst / Oracle Functional',0],['Product Manager Native Advertising',0],['Corporate Recruiter ',26000],['Sr. Oracle Supply Chain BA',0],['Network Engineer',0],['Sharepoint Programmer Analyst',0],['Commercial Manager -  Mexico',0],['Commercial Manager Colombia',0],['Sr. Global Architect - End User Computing',29900],['Head of Marketing   Peru',0],['Director, Sr Attorney',0]

this is the data i am getting with my code                  ]


        }]
    });
});

}

The data i am getting for the arrRevenue is given here.But the arrRevenue is not working when i am using it dynamically.I have tried all syntax.But no use still .Somebody please help.

The problem is with generating data. Required are two changes:

  • data assignment: data: [arrRevenue] -> data: arrRevenue
  • data generation: arrRevenue.push('['+searchResultArray[1]+","+parseFloat(searchResultArray[5])+']'); -> arrRevenue.push( [ searchResultArray[1], parseFloat(searchResultArray[5]) ] );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM