summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sfiligoi <isfiligoi@ucsd.edu>2010-01-26 20:57:23 +0000
committerIgor Sfiligoi <isfiligoi@ucsd.edu>2010-01-26 20:57:23 +0000
commit3bfd87c4dbf8109487109223ddaea34615eaf67c (patch)
tree988961bb738ff787a70cc0a100a2067dcceee8a4
parentd7f3390b3edad2ab7215112c19afd14c2badb90e (diff)
Similar to rrdJFlot, but this plots the sum of two files
-rw-r--r--src/examples/rrdJFlotTwo.html141
1 files changed, 141 insertions, 0 deletions
diff --git a/src/examples/rrdJFlotTwo.html b/src/examples/rrdJFlotTwo.html
new file mode 100644
index 0000000..9719dde
--- /dev/null
+++ b/src/examples/rrdJFlotTwo.html
@@ -0,0 +1,141 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ Example HTML/javascript file that display the
+ content of two RRD archive files in a graph
+ using the Flot libraries
+ Part of the javascriptRRD package
+ Copyright (c) 2010 Igor Sfiligoi, isfiligoi@ucsd.edu
+ Frank Wuerthwein, fkw@ucsd.edu
+
+ Original repository: http://javascriptrrd.sourceforge.net/
+
+ MIT License [http://www.opensource.org/licenses/mit-license.php]
+
+-->
+
+<!--
+ This page requires Flot.
+
+ Repository: http://code.google.com/p/flot/
+
+-->
+
+<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>
+ <head>
+ <title>RRD Graphs with Flot</title>
+ </head>
+
+ <body>
+ <h1 id="title">RRD Graphs with Flot</h1>
+
+ RRD URL:
+ <input type="text" id="input_fname1" value="example4_s1.rrd"><br>
+ <input type="text" id="input_fname2" value="example4_s2.rrd"><br>
+ <button onclick="fname_update()">Update</button>
+ <hr>
+
+ <table id="infotable" border=1>
+ <tr><td colspan="21"><b>Javascript needed for this page to work</b></td></tr>
+ <tr><td><b>RRD file</b></td><td id="fname1" colspan="2">None</td><td id="fname2" colspan="3">None</td></tr>
+ </table>
+
+ <div id="mygraph"></div>
+
+ <script type="text/javascript">
+
+ // 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}};
+
+ // 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;
+ try {
+ var i_rrd_data=new RRDFile(bf);
+ } catch(err) {
+ alert("File "+fname1+" is not a valid RRD archive!");
+ }
+ if (i_rrd_data!=undefined) {
+ rrd_data1=i_rrd_data;
+ update_fname()
+ }
+ }
+
+ function update_fname_handler2(bf) {
+ var i_rrd_data=undefined;
+ try {
+ var i_rrd_data=new RRDFile(bf);
+ } catch(err) {
+ alert("File "+fname2+" is not a valid RRD archive!");
+ }
+ if (i_rrd_data!=undefined) {
+ rrd_data2=i_rrd_data;
+ update_fname()
+ }
+ }
+
+ // 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);
+ }
+ }
+
+ </script>
+ </body>
+</html>