HighCharts无法显示加载符号。变量超出范围

时间:2014-10-06 20:46:58

标签: javascript jquery highcharts

出于某种原因,我在showLoading()方法上遇到错误,指出它未定义。我仔细看了一下chrome调试器,看起来图表变量从未被初始化。我该如何解决这个问题?

我有以下JS:

$(document).ready(function() {



//Stops the submit request
$("#dashBoardRequestForm").submit(function(e){
    e.preventDefault();
});

//checks for the button click event
$("#submitButton").click(function(e){
    chart = $('#graph1').highcharts();
    console.log("Entered");
    //get the form data and then serialize that
    dataString = $("#dashBoardRequestForm").serialize();

    chart.showLoading();
...Some Ajax Calls and Stuff...

我的HTML文件中的相应div如下:

<div class="container" id="anotherSection" style="max-width : 90%; width: 90%;">
<fieldset>
    <legend>Graphs:</legend>
    <div id="graph1" style="width: 33%; height: 28%; margin : 0; float: left;"></div>
    <div id="graph2" style="width: 33%; height: 28%; margin : 0;float: left;"></div>
    <div id="graph3" style="width: 33%; height: 28%; margin : 0;float: left;"></div>

</fieldset>

1 个答案:

答案 0 :(得分:0)

我只能猜出问题是什么。使用时点击#submit-button,我希望你已经创建了图表。如果没有,那就是问题所在。所以这是正确的过程:

  • 创建图表(使用$("#container").highcharts( { ... } ); - 注意:选项对象)
  • 获取图表(使用var chart = $("#container").highcharts(); - 注意:没有选项,它是吸气剂)
  • 现在使用您的变量来显示加载程序:chart.showLoading()