Search code examples
javascriptjquerytwitter-bootstrap-3chartsflot

Flot pie chart Invalid dimensions for plot, width = null, height = null


I'm getting this error when I trying to use pie chart with tabs.How can I solve it ?

var arr = JSON.parse('{!! json_encode($array) !!}');



var pieChartData = [], pieChartSeries = arr;
    var pieChartColors = ['#E91E63', '#03A9F4', '#FFC107', '#009688'];

    $.plot('#pie_chart[0]', pieChartData, {
        series: {
            pie: {
                show: true,
                radius: 1,
                label: {
                    show: true,
                    radius: 3 / 4,
                    formatter: labelFormatter,
                    background: {
                        opacity: 0.5
                    }
                }
            }
        },
        legend: {
            show: false
        }
    });

I gave style to div but it didn't worked.Also It's working when I use pie chart without tabs.

Also I tried to run this code after page load and document ready but not worked either.

<div id="pie_chart[0]" class="flot-chart"></div>

Also I gave style to div element too. but it not working.


Solution

  • Okay I solved problem.

    Problem is I was giving id's with [] I deleted [] and used id like = chart_12 and its solved.