Aslam H
Aslam H

Reputation: 1801

Highcharts series doesnt show data and render the chart

I've got the following array which I want to use for draw pie chart with highchairs

enter image description here

and this is my code

var dataChart = [];
    function getData() 
    {
        return $.get('/report/charts-top-10-claimant')
        .done(function(data) {
            for (var i=0; i<data.length; i++) {
                dataChart.push(data[i]);
            }
        });
    }

    getData();

    $(function() {

            console.log(dataChart);

        $('#test').highcharts({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                type: 'pie'
            },
            title: {
                text: ''
            },
            tooltip: {
                pointFormat: '{point.y} <b>({point.percentage:.1f}%)</strong>'
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        format: '<b>{point.name}</strong>: {point.y} ({point.percentage:.1f}%)',
                        style: {
                            color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                        }
                    }
                }
            },
            series: [{
                colorByPoint: true,
                data: []
            }]
        });



        $('#claimant-by-amount').on('click', function(e) {

            var chart = $('#test').highcharts();
            chart.series[0].setData(dataChart);
        });
});

After loading the page and checking the error console saying "Uncaught Highcharts error #14: www.highcharts.com/errors/14 ". What am doing wrong, please help me out

Upvotes: 1

Views: 55

Answers (1)

Vladimir M
Vladimir M

Reputation: 4489

If you click on the error in console it should redirect you to:

https://www.highcharts.com/errors/14

Which clearly states what is the problem.

Your y-values are strings when numbers are expected.

Upvotes: 1

Related Questions