How to plot graph (Line Chart) with custom x-axis with custom y-axis in Jqplot?

529 views
Skip to first unread message

Samadhan Kshirsagar

unread,
Mar 11, 2016, 3:06:56 AM3/11/16
to jqplot-users
Hi All,

     I want to create line chart report using jqplot library.I have taken custom x-axis and y-axis.I have taken 2 arrays with same size. I have written following code for it.


$(document).ready(function(){


  var plot2 = $.jqplot ('chart2', [arrOfValueYaxis], {
      // Give the plot a title.
      title: 'Plot With Options',
      // You can specify options for all axes on the plot at once with
      // the axesDefaults object.  Here, we're using a canvas renderer
      // to draw the axis label which allows rotated text.
      axesDefaults: {
        labelRenderer: $.jqplot.CanvasAxisLabelRenderer
      },
      // Likewise, seriesDefaults specifies default options for all
      // series in a plot.  Options specified in seriesDefaults or
      // axesDefaults can be overridden by individual series or
      // axes options.
      // Here we turn on smoothing for the line.
      seriesDefaults: {
          rendererOptions: {
              smooth: true
          }
      },
      // An axes object holds options for all axes.
      // Allowable axes are xaxis, x2axis, yaxis, y2axis, y3axis, ...
      // Up to 9 y axes are supported.
      axes: {
        // options for each axis are specified in seperate option objects.
        xaxis: {
          label: "X Axis",
 ticks:ticks,
          // Turn off "padding".  This will allow data point to lie on the
          // edges of the grid.  Default padding is 1.2 and will keep all
          // points inside the bounds of the grid.
          pad: 0
        },
        yaxis: {
          label: "Y Axis"
        }
      }
    });
});



But actually issue is that this graph is showing wrong line chart.

I have 2 arrays i.e

var arrOfValueYaxis=[0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,50,0,74,0,0];


var ticks=[26,24,22,20,18,16,14,12,10,8,6,4,2,0,-2,-4,-6,-8,-10,-11];

still its plotting with wrong points.

Please anybody has suggestions on it then please share.

Thanks In Advance.

PFB screenshot.


Larry Martell

unread,
Mar 11, 2016, 10:21:55 PM3/11/16
to jqplot-users
It has something to do with the fact that your X values are descending. The Y values are coming out in reverse order. You could reverse the order of the values in arrOfValueYaxis and then it will come out the way you want. Kinda kludgey, but that's what I've often found to be required with jqPlot. 

Reply all
Reply to author
Forward
0 new messages