Graph time will automatically set to current time when user tried to change graph duration

application-manager-new
charithag 9 years ago
parent 796bbdf7f5
commit 2e752c61d9

@ -1,6 +1,10 @@
var fromDate; var fromDate;
var toDate; var toDate;
var currentDay = new Date();
var startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100));
var endDate = new Date(currentDay.getTime());
// create a custom bar renderer that has no gaps // create a custom bar renderer that has no gaps
Rickshaw.Graph.Renderer.BarNoGap = Rickshaw.Class.create(Rickshaw.Graph.Renderer.Bar, { Rickshaw.Graph.Renderer.BarNoGap = Rickshaw.Class.create(Rickshaw.Graph.Renderer.Bar, {
name: 'bar_no_gap', name: 'bar_no_gap',
@ -11,10 +15,11 @@ Rickshaw.Graph.Renderer.BarNoGap = Rickshaw.Class.create(Rickshaw.Graph.Renderer
} }
}); });
function initDate(){
var currentDay = new Date(); currentDay = new Date();
var startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100)); startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100));
var endDate = new Date(currentDay.getTime()); endDate = new Date(currentDay.getTime());
}
var configObject = { var configObject = {
startOfWeek: 'monday', startOfWeek: 'monday',
@ -38,6 +43,7 @@ var configObject = {
var DateRange = convertDate(startDate) + " " + configObject.separator + " " + convertDate(endDate); var DateRange = convertDate(startDate) + " " + configObject.separator + " " + convertDate(endDate);
$(document).ready(function () { $(document).ready(function () {
initDate();
$('#date-range').dateRangePicker(configObject) $('#date-range').dateRangePicker(configObject)
.bind('datepicker-apply', function (event, dateRange) { .bind('datepicker-apply', function (event, dateRange) {
$(this).addClass('active'); $(this).addClass('active');
@ -61,21 +67,25 @@ $(document).ready(function () {
//day picker //day picker
$('#today-btn').on('click', function () { $('#today-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - 86400000, currentDay.getTime()); getDateTime(currentDay.getTime() - 86400000, currentDay.getTime());
}); });
//hour picker //hour picker
$('#hour-btn').on('click', function () { $('#hour-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - 3600000, currentDay.getTime()); getDateTime(currentDay.getTime() - 3600000, currentDay.getTime());
}); });
//week picker //week picker
$('#week-btn').on('click', function () { $('#week-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - 604800000, currentDay.getTime()); getDateTime(currentDay.getTime() - 604800000, currentDay.getTime());
}); });
//month picker //month picker
$('#month-btn').on('click', function () { $('#month-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - (604800000 * 4), currentDay.getTime()); getDateTime(currentDay.getTime() - (604800000 * 4), currentDay.getTime());
}); });

Loading…
Cancel
Save