vendor/assets/javascripts/jqplot-plugins/jqplot.dateAxisRenderer.js in outfielding-jqplot-rails-1.0.5 vs vendor/assets/javascripts/jqplot-plugins/jqplot.dateAxisRenderer.js in outfielding-jqplot-rails-1.0.7
- old
+ new
@@ -1,11 +1,11 @@
/**
* jqPlot
* Pure JavaScript plotting plugin using jQuery
*
- * Version: 1.0.5
- * Revision: 1122+
+ * Version: 1.0.7
+ * Revision: 1224
*
* Copyright (c) 2009-2013 Chris Leonello
* jqPlot is currently available for use in all personal or commercial projects
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
@@ -31,11 +31,11 @@
(function($) {
/**
* Class: $.jqplot.DateAxisRenderer
* A plugin for a jqPlot to render an axis as a series of date values.
* This renderer has no options beyond those supplied by the <Axis> class.
- * It supplies it's own tick formatter, so the tickOptions.formatter option
+ * It supplies its own tick formatter, so the tickOptions.formatter option
* should not be overridden.
*
* Thanks to Ken Synder for his enhanced Date instance methods which are
* included with this code <http://kendsnyder.com/sandbox/date/>.
*
@@ -332,18 +332,39 @@
var min, max;
var pos1, pos2;
var tt, i;
var threshold = 30;
var insetMult = 1;
+ var daTickInterval = null;
+
+ // if user specified a tick interval, convert to usable.
+ if (this.tickInterval != null)
+ {
+ // if interval is a number or can be converted to one, use it.
+ // Assume it is in SECONDS!!!
+ if (Number(this.tickInterval)) {
+ daTickInterval = [Number(this.tickInterval), 'seconds'];
+ }
+ // else, parse out something we can build from.
+ else if (typeof this.tickInterval == "string") {
+ var parts = this.tickInterval.split(' ');
+ if (parts.length == 1) {
+ daTickInterval = [1, parts[0]];
+ }
+ else if (parts.length == 2) {
+ daTickInterval = [parts[0], parts[1]];
+ }
+ }
+ }
var tickInterval = this.tickInterval;
// if we already have ticks, use them.
// ticks must be in order of increasing value.
- min = ((this.min != null) ? new $.jsDate(this.min).getTime() : db.min);
- max = ((this.max != null) ? new $.jsDate(this.max).getTime() : db.max);
+ min = new $.jsDate((this.min != null) ? this.min : db.min).getTime();
+ max = new $.jsDate((this.max != null) ? this.max : db.max).getTime();
// see if we're zooming. if we are, don't use the min and max we're given,
// but compute some nice ones. They will be reset later.
var cursor = plot.plugins.cursor;
@@ -462,11 +483,11 @@
// Not gauranteed to get this interval, but we'll get as close as
// we can.
// tickInterval will be used before numberTicks, that is if
// both are specified, numberTicks will be ignored.
else if (this.tickInterval) {
- titarget = this.tickInterval;
+ titarget = new $.jsDate(0).add(daTickInterval[0], daTickInterval[1]).getTime();
}
// if numberTicks specified, try to honor it.
// Not gauranteed, but will try to get close.
else if (this.numberTicks) {
@@ -478,13 +499,12 @@
if (titarget <= 19*day) {
var ret = bestDateInterval(min, max, titarget);
var tempti = ret[0];
this._autoFormatString = ret[1];
- min = Math.floor(min/tempti) * tempti;
min = new $.jsDate(min);
- min = min.getTime() + min.getUtcOffset();
+ min = Math.floor((min.getTime() - min.getUtcOffset())/tempti) * tempti + min.getUtcOffset();
nttarget = Math.ceil((max - min) / tempti) + 1;
this.min = min;
this.max = min + (nttarget - 1) * tempti;
@@ -638,27 +658,11 @@
// if min, max and number of ticks specified, user can't specify interval.
if (this.min != null && this.max != null && this.numberTicks != null) {
this.tickInterval = null;
}
- // if user specified a tick interval, convert to usable.
- if (this.tickInterval != null)
- {
- // if interval is a number or can be converted to one, use it.
- // Assume it is in SECONDS!!!
- if (Number(this.tickInterval)) {
- this.daTickInterval = [Number(this.tickInterval), 'seconds'];
- }
- // else, parse out something we can build from.
- else if (typeof this.tickInterval == "string") {
- var parts = this.tickInterval.split(' ');
- if (parts.length == 1) {
- this.daTickInterval = [1, parts[0]];
- }
- else if (parts.length == 2) {
- this.daTickInterval = [parts[0], parts[1]];
- }
- }
+ if (this.tickInterval != null && daTickInterval != null) {
+ this.daTickInterval = daTickInterval;
}
// if min and max are same, space them out a bit
if (min == max) {
var adj = 24*60*60*500; // 1/2 day