开发者

Emphasize 0 on x-axis with jqPlot

when plotting a graph 开发者_JAVA百科with jqPlot I have curves which contains both positive and negative values, thus crossing the x-axis. I would like to emphasize the x-axis at 0 to distinguish positive and negative values more clearly. Is there a way to do this ?

Below the code I'm using with an example curve:

$.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'}}});});

Thanks in advance


You could draw a line on y=0 using the canvas overlay:

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

More examples using the canvas overlay can be found in "examples\canvasOverlay.html" in the jqPlot downloaded package.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜