2011-07-28 140 views
4

獲取日誌消息:餅圖的直徑太小,不能渲染。jqplot餅圖無法正確顯示。

然後,似乎當我將鼠標懸停或點擊網頁我進去:遺漏的類型錯誤:無法讀取的不確定

<link href="/Content/jqPlot/jquery.jqplot.css" rel="stylesheet" type="text/css" /> 
    <script src="/Scripts/jquery.jqplot.js" type="text/javascript"></script> 
    <script src="/Scripts/jqplot.pieRenderer.js" type="text/javascript"></script> 

    <script type="text/javascript"> 
     $(function() { 
      //GetWeeklyProjectSummary(); 
      Test(); 
     }); 

     function Test() { 
      var data = [["987 Project",74],["ABC Project",68],["XYZ project",26]]; 
      var plot1 = jQuery.jqplot('weeklyProjectSummary', [data], 
       { 
        seriesDefaults: { 
         // Make this a pie chart. 
         renderer: jQuery.jqplot.PieRenderer, 
         rendererOptions: { 
          // Put data labels on the pie slices. 
          // By default, labels show the percentage of the slice. 
          showDataLabels: true 
         } 
        }, 
        legend: { show: true, location: 'e' } 
       } 
      ); 
     } 
    </script> 

這裏財產「0」是其進入股利:

<div id="weeklyProjectSummary"></div> 

這是我在頁面上得到的:page output

讓我知道你是否需要任何更多的細節。

回答

11

我在使用jpgplot和blueprintcss時出現了類似的問題 - 基於你的屏幕截圖我相信你正在使用blueprintcss。

嘗試刪除以下行:

legend: { show: true, location: 'e' } 

,看看它是否正確地呈現。

(編輯:點擊此處瞭解詳情:

https://bitbucket.org/cleonello/jqplot/issue/48/legends-doesnt-look-nice-when-using

+0

這個工作,但我怎麼得到的傳說? – Justin

+0

呵呵,閱讀鏈接! – Justin

+0

一切都很好,謝謝。 – Justin

0

您的JQPlot圖表定義似乎正確。餡餅在我的屏幕上呈現正確。

我沒有看到包含jquery.js或jquery.min.js。你能確認你的代碼中有這個文件的引用嗎?

此外,請確認您所有的js/css文件都被正確引用(您可以使用JSView Firefox Extension快速確認它們確實包含在內)。

0

包括canvas.min.js。你可以在下載的例子中找到它。它與傳奇一起爲我工作。

3

我添加下面的行我的CSS文件

.jqplot表,傳說{寬度:自動; }

從jqplot css文件重載屬性。

爲我工作。

+0

這可以解決與現場Foundation CSS相同的錯誤。 – skobaljic

0

我只是想答案從Amaud T擴展:

我面臨着同樣的問題,我用上面的回答,有一些小的修改:

<style type="text/css"> 
    #chartComponentId table.jqplot-table-legend { width: auto !important;} 
</style> 
<div id="chartComponentId" class="chartComponent"> 
... 
</div> 

由於需要使用的!重要的,在特定的div對象上綁定這個樣式表可以防止對其他元素產生任何副作用。