2011-12-19 44 views
0

是存在的,當我們在使用指定標籤的方式多y軸的指定系列標籤和多個yaxes的一起

<script class="code" type="text/javascript"> 
    $(document).ready(function(){ 
    var line1=[['11-01-11',2052], ['11-02-11',2205], ['11-03-11',1910], ['11-04-  11',2085], ['11-05-11',2261], ['11-06-11',1714], ['11-07-11',3123]; 

    var line2=[['11-01-11',2121], ['11-02-11',32323], ['11-03-11',65656], ['11-04- 11',21212], ['11-05-11',32323], ['11-06-11',54544], ['11-07-11',31230]]; 

var plot1 = $.jqplot('chart1', [line1, line2], { 
title:'Margin vs Date', 
axes:{ 
    xaxis:{ 
     renderer:$.jqplot.DateAxisRenderer 
    }, 
    yaxis:{ autoscale:true}, 
     y2axis:{ 
      autoscale:true, 
      tickOptions:{showGridline:false} 
     } 

}, 
series:[{lineWidth:4}, {yaxis:'y2axis'}] 

    }); 
    }); 
    </script> 

,但是當我試圖指定爲這兩個系列的無標籤的標籤顯示,

series:[{label: 'hello' }, {label: 'Hi'},{lineWidth:4}, {yaxis:'y2axis'}] 

有沒有辦法完成它?

grap With two y axe's

回答

1

在我的回答,我假設你是指軸的標籤,而不是一個表的傳奇。

首先,爲了徹底。你的日期正在翻譯成1911年,我懷疑它的意圖。 (如果你做new Date("11-03-11") js將其翻譯爲1911)。

此外,還要確保你enablePlugins

$.jqplot.config.enablePlugins = true; 

所有這一切說,軸標籤上的實際軸的特性,而不是一系列的屬性定義。因此,使用你的代碼作爲一個例子,以下爲我的作品:

<script class="code" type="text/javascript"> 
    $(document).ready(function(){ 
    var line1=[['11-01-2011',2052], ['11-02-2011',2205], ['11-03-2011',1910], ['11-04-2011',2085], ['11-05-2011',2261], ['11-06-2011',1714], ['11-07-2011',3123]]; 
    var line2=[['11-01-2011',2121], ['11-02-2011',32323], ['11-03-2011',65656], ['11-04- 11',21212], ['11-05-2011',32323], ['11-06-2011',54544], ['11-07-2011',31230]]; 

    $.jqplot.config.enablePlugins = true; 

    var plot1 = $.jqplot('chart1', [line1, line2], { 
     title:'Margin vs Date', 
     axes:{ 
      xaxis:{ 
       renderer:$.jqplot.DateAxisRenderer    
      }, 
      yaxis:{ 
      autoscale:true, 
      label: "hello" 
      }, 
      y2axis:{ 
      autoscale:true, 
      tickOptions:{showGridline:false}, 
      label: "Hi" 
      } 

     }, 
     series:[{lineWidth:4}, {yaxis:'y2axis'}] 
    }); 
    }); 
</script> 

如果當時就想採取進一步行動,並旋轉標籤,你要考慮使用canvasTextRenderer和canvasAxisLabelRenderer插件。