未捕获的TypeError:无法读取未定义的属性'0' - highcharts

时间:2013-08-17 11:49:23

标签: javascript highcharts

我正在尝试绘制HighCharts - Polar wind Rose Chart

参考:http://www.highcharts.com/demo/polar-wind-rose

但是当我检查我的chrome的控制台时,图表没有得到绘图我发现了这个错误 未捕获的TypeError:无法读取未定义的属性“0”

无法理解为什么会这样

我的JS代码:

function createWindRoseChart(divID, tableID, graphTitle) {
    var chart = new Highcharts.Chart({
        data: {
            table: tableID,
            startRow: 1,
            endRow: 10,
            endColumn: 8
        },
        chart: {
            polar: true,
            type: 'column',
            renderTo: divID,
            backgroundColor: 'rgba(255, 255, 255, 0.1)'
        },

        title: {
            text: graphTitle
        },

        subtitle: {

        },

        pane: {
            size: '85%'
        },

        legend: {
            reversed: true,
            align: 'right',
            verticalAlign: 'top',
            y: 100,
            layout: 'vertical'
        },

        xAxis: {
            tickmarkPlacement: 'on'
        },

        yAxis: {
            min: 0,
            endOnTick: false,
            showLastLabel: true,
            title: {
                text: 'Frequency (%)'
            },
            labels: {
                formatter: function () {
                    return this.value + '%';
                }
            }
        },

        tooltip: {
            valueSuffix: '%',
            followPointer: true
        },

        plotOptions: {
            series: {
                stacking: 'normal',
                shadow: false,
                groupPadding: 0,
                pointPlacement: 'on'
            }
        }
    });
}

其通话功能

createWindRoseChart('divCRATicketType', 'freq', 'Calls Open');

用于创建风玫瑰图表的HTML表格

<html>
    <body>
        <table id='freq' border='1' cellpadding='5' align='center'>
            <tr align='center'><th class='freq'>CRA</th><th class='freq'>FLM</th><th class='freq'>SLM</th><th class='freq'>Network</th><th class='freq'>UPS</th><th class='freq'>Electrical</th><th class='freq'>Power Failure</th><th class='freq'>Bank</th><th class='freq'>Cashout</th></tr>
            <tr align='center'><td class='dir'>SIS</td><td class='data'>2</td><td class='data'>1</td><td class='data'>0</td><td class='data'>0</td><td class='data'>0</td><td class='data'>1</td><td class='data'>0</td><td class='data'>0</td></tr>
            <tr align='center'><td class='dir'>S&IB</td><td class='data'>2</td><td class='data'>0</td><td class='data'>0</td><td class='data'>0</td><td class='data'>0</td><td class='data'>0</td><td class='data'>0</td><td class='data'>0</td></tr>
            <tr align='center'><td class='dir'>Branch</td><td class='data'>1</td><td class='data'>1</td><td class='data'>0</td><td class='data'>0</td><td class='data'>0</td><td class='data'>0</td><td class='data'>0</td><td class='data'>0</td></tr>
            <tr align='center'><td class='dir'>Securitrans</td><td class='data'>45</td><td class='data'>13</td><td class='data'>4</td><td class='data'>1</td><td class='data'>6</td><td class='data'>4</td><td class='data'>1</td><td class='data'>0</td></tr>
            <tr align='center'><td class='dir'>Writer</td><td class='data'>33</td><td class='data'>8</td><td class='data'>5</td><td class='data'>0</td><td class='data'>4</td><td class='data'>0</td><td class='data'>4</td><td class='data'>1</td></tr>
            <tr align='center'><td class='dir'>CMS</td><td class='data'>86</td><td class='data'>23</td><td class='data'>6</td><td class='data'>12</td><td class='data'>5</td><td class='data'>13</td><td class='data'>4</td><td class='data'>7</td></tr>
            <tr align='center'><td class='dir'>SDB CISCO</td><td class='data'>20</td><td class='data'>5</td><td class='data'>1</td><td class='data'>0</td><td class='data'>3</td><td class='data'>6</td><td class='data'>3</td><td class='data'>1</td></tr>
            <tr align='center'><td class='dir'>Brinks</td><td class='data'>27</td><td class='data'>5</td><td class='data'>2</td><td class='data'>2</td><td class='data'>0</td><td class='data'>0</td><td class='data'>7</td><td class='data'>1</td></tr>
            <tr align='center'><td class='dir'>Secure Value</td><td class='data'>30</td><td class='data'>8</td><td class='data'>1</td><td class='data'>1</td><td class='data'>2</td><td class='data'>3</td><td class='data'>7</td><td class='data'>0</td></tr>
        </table>
    </body>
</html>

1 个答案:

答案 0 :(得分:1)

这是一张包含您数据的正确polar图表:

enter image description here

小提琴示例here