2011-03-29 66 views
3

當使用jqPlot繪製圖形時我具有包含正值和負值的曲線,從而穿過x軸。我想強調0的x軸更清楚地區分正值和負值。有沒有辦法做到這一點 ?使用jqPlot強調x軸上的0

下面我用用一個例子曲線代碼:

$.jqplot(
    'plotDiv', 
     [[[40,-5], [41,-5], [42,-5], [43,-5], [44,-5], [45,-5], 
     [46,-5], [47,-5], [48,-5], [49,-5], [50,-5], [51,-4], 
     [52,-3], [53,-2], [54,-1], [55,0], [56,1], [57,2], [58,3], [59,4], [60,5]]], 
    { title:{text:"Results"}, 
     axes: { 
      yaxis: {tickInterval: 2, label: 'Profit'}, 
      xaxis: {tickInterval: 2, label: 'Price'}}});}); 

在此先感謝

回答

4

你可以畫一條線在Y = 0用帆布覆蓋:

canvasOverlay: { 
     show: true, 
     objects: [ 
      {horizontalLine: { 
       name: '0 mark', 
       y: 0, 
       lineWidth: 2, 
       color: 'rgb(0, 0, 0)', 
       shadow: false 
      }} 
     ] 
}, 

在jqPlot下載的軟件包的「examples \ canvasOverlay.html」中可以找到更多使用畫布覆蓋的示例。