Column Highchart Uncaught TypeError:无法读取骨干中未定义的属性“0”

时间:2016-01-07 06:17:14

标签: backbone.js highcharts

我想加载并在backboneJS视图上创建高图表。但它显示无法读取未定义的属性'0'。

骨干

var ReportSalesAnalyticsView = Backbone.View.extend({
           chart : null,
        // target item.
        el : $("#merchantCntPanel"),
        render : function() {
            var data = {};
            chart = null;
            // template
            var compiledTemplate = _.template(reportSalesAnalyticsTemplate, data);
            // append the item to the view's target
            this.$el.html(compiledTemplate);
             chart = $('.chartContainer').highcharts({
                    chart: {
                        type: 'column'
                    },
                    xAxis: {
                        type: 'Month'
                    },
                    yAxis: {
                        title: {
                            text: 'Total Amount'
                        }
                    },
                    legend: {
                        enabled: false
                    },
                    plotOptions: {
                        series: {
                            borderWidth: 0,
                            dataLabels: {
                                enabled: true,
                                format: '{point.y:.1f}%'
                            }
                        }
                    },
                    tooltip: {
                        headerFormat: '<span style="font-size:11px">{series.name}</span><br/>',
                        pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
                    },
                    series: [{
                        data: [{
                             name: "vjvbj",
                             y: 30,
                             drilldown: "vtguvh"
                        }]
                    }],
                });
        },
        // Event Handlers
        events : {
            'click #btnGraph':'btnGraph'
        },
        btnGraph: function(){
            chart.series[0].setData([50,60]);
        },
        });
    return new ReportSalesAnalyticsView;
});

HTML内容

<button id="btnGraph">Load</button>
<div class="chartContainer"style="height: 300px; width: 100%;"></div>

0 个答案:

没有答案