From 26e8a32604a78e82da23e8d2262fd2bcc54288fa Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Sat, 12 Jun 2010 12:11:20 +0100 Subject: Dynamically extend the range preview beyond the chosen range --- jrrd.js | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/jrrd.js b/jrrd.js index 62ebce6..2dfe28a 100644 --- a/jrrd.js +++ b/jrrd.js @@ -502,7 +502,7 @@ jrrd.ChartCoordinator = function(ui) { }); // Style and configuration of the range timeline - var rangePreviewOptions = { + this.rangePreviewOptions = { grid: { borderWidth: 1 }, @@ -516,20 +516,6 @@ jrrd.ChartCoordinator = function(ui) { ticks: [] } }; - var now = new Date().getTime(); - var HOUR = 1000 * 60 * 60; - var DAY = HOUR * 24; - var WEEK = DAY * 7; - var MONTH = DAY * 31; - var YEAR = DAY * 365; - - // Dummy data for the range timeline - var data = [ - [now - WEEK, null], - [now, null]]; - - this.rangePreview = $.plot(this.ui.find('.range-preview'), [data], - rangePreviewOptions); // When a selection is made on the range timeline, redraw all the charts. this.ui.bind("plotselected", function(event, ranges) { @@ -551,6 +537,35 @@ jrrd.ChartCoordinator.prototype.update = function() { to: endTime.getTime() } }; + + // Add a suitable extended head and tail to preview graph time axis + var HOUR = 1000 * 60 * 60; + var DAY = HOUR * 24; + var WEEK = DAY * 7; + var MONTH = DAY * 31; + var YEAR = DAY * 365; + var periods = [HOUR, HOUR*6, HOUR*12, + DAY, DAY*3, + WEEK, WEEK*2, + MONTH, MONTH*3, MONTH*6, YEAR]; + + var range = ranges.xaxis.to - ranges.xaxis.from; + for(var i=0; i