summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Wall <richard@aziz>2010-04-09 03:39:46 +0100
committerRichard Wall <richard@aziz>2010-04-09 03:39:46 +0100
commitb96a962c8ea828569c17b3c730f6a113a1013bf5 (patch)
treef86fb0d93d6c9e35948c16dc91d9d9f67dcd6980
parente7e8ce2313d1b13f6e1986f78316ab1d6a2f04ff (diff)
enable range selections
-rw-r--r--index.html23
1 files changed, 18 insertions, 5 deletions
diff --git a/index.html b/index.html
index b7986f1..66baba2 100644
--- a/index.html
+++ b/index.html
@@ -21,6 +21,7 @@
$.ajax({
url: url,
dataType: 'text',
+ cache: false,
beforeSend: function(request) {
try {
request.overrideMimeType('text/plain; charset=x-user-defined');
@@ -148,11 +149,8 @@
}
};
- $(function() {
- new RrdDataWrapper('data/localhost/load/load.rrd')
- .getData(
- new Date('7 April 2010 09:30:00'),
- new Date('7 April 2010 11:00:00'))
+ function drawChart(db, startTime, endTime) {
+ return db.getData(startTime, endTime)
.addCallback(
function(data) {
var plot = $.plot($('.container'), data, graphOptions);
@@ -161,11 +159,26 @@
function(failure) {
$('.container').text('error: ' + failure.message);
});
+ }
+
+ var db = new RrdDataWrapper('data/localhost/load/load.rrd');
+
+ $(function() {
+ drawChart(db, new Date('7 April 2010 09:30:00'),
+ new Date('7 April 2010 15:00:00'));
+
$('.container').bind('plotclick', function(event, pos, item) {
if (item) {
console.log(['X: ' + new Date(item.datapoint[0]), 'Y: ' + item.datapoint[1]]);
}
});
+
+ $('.container').bind("plotselected", function(event, ranges) {
+ var startTime = new Date(ranges.xaxis.from);
+ var endTime = new Date(ranges.xaxis.to);
+ drawChart(db, startTime, endTime);
+ console.log("You selected " + startTime + " to " + endTime);
+ });
});
</script>
</head>