2014-01-08 154 views
0

我正在使用jqplot來顯示我的欄字符。jqplot.CanvasAxisTickRenderer拋出未捕獲類型錯誤

條形圖工作正常,直到我添加了tickRenderer和tickOptions。

現在我得到以下錯誤:遺漏的類型錯誤:未定義是不是一個函數

這裏是我的代碼

plot3 = $.jqplot('chart3', [s2, s3], { 
    stackSeries: true, 
    seriesDefaults: { 
     renderer: $.jqplot.BarRenderer, 
     rendererOptions: { 
      highlightMouseDown: true 
     }, 
     pointLabels: {show: true} 
    }, 
    legend: { 
     show: true, 
     location: 'e', 
     placement: 'outside' 
    }, 
    axes: { 
     xaxis: { 
      renderer: $.jqplot.CategoryAxisRenderer, 
      ticks: ticks, 
      tickRenderer: $.jqplot.CanvasAxisTickRenderer , 
      tickOptions: { 
       angle: -90, 
       fontSize: '10pt' 
      } 
     } 
    } 
}); 

回答

0

我想你的代碼和它的作品... 我不不知道你的問題是什麼。

我包括這些插件

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> 
<script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/jquery.jqplot.min.js"></script> 
<link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/jqplot/1.0.8/jquery.jqplot.min.css" /> 
<script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.barRenderer.min.js"></script> 
<script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.categoryAxisRenderer.min.js"></script> 
<script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.pointLabels.min.js"></script> 
<script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.cursor.min.js"></script> 

和我使用這些數據數組爲測試。

$(document).ready(function(){ 
s2 = [0,1,2,3,4]; 
s3 = [1,2,3,4,5]; 
ticks = ["a","b","c","d","e"]; 

這是結果

enter image description here

1

我裝我的腳本動態,但我loadScript()函數是ASYC,所以不是所有的資源來繪製圖表之前加載。將異步更改爲false後,所有工作都開始運行。

loadScript("jqplot/jquery.jqplot.min.js"); 
loadScript("jqplot/jqplot.dateAxisRenderer.min.js"); 
loadScript("jqplot/jqplot.barRenderer.min.js"); 
loadScript("jqplot/jqplot.canvasTextRenderer.min.js"); 
loadScript("jqplot/jqplot.canvasAxisTickRenderer.min.js"); 
loadScript("jqplot/jqplot.categoryAxisRenderer.min.js"); 
loadScript("jqplot/jqplot.pointLabels.min.js"); 

function loadScript(jsPage) { 
    $.ajax({ 
     url: jsPage, 
     async: false, 
     dataType: "script" 
    }); 
}