0

i am using pie chart of highcharts and i am not able to popluate dynamic data. Here is static form pie chart view enter image description here

and code for above graph is

Highcharts.setOptions({
                colors: projectColor.split(','),
            });

            Highcharts.chart('myChartStatics', {
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: 0,
                plotShadow: false,
                type: 'pie',
            },
            title: {
                text: ''
            },
            navigation: {
                buttonOptions: {
                    enabled: false
                }
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
            },
            accessibility: {
                point: {
                    valueSuffix: '%'
                }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                    },
                }
            },
            series: [{
                type: 'pie',
                innerSize: '60%',
                name: 'Tasks',
                colorByPoint: true,
                data: [
                    [
                    "Inbox", 12
                    ],  
                    [
                    "Usage Guidance", 12
                    ],  
                    [
                    "Jobeegoo", 12
                    ],  
                ]
            }]
        });

now i want to add data array dynmaic on ajax call i am tried but it does not show graph

projectName = projectName.split(',')
totalTask = totalTask.split(',')

var loop = [];

for(var x = 0; x < projectName.length; x++){
loop.push([projectName[x] , parseInt(totalTask[x])]);
}
            
var data_value = JSON.stringify(loop);
console.log(data_value)

and console disply

[["inbox",128],["Usage Guidance",116],["FocusChain",0]]

tell me where i am wrong

Irshad Khan
  • 434
  • 4
  • 13
  • You might find [this](https://stackoverflow.com/questions/21152885/changing-data-dynamically-for-a-series-in-highcharts) helpful. Once you've initialised your chart, you'll want to set the series data `series.setData()`, using your `data_value` variable. – ChewySalmon Aug 03 '20 at 05:20
  • 1
    Thanks i have solved by making json object and pass it to series data – Irshad Khan Aug 11 '20 at 04:40

0 Answers0