jqplot DateAxisRenderer not working for minute based time scales

4,480 views
Skip to first unread message

Andrew

unread,
Dec 8, 2011, 6:45:03 PM12/8/11
to jqplot-users
jqplot is having a problem when I specify dates that only differ on
the minute scale. Here are my two data sets and a simple plot (that
doesn't function for line2 but works great for line1):

var line1 = [
['2011-12-06', 68],['2011-12-07', 27],
['2011-12-08', 12],['2011-12-09', 81],
['2011-12-10', 40],['2011-12-11', 93],
['2011-12-12', 34],['2011-12-13', 24],
['2011-12-14', 37],['2011-12-15', 80]];

var line2 = [
['2011-12-06 00:50', 68],['2011-12-06 00:55', 27],
['2011-12-06 01:00', 12],['2011-12-06 01:05', 81],
['2011-12-06 01:10', 40],['2011-12-06 01:15', 93],
['2011-12-06 01:20', 34],['2011-12-06 01:25', 24],
['2011-12-06 01:30', 37],['2011-12-06 01:35', 80]];

var plot = $.jqplot('chart', [line2], {
axes:{
xaxis:{
renderer:$.jqplot.DateAxisRenderer,
// min: '2011-12-06 00:00'
},
},
cursor:{ zoom:true, },
});

It renders and zooms fine for line1 but not for line2. line2 doesn't
render as expected. It looks like the min and max used to set the
xaxis and its scale are not being set correctly in the
DateAxisRenderer. If I set the min by hand for line2, the graph
renders correctly. Which would be fine for me...except that I would
like to use cursor zoom which doesn't work because min/max are not
behaving...I suspect.

Ideas?

Chris Leonello

unread,
Dec 8, 2011, 6:54:18 PM12/8/11
to jqplot...@googlegroups.com
What version of jqPlot ($.jqplot.version, unless you're running from source, then you'll have to look at the hg rev)?

-- 
Chris Leonello
http://www.jqplot.com

--
You received this message because you are subscribed to the Google Groups "jqplot-users" group.
To post to this group, send email to jqplot...@googlegroups.com.
To unsubscribe from this group, send email to jqplot-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jqplot-users?hl=en.

Andrew Davis

unread,
Dec 8, 2011, 6:58:20 PM12/8/11
to jqplot...@googlegroups.com
build 1012.  I also tried 1049 because it had some changes in cursor.js.  Didn't work for either.

  -Andrew

Chris Leonello

unread,
Dec 8, 2011, 7:16:56 PM12/8/11
to jqplot...@googlegroups.com
Thanks.  I'll take a look.

-- 
Chris Leonello
http://www.jqplot.com

Tim Harvey

unread,
Dec 9, 2011, 2:59:44 PM12/9/11
to jqplot...@googlegroups.com
Seeing similar issues build 1012 here using  timestamps that differ in seconds (var line1=[[1214838000000,4], [1214838010000,6.5], [1214838020000,5.7], [1214838030000,9], [,8.2]];) .  Seems to be something wrong with the autoscale.

Could you provide some info on how to implement your own tickRenderer?  For example, as epoch's on the x-axis auto-scale fine I could work-around the DateAxisRenderer issues by using my own formatter to render epoch's as a date/time string.

Thanks,

Tim 

Tbone

unread,
Jan 12, 2012, 1:04:15 PM1/12/12
to jqplot-users
Chris,
If I may 'chime' in here...For us anything after r947 that used
dateAxisRenderer was plotting but not showing an x-axis.

I tracked down the problem to after scanning the series data for
min/max, you then try to 'fix' it a bit more...For instance with min:
r1012 - dateAxisRenderer.js line 450
min = min.getTime() + min.getUtcOffset();

For us, it's the UTC offset that kills us...I remove that and it all
works...

Well except for one other adjustment. In r947 we can specify the tick
interval as:
tickInterval:'2 minute'

in r1012, we have to specify the interval in milliseconds.
tickInterval:120000

Is this a permanent change?

Thanks,
DeWayne Thomas

On Dec 8 2011, 5:16 pm, Chris Leonello <jqplot-us...@jqplot.com>
wrote:
> Thanks.  I'll take a look.
>
> --
> Chris Leonellohttp://www.jqplot.com
>
>
>
>
>
>
>
> On Thursday, December 8, 2011 at 6:58 PM, Andrew Davis wrote:
> > build 1012.  I also tried 1049 because it had some changes in cursor.js.  Didn't work for either.
>
> >   -Andrew
>
> > > > To post to this group, send email to jqplot...@googlegroups.com (mailto:jqplot...@googlegroups.com).
> > > > To unsubscribe from this group, send email to jqplot-users...@googlegroups.com (mailto:jqplot-users...@googlegroups.com).
> > > > For more options, visit this group athttp://groups.google.com/group/jqplot-users?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups "jqplot-users" group.
> > > To post to this group, send email to jqplot...@googlegroups.com (mailto:jqplot...@googlegroups.com).
> > > To unsubscribe from this group, send email to jqplot-users...@googlegroups.com (mailto:jqplot-users%2Bunsu...@googlegroups.com).
> > > For more options, visit this group athttp://groups.google.com/group/jqplot-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups "jqplot-users" group.
> > To post to this group, send email to jqplot...@googlegroups.com (mailto:jqplot...@googlegroups.com).
> > To unsubscribe from this group, send email to jqplot-users...@googlegroups.com (mailto:jqplot-users...@googlegroups.com).

tony

unread,
Jan 13, 2012, 6:24:01 AM1/13/12
to jqplot-users
Thanks for that! I commented the UTC offset and now my dates are
rendering (almost) as I want them after zooming. Still not keeping the
value for numberTicks on each and every zoom - sometimes it works ans
sometimes it doesn't.

Cheers
Tony

Adam Chasen

unread,
Aug 21, 2012, 6:52:40 PM8/21/12
to jqplot...@googlegroups.com
This is still an issue as of 1.0.3r1117.

Any data set within a short enough min/max will cause too few ticks. Commenting out the following in jqplot.dateAxisRenderer.js restores a sane number of ticks:
                //min = new $.jsDate(min);
                //min = min.getTime() + min.getUtcOffset();

We can see that the tempti is calculated properly because if we comment out the offset calculation, there is a sane interval.

It appears that we adjust the minimum by the offset. When the max/min of the data set is small (i.e. a few hours) and the offset is -4 UTC, this causes the min/max ceiling calculation to return 1 or a very low number which in turn sets the ticks to 2 (not sane).

Not sure what the solution is, or why we are even dealing with the offset of the minimum and comparing it against an unadjusted maximum, but there is clearly a bug here.

Workaround: Comment out the offset

I am new to this project and it is slick. Thanks for the great work!

Thanks,
Adam

John Paul Perry

unread,
Feb 15, 2013, 9:11:08 PM2/15/13
to jqplot...@googlegroups.com
bump.

Any official solution?

Thanks

Paul Pritchard

unread,
Feb 15, 2013, 10:26:18 PM2/15/13
to jqplot...@googlegroups.com
Not an official solution, but does pull request #29 fix the problem?


--Paul

JP

unread,
Feb 19, 2013, 4:44:59 PM2/19/13
to jqplot...@googlegroups.com
Hi Paul,

I tried that and it works... hopefully the pull request will be accepted sometime soon or another solution will be committed..

Thanks!
JP

Paul Pritchard

unread,
Feb 19, 2013, 4:50:05 PM2/19/13
to jqplot...@googlegroups.com
Cool, I will prioritize getting that pull request into the distribution.

--Paul

Paul Pritchard

unread,
Feb 26, 2013, 9:54:22 AM2/26/13
to jqplot...@googlegroups.com
It's in 1.07.

Steve Miller

unread,
Feb 27, 2013, 6:43:36 PM2/27/13
to jqplot...@googlegroups.com
I am continuing to have an issue with rendering small time scale data (seconds and minutes). I just tried the latest version 1.0.7r1224. When I revert all the way back to 1.0.0r701, it works.

Here is the data I am feeding to the chart in trying to display two lines of data:

['2012-01-01 1:00:15 AM','11'],['2012-01-01 1:00:30 AM','25'],['2012-01-01 1:00:45 AM','28'],['2012-01-01 1:01:00 AM','28'],['2012-01-01 1:01:15 PM','22']

['2012-01-01 1:00:15 AM','15'],['2012-01-01 1:00:30 AM','29'],['2012-01-01 1:00:45 AM','25'],['2012-01-01 1:01:00 AM','24'],['2012-01-01 1:01:15 AM','16']

The second data set is not displaying. Plus, the start of the x-axis is 7AM (perhaps the UTC issue) which chops off the date from the first dataset. 

Note the last data plot in the first dataset....it is set to "PM" which extends the time range on the x-axis. If I leave it at "AM", it too will not plot and the whole chart is blank with nothing on the x-axis. 

Like I said, when I revert back to the old version of jqPlot, it works just fine. Version 1.0.4r1121 does not work either. 

Really would love to get this fixed so we can use the more advanced features and bug fixes of the current release .

Thanks!

Paul Pritchard

unread,
Feb 27, 2013, 8:37:20 PM2/27/13
to jqplot...@googlegroups.com
Could you set up an example in a jsfiddle?  You could fork http://jsfiddle.net/ppritcha/G8xSx/, for example.  This will enable me to understand and debug the issue much more quickly.  Also, have you tried putting the dates in javascript timestamp format to see if there's a problem with the date conversion?

Paul Pritchard

unread,
Feb 27, 2013, 9:08:14 PM2/27/13
to jqplot...@googlegroups.com
I created this jsfiddle with the second set of data -- it displays OK with version 1.07, so probably you are doing something different.  Just update this fiddle with your version.

Steve Miller

unread,
Feb 28, 2013, 12:50:29 PM2/28/13
to jqplot...@googlegroups.com
Thanks for the quick response! We are doing alot of complex stuff with jqPlot parts of which are created dynamically. I created a jsp tag to help simplify the implementation along with it being more flexible and dynamic to aid other programmers that aren't jqPlot experts. :-) This gives me something to go on to reverse-engineer the problem. I'll post my results back here...might be a month or so as I have time. 

Florin Cretu

unread,
Aug 22, 2013, 4:10:38 PM8/22/13
to jqplot...@googlegroups.com
Hi, not exactly same problem but:
if i use min and max on xaxis, ticks change to date:
http://jsfiddle.net/nX2xU/

line1 = [

['2012-01-01 1:00:15 AM','15'],['2012-01-01 1:00:30 AM','29'],['2012-01-01 1:00:45 AM','25'],['2012-01-01 1:01:00 AM','24'],['2012-01-01 1:01:15 AM','16']
];

var plot1 = $.jqplot('chart', [line1], {

    axes: {
        xaxis: {
            renderer: $.jqplot.DateAxisRenderer,
            min: '2012-01-01 1:00:00 AM',
            max: '2012-01-01 1:02:00 AM'
           
        }
    }

});

the diff between min and max is 2 min but all tics show 2012/01/01
Reply all
Reply to author
Forward
0 new messages