Issue #370 invalid

Axes pad option behavior change

Anonymous created an issue

The jqplot.dateAxisRenderer.js plugin previously to worked in a different manner on the xaxis and a pad of 1.02. It would bring the date close to the left and right ends of the (line) graph. In 1.0.0a this worked well. with 1.0.0b2 this appears to cause the default padding to be used which is more padding than desired.

Additionally, using a pad of 2 or more seems to work as expected.

Here is a sample of my options: axes: { xaxis: { pad: 1.02, autoscale: true, renderer: $.jqplot.DateAxisRenderer, rendererOptions: { tickRenderer: $.jqplot.CanvasAxisTickRenderer }, tickOptions: { formatString: '%x %R', fontSize: '8.5pt', fontFamily: 'Tahoma', angle: 30, fontWeight: 'normal', fontStretch: 1 } }, yaxis: { min: 0, tickOptions: { fontSize: '8pt', fontFamily: 'Tahoma', fontWeight: 'normal', fontStretch: 1, formatString: "%'.2f" }, labelRenderer: $.jqplot.CanvasAxisLabelRenderer } }

Comments (8)

  1. Anonymous

    I'll take a look. Since I've reverted back on the app. it may be a bit to restore...Thanks for investigating thus far. I'll update this with what I find.

  2. oseemann

    I have stumbled upon this problem as well. I've adapted an example file to show the problem. In the attached dateAxisRender.html a padding of 0 is given, yet the chart does add a padding.

    (to reproduce you need to place the file in the examples directory of the 1.0.0b2_r792 distribution)

    Can you confirm the bug?

  3. Chris Leonello repo owner

    Thanks for the test case oseeman. I really appreciate it. There are too many issues reported without test cases. I rarely have the time to try to put together a test case to duplicate an issue based on someones description.

    Although not the expected behavior, this is not a bug. The pad option simply expands the data range for purposes of computing tick values. It doesn't enforce any specific minimum or maximum value, use the axes min and max options for that. It was and still is a crude way to ensure data is somewhat centered in the graph area.

    If you want to ensure your axis starts and ends at your first and last data points, you should do something like:

    xaxis: {
        min: line2[0][0],
        max: line2[line2.length-1][0],

    I apologize that it doesn't look as good as it used to. This is probably due to changes in the tick generation algorithm. The algorithm is optimized for numbers, not dates. I'll have to improve that.

    Note, there were some recent fixes when using the numberTicks and tickInterval options that you may need if you use those options. They were committed a few days ago.

  4. Anonymous

    I have a similar issue. If I render a stacked bar chart, using DateAxisRenderer for the xaxis, and showing seven bars (one for every day of the week), then the first and last bars start/end in the middle of the bar. I would like to see more options for specifying padding, instead of mocking extra space through adding more to the beginning/end of the axis.

  5. Anish Nair

    Hi Chris,

    The 'pad' attribute doesn't seem to work for me. Can you tell me why?

    I am using a simple array like the one below:

    var arr_values = [['13-Oct-12',0], ['14-Oct-12',0], ['15-Oct-12',0], ['16-Oct-12',280], ['17-Oct-12',150], ['18-Oct-12',167], ['19-Oct-12',200], ['20-Oct-12',123], ['21-Oct-12',220]];

    I am setting the 'min' value on the y-axis to '0', so that the y-axis doesn't include the negative values in the ticks.

    But since my array( i.e. arr_values) has one or more data value at '0', the marker on the line chart gets cut(the x-axis cuts it)

    So i decided to use the 'pad' attribute so that the chart doesn't get cut. But it just won't work out for me.

    I hope you are clear with my problem.

    So looking forward for your help

  6. Log in to comment