开发者

Emphasize 0 on x-axis with jqPlot

开发者 https://www.devze.com 2023-02-20 10:17 出处:网络
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 posi

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

精彩评论

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

关注公众号