diff options
author | Atul Pratap Singh <atulpratapsingh05@gmail.com> | 2012-07-29 17:45:14 +0400 |
---|---|---|
committer | Atul Pratap Singh <atulpratapsingh05@gmail.com> | 2012-07-29 17:45:14 +0400 |
commit | 759df40f089c0ededad008ede121da4095dc2acf (patch) | |
tree | cbf0e8e3e2d21b2d38fb3d069ec5c61617ccdd10 /js/jqplot | |
parent | 8016ac497762ae47e8e9bbee16f3d5d0a426b797 (diff) |
Tried fixing jqplot crashing problem using diff provided on https://bitbucket.org/cleonello/jqplot/issue/552/jqplot-crashes-when-interval-too-small
Diffstat (limited to 'js/jqplot')
-rw-r--r-- | js/jqplot/plugins/jqplot.dateAxisRenderer.js | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/js/jqplot/plugins/jqplot.dateAxisRenderer.js b/js/jqplot/plugins/jqplot.dateAxisRenderer.js index bb307b7186..bdf4c22cf4 100644 --- a/js/jqplot/plugins/jqplot.dateAxisRenderer.js +++ b/js/jqplot/plugins/jqplot.dateAxisRenderer.js @@ -335,6 +335,28 @@ 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. @@ -464,7 +486,7 @@ // 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. @@ -480,9 +502,10 @@ var tempti = ret[0]; this._autoFormatString = ret[1]; - min = Math.floor(min/tempti) * tempti; + //min = Math.floor(min/tempti) * tempti; min = new $.jsDate(min); - min = min.getTime() + min.getUtcOffset(); + //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; @@ -640,7 +663,7 @@ this.tickInterval = null; } - // if user specified a tick interval, convert to usable. + /* // 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. @@ -658,8 +681,12 @@ 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 |