3

当用 jqPlot 绘制图表时,我的曲线包含正值和负值,因此穿过 x 轴。我想强调 0 处的 x 轴,以便更清楚地区分正值和负值。有没有办法做到这一点 ?

在我使用示例曲线的代码下方:

$.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

1 回答 1

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”中找到。

于 2011-08-12T13:10:30.027 回答