2011-03-29 63 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”中可以找到更多使用画布覆盖的示例。