2011-12-12 61 views
1

我正在使用jqplot來繪製餅圖。但是,當我繪製一個包含變量100%的數據的餅圖時,它會顯示一個非常奇怪的餅圖。餅圖jqplot爲100%時的正方形

enter image description here

這是我的代碼

<script type="text/javascript"> 
$(document).ready(function() 
{ 

    $('#chart1').bind('jqplotDataHighlight', 
     function (ev, seriesIndex, pointIndex, data) 
     { 
      $('#info1').html('' + data[0] + " - " + data[1]); 
     } 
    ); 

    $('#chart1').bind('jqplotDataUnhighlight', 
     function (ev) { 
      $('#info1').html('&nbsp;'); 
     } 
    ); 


    var plot1 = jQuery.jqplot ('chart1', [data], 
    { 
     title: { 
      text: '', // title for the plot, 
      show: true, 
     }, 
     seriesDefaults: { 
      renderer: jQuery.jqplot.PieRenderer, 
      padding: 0, 
      color:"#FFFFFF",  
      shadow: false, 
      rendererOptions: { 
       dataLabelFormatString: "<font color=white>%d%</font>", 
       diameter: 135, 
       showDataLabels: true, 
       sliceMargin: 1, 
       textColor: "#ABBBBB", 
       lineWidth: 5 
      }, 

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

     grid: { 
      background: '#ffffff', 
      shadow: false, 
      borderWidth: 0 
     } 
    } 

); 
}); 
</script> 
+0

我認爲如果你沒有很好地解釋,你不會得到太多的答案。通常讀者認爲關於這個問題的所有細節都在帖子主體本身上,並且不會試圖從帖子主體的標題和其他一半中獲取一半,並且理解這個問題。至少包括你用來做這件事的代碼。 –

+0

「數據」數組的內容是什麼? –

+0

它是工具提示,就像Android - 123設備 –

回答

0

問題是

sliceMargin:1,

沒有它,一切工作正常。

0

你有

title: { 
      text: '', // title for the plot, 
      show: true, 
     }, 

兩個額外的逗號和

 rendererOptions: { 
      dataLabelFormatString: "<font color=white>%d%</font>", 
      diameter: 135, 
      showDataLabels: true, 
      sliceMargin: 1, 
      textColor: "#ABBBBB", 
      lineWidth: 5 
     }, 

也就是說在JavaScript無效。所以這個問題的原因可能是這個。

+0

我更新了,但它沒有解決我的問題 –