summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sfiligoi <isfiligoi@ucsd.edu>2013-11-06 19:49:31 +0000
committerIgor Sfiligoi <isfiligoi@ucsd.edu>2013-11-06 19:49:31 +0000
commit59bf2e93f3c466281c06bbf8347a8b9992f132dd (patch)
tree1158ccf6b4c94a9af303b1b3f606ba1c8f926588 /src
parent33a6737df3781d352692b2dccf48896d62cedff7 (diff)
Use new Async class and the new unified include
Diffstat (limited to 'src')
-rw-r--r--src/examples/rrdJFlotTwo.html110
1 files changed, 16 insertions, 94 deletions
diff --git a/src/examples/rrdJFlotTwo.html b/src/examples/rrdJFlotTwo.html
index 4d1c79c..ce015f5 100644
--- a/src/examples/rrdJFlotTwo.html
+++ b/src/examples/rrdJFlotTwo.html
@@ -23,17 +23,8 @@
<html>
- <script type="text/javascript" src="../lib/binaryXHR.js"></script>
- <script type="text/javascript" src="../lib/rrdFile.js"></script>
- <script type="text/javascript" src="../lib/rrdMultiFile.js"></script>
-
- <!-- rrdFlot class needs the following four include files !-->
- <script type="text/javascript" src="../lib/rrdFlotSupport.js"></script>
- <script type="text/javascript" src="../lib/rrdFlot.js"></script>
- <script type="text/javascript" src="../../flot/jquery.js"></script>
- <script type="text/javascript" src="../../flot/jquery.flot.js"></script>
- <script type="text/javascript" src="../../flot/jquery.flot.selection.js"></script>
- <script type="text/javascript" src="../../flot/jquery.flot.tooltip.js"></script>
+ <script type="text/javascript" src="../lib/javascriptrrd.wlibs.js"></script>
+ <!-- the above script replaces the rrdfFlotAsync,rrdFlot, rrdFlotSelection, rrdFile, rrdMultiFile, binaryXHR and all the jquery libraries -->
<head>
<title>RRD Graphs with Flot</title>
</head>
@@ -59,93 +50,24 @@
// Remove the Javascript warning
document.getElementById("infotable").deleteRow(0);
- // fname and rrd_data are the global variable used by all the functions below
- fname1=document.getElementById("input_fname1").value;
- rrd_data1=undefined;
- fname2=document.getElementById("input_fname2").value;
- rrd_data2=undefined;
-
- // This function updates the Web Page with the data from the RRD archive header
- // when a new file is selected
- function update_fname() {
- if ((rrd_data1==undefined) || (rrd_data2==undefined)) {
- return; /* some data still missing */
- }
-
- rrd_data_sum=new RRDFileSum([rrd_data1,rrd_data2]);
-
- // Finally, update the file name and enable the update button
- document.getElementById("fname1").firstChild.data=fname1;
- document.getElementById("fname2").firstChild.data=fname2;
+ var graph_opts={legend: { noColumns:4}};
+ var ds_graph_opts={'Oscilator':{ color: "#ff8000",
+ lines: { show: true, fill: true, fillColor:"#ffff80"} },
+ 'Idle':{ label: 'IdleJobs', color: "#00c0c0",
+ lines: { show: true, fill: true} },
+ 'Running':{color: "#000000",yaxis:2}};
- var graph_opts={legend: { noColumns:4}};
- var ds_graph_opts={'Oscilator':{ color: "#ff8000",
- lines: { show: true, fill: true, fillColor:"#ffff80"} },
- 'Idle':{ label: 'IdleJobs', color: "#00c0c0",
- lines: { show: true, fill: true} },
- 'Running':{color: "#000000",yaxis:2}};
-
- // the rrdFlot object creates and handles the graph
- var f=new rrdFlot("mygraph",rrd_data_sum,graph_opts,ds_graph_opts);
- }
-
- // This is the callback function that,
- // given a binary file object,
- // verifies that it is a valid RRD archive
- // and performs the update of the Web page
- function update_fname_handler1(bf) {
- var i_rrd_data=undefined;
- if (bf.getLength()<1) {
- alert("File "+fname1+" is empty (possibly loading failed)!");
- return 1;
- }
- try {
- var i_rrd_data=new RRDFile(bf);
- } catch(err) {
- alert("File "+fname1+" is not a valid RRD archive!\n"+err);
- }
- if (i_rrd_data!=undefined) {
- rrd_data1=i_rrd_data;
- update_fname()
- }
- }
-
- function update_fname_handler2(bf) {
- var i_rrd_data=undefined;
- if (bf.getLength()<1) {
- alert("File "+fname2+" is empty (possibly loading failed)!");
- return 1;
- }
- try {
- var i_rrd_data=new RRDFile(bf);
- } catch(err) {
- alert("File "+fname2+" is not a valid RRD archive!\n"+err);
- }
- if (i_rrd_data!=undefined) {
- rrd_data2=i_rrd_data;
- update_fname()
- }
- }
+ // the rrdFlot object creates and handles the graph
+ flot_obj=new rrdFlotSumAsync("mygraph",null,graph_opts,ds_graph_opts);
// this function is invoked when the RRD file name changes
function fname_update() {
- /* invalidate them, so we know when they are both loaded */
- rrd_data1=undefined;
- rrd_data2=undefined;
-
- fname1=document.getElementById("input_fname1").value;
- try {
- FetchBinaryURLAsync(fname1,update_fname_handler1);
- } catch (err) {
- alert("Failed loading "+fname1+"\n"+err);
- }
- fname2=document.getElementById("input_fname2").value;
- try {
- FetchBinaryURLAsync(fname2,update_fname_handler2);
- } catch (err) {
- alert("Failed loading "+fname2+"\n"+err);
- }
- }
+ var fname1=document.getElementById("input_fname1").value;
+ var fname2=document.getElementById("input_fname2").value;
+ flot_obj.reload([fname1,fname2]);
+ document.getElementById("fname1").firstChild.data=fname1;
+ document.getElementById("fname2").firstChild.data=fname2;
+ }
</script>
</body>