2013-10-02 166 views
1

我知道這個問題是種複製到在jqPlot中,如何去除y軸線?

jqPlot Styling - How to remove Y axis line?

但由於這個問題沒有得到證實的答案(一貼,我沒有工作),所以我在這裏再問問吧。

我有一個簡單的例子,從條形圖示例的jqPlot網頁中複製,並且想要刪除y軸線而不改變它到$ .jqplot.CategoryAxisRenderer(它可以隱藏軸線作爲我的x軸) 。

http://jsfiddle.net/marsant/HndmB/3/

代碼:

$(document).ready(function(){ 
    var s1 = [200, 600, 700, 1000, 600]; 
    // Can specify a custom tick Array. 
    // Ticks should match up one for each y value (category) in the series. 
    var ticks = ['May', 'June', 'July', 'August', 'September']; 

    var plot1 = $.jqplot('chart1', [s1], { 
     // The "seriesDefaults" option is an options object that will 
     // be applied to all series in the chart. 
     seriesDefaults:{ 
      renderer:$.jqplot.BarRenderer, 
      rendererOptions: { barWidth: 20 }, 
      color:'blue', 
      shadow: false, 
     }, 
     grid: { 
      drawBorder: false, 
      shadow: false, 
     }, 
     axes: { 
      // Use a category axis on the x axis and use our custom ticks. 
      xaxis: { 
       renderer: $.jqplot.CategoryAxisRenderer, 
       ticks: ticks, 
       tickOptions: { showGridline: false, showMark: false }, 
       showTickMarks: false, 
      }, 
      // Pad the y axis just a little so bars can get close to, but 
      // not touch, the grid boundaries. 1.2 is the default padding. 
      yaxis: { 
       pad: 1.05, 
       tickOptions: { formatString: '$%d', showMark: false }, 
       showTickMarks: false, 
      } 
     } 
    }); 
}); 

更新

此示例代碼爲我工作

yaxis: { 
    renderer: $.jqplot.LinearAxisRenderer, 
    rendererOptions: { drawBaseline: false, }, 
    ... ... 
} 

回答

5

網格選項後,你可以嘗試和軸之前,選項t o插入:

axesDefaults: { 
    rendererOptions: { 
     drawBaseline: false 
    } 
}, 

希望它有幫助。

+0

是的,它的工作,謝謝! – marsant

+0

是的......這個工作很完美,謝謝! –