Bootstrap导致javascript错误?

时间:2015-02-24 22:52:44

标签: javascript jquery html twitter-bootstrap highcharts

我正在使用具有单侧边栏的引导程序模板。我试图在此模板的初始索引页面上放置一个高图,但显然该模板导致问题并使我的图表根本不显示

带有代码的模板位于http://pastebin.com/wBvdG2J1(出于某种原因,我无法将其格式化为帖子,因此我会留在那里)。

起初我以为这是我的javascript,但后来我只尝试了它并按预期执行

 <div id="container" class="resize" style=" width: 100%; height: 100%; margin: 0 auto "></div>

        <label for="numberInput">Enter Number Code:</label><input type="text" id="numberInput" />
        <input type="button" value="Enter" id="enter"/>

        <script>
        $(document).ready(function() {

        $('#enter').click(function() {

            sgaxml = "https://sga.quickbase.com/db/bjmdensiu?apptoken=beadyrucxguavbx5isubd6iaqpe&act=API_DoQuery&query={14.EX." + $("#numberInput").val() + "}&clist=7.24.25.26.27.28.29.30.31.32.33.34.35.36.37";

            console.log(sgaxml);

            // Load the data from the XML file 
                $.get(sgaxml, function(xml) {

                // Split the lines
                var xml = $(xml).find('record');

                var options = {
                        chart: {
                        renderTo: 'container',
                type: 'column'
                    },
                    title: {
                        text: 'Components Over Time'
                 },
                    xAxis: {
                        categories: []
                },
                    yAxis: {
                         title: {
                     text: 'Concentration%'
            }
        },
        series: []
    };


// Variables for the component series

var seriesH = {
        name: 'Hydrogen',
        data: []
    };

     var seriesHe = {
        name: 'Helium',
        data: []
    };

var seriesO = {
        name: 'Oxygen',
        data: []
    };

var seriesHs = {
        name: 'Hydrogen Sulfide',
        data: []
    };

var seriesN = {
        name: 'Nitrogen',
        data: []
    };

var seriesC = {
        name: 'Carbon Dioxide',
        data: []
    };

var seriesM = {
        name: 'Methane',
        data: []
    };

var seriesE = {
        name: 'Ethane',
        data: []
    };

var seriesP = {
        name: 'Propane',
        data: []
    };

var seriesIb = {
        name: 'Iso-Butane',
        data: []
    };

var seriesNb = {
        name: 'N-Butane',
        data: []
    };

var seriesIp = {
        name: 'Iso-Pentane',
        data: []
    };

var seriesNp = {
        name: 'N-Pentane',
        data: []
    };

var seriesHex = {
        name: 'Hexanes+',
        data: []
    };

xml.each(function (i, record) {
        options.xAxis.categories.push(new Date(parseInt($(record).find('sample_date').text())));
    seriesH.data.push(parseFloat($(record).find('hydrogen').text()));
    seriesHe.data.push(parseFloat($(record).find('helium').text()));
    seriesO.data.push(parseFloat($(record).find('oxygen').text()));
    seriesHs.data.push(parseFloat($(record).find('hydrogen_sulfide').text()));
    seriesN.data.push(parseFloat($(record).find('nitrogen').text()));
    seriesC.data.push(parseFloat($(record).find('co2').text()));
        seriesM.data.push(parseFloat($(record).find('methane').text()));
        seriesE.data.push(parseFloat($(record).find('ethane').text()));
    seriesP.data.push(parseFloat($(record).find('propane').text()));
    seriesIb.data.push(parseFloat($(record).find('iso_butane').text()));
    seriesNb.data.push(parseFloat($(record).find('n_butane').text()));
    seriesIp.data.push(parseFloat($(record).find('iso_pentane').text()));
    seriesNp.data.push(parseFloat($(record).find('n_pentane').text()));
    seriesHex.data.push(parseFloat($(record).find('hexanes_').text()));
    });

console.log(seriesO.data);  

if($.isNumeric(seriesH.data[0])){options.series.push(seriesH)};
if($.isNumeric(seriesHe.data[0])){options.series.push(seriesHe)};
if($.isNumeric(seriesO.data[0])){options.series.push(seriesO)};
if($.isNumeric(seriesHs.data[0])){options.series.push(seriesHs)};
if($.isNumeric(seriesN.data[0])){options.series.push(seriesN)};
if($.isNumeric(seriesC.data[0])){options.series.push(seriesC)};
if($.isNumeric(seriesM.data[0])){options.series.push(seriesM)};
if($.isNumeric(seriesE.data[0])){options.series.push(seriesE)};
if($.isNumeric(seriesP.data[0])){options.series.push(seriesP)};
    if($.isNumeric(seriesIb.data[0])){options.series.push(seriesIb)};
if($.isNumeric(seriesNb.data[0])){options.series.push(seriesNb)};
if($.isNumeric(seriesIp.data[0])){options.series.push(seriesIp)};
if($.isNumeric(seriesNp.data[0])){options.series.push(seriesNp)};
if($.isNumeric(seriesHex.data[0])){options.series.push(seriesHex)};
    console.log('options: ', options);

        var chart = new Highcharts.Chart(options);
});

});                          

});

我检查了控制台并注意到当我使用模板运行代码时,我得到了

  

未捕获的TypeError:无法读取属性&#39; addEvent&#39; of undefined highcharts.js:304

我已经查看了它,无法弄清楚为什么它不使用该模板......也许我忽略了什么?

0 个答案:

没有答案