1. Chris Leonello
  2. jqplot
Issue #359 resolved

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

created an issue

I am plotting one year's worth of data.



this.Chart = $.jqplot(this.PaneContainer.id, [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:



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:



{ seriesDefaults:{yaxis:'y2axis'}, axes: { xaxis: { renderer:$.jqplot.DateAxisRenderer, tickOptions:{formatString:'%b %e'}, tickInterval: "4 weeks" }, y2axis: { tickOptions:{formatString:'%d'} } }, series: [{ renderer:$.jqplot.OHLCRenderer, rendererOptions:{ candleStick:true, fillUpBody:true, fillDownBody:true, upBodyColor:"#00CD00", 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: https://groups.google.com/forum/?fromgroups=#!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