Replot() with resetAxes=True causing inconsistent behavior with xaxis if data is of type Date

dizzy avatardizzy created an issue

I am plotting one year's worth of data.


  1. !javascript

this.Chart = $.jqplot(, [data], ChartOptions); This works fine when the page loads, the X axes shows date range from May 2010 to July 2011. However if i then call: this.Chart.series[0].data = data; this.Chart.replot({ clear: true, resetAxes: true }) }}}

The date range for the X axes now shows March 2010 to July 2011, while the data plotted is still 1 year, thus leaving a large area to the left of the chart with no data showing.

I think the problem is the ‘resetAxes:true’ option. In jquery.jqPlot.js, resetAxesScale is called if resetAxes = true. It looks like this function calls resetScale to null out the axis options:


  1. !javacript

Axis.prototype.resetScale = function(opts) { $.extend(true, this, { min: null, max: null, numberTicks: null,tickInterval: null, _ticks: [], ticks: [] }, opts); this.resetDataBounds(); }; }}}

So this is where tickInterval is being nulled out. However strangely, if I remove tickInterval from the list of attributes being nulled out in the code above, while that fixes the the xaxis issue, the yaxis scale still shifts between the initial plot and the call to replot despite the data being exactly the same. I would expect the chart to render the same when replot() is called if the series is exactly the same. I think there may be some padding or such thing being applied only when replot is called. If it helps these are the chart options i am using:

        axes: { 
          xaxis: { 
            tickOptions:{formatString:'%b %e'}, 
            tickInterval: "4 weeks" 
          y2axis: { 
        series: [{ 
                downBodyColor:"#D41A1F" } 
        highlighter: { 
          show: false 

Comments (8)

  1. Paul Pritchard

    Note that when yaxis min is not set, the data is plotted the same way, both initially and after clicking on a series in the legend. It looks like yaxis: {min:0} is ignored when the data is replotted.

  2. Paul Pritchard

    OK, the basic issue here is that when you set seriesToggleReplot: {resetAxes:true}, the graph is replotted every time you click on a series in the legend, and the axes are reset -- which means that the yaxis setting of min:0 is replaced with the default yaxis.

    To keep the plot's axis unchanged, just set seriesToggleReplot: false.

  3. daijobou

    Thank you for your fast response. :) I don't understand.. why is this issue now "resolved"?

    I need "seriesToggleReplot:{resetAxes:true}". After selection in legend, the plot should re-calculate and redraw yaxis. But why he starting with resetAxes for yaxis with -50 and not 0?

    What can I do to redraw the plot and a yaxis of min:0? I have here never ever values <0, so its not logical to show -50 for yaxis.

    EDIT: I have tried this: (source:!topic/jqplot-users/RYzc3UxiqDc)


    But now the legend toggle wrong. Its hide the line and show the hidden line again.

  4. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.