summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sfiligoi <isfiligoi@ucsd.edu>2012-09-10 19:37:13 +0000
committerIgor Sfiligoi <isfiligoi@ucsd.edu>2012-09-10 19:37:13 +0000
commit1d4d341179de48e903e53d0daa37b931f0f34092 (patch)
treec69f2aa98edc29c224fa36ba837f4ff70c540a07
parent969e56cd3a8143f325320873c9a332116c3a6f96 (diff)
Add and example HTML page that shows the use of the new rrdflot_defaults.graph_only option, which strips off any non-essential element
-rw-r--r--src/examples/rrdJFlotSimple.html134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/examples/rrdJFlotSimple.html b/src/examples/rrdJFlotSimple.html
new file mode 100644
index 0000000..0f91ce0
--- /dev/null
+++ b/src/examples/rrdJFlotSimple.html
@@ -0,0 +1,134 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ Example HTML/javascript file that display the
+ content of a RRD archive file in a graph
+ using the Flot libraries
+ Part of the javascriptRRD package
+ Copyright (c) 2010 Frank Wuerthwein, fkw@ucsd.edu
+ Igor Sfiligoi, isfiligoi@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>
+
+ <!-- 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>
+ <head>
+ <title>RRD Graphs with Flot - Simplified version</title>
+ </head>
+
+ <body>
+ <h1 id="title">RRD Graphs with Flot - Simplified version</h1>
+
+ RRD URL: example3.rrd
+ <br>
+ <table width="100%">
+ <tr><td width="50%">
+ DS: SignChanger
+ <br>
+ RRA: 1
+ </td>
+ <td>
+ DS: Oscilator
+ <br>
+ RRA: 0
+ </td></tr>
+ </table>
+ <hr>
+
+ <table id="infotable" border=1>
+ <tr><td colspan="21"><b>Javascript needed for this page to work</b></td></tr>
+ </table>
+
+ <table width="100%">
+ <tr><td width="50%">
+ <div id="mygraph1"></div>
+ </td>
+ <td>
+ <div id="mygraph2"></div>
+ </td></tr>
+ </table>
+
+ <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
+ fname="example3.rrd"
+ rrd_data=undefined;
+
+ // This function updates the Web Page with the data from the RRD archive header
+ // when a new file is selected
+ function update_fname() {
+ // Finally, update the file name and enable the update button
+
+ 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 rrdflot_defaults1={graph_only:true,use_checked_DSs:true,checked_DSs:['SignChanger'],use_rra:true,rra:1}
+ // the rrdFlot object creates and handles the graph
+ var f=new rrdFlot("mygraph1",rrd_data,graph_opts,ds_graph_opts,rrdflot_defaults1);
+
+ var rrdflot_defaults2={graph_only:true,use_checked_DSs:true,checked_DSs:['Oscilator'],use_rra:true,rra:0}
+ // the rrdFlot object creates and handles the graph
+ var f=new rrdFlot("mygraph2",rrd_data,graph_opts,ds_graph_opts,rrdflot_defaults2);
+ }
+
+ // 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_handler(bf) {
+ var i_rrd_data=undefined;
+ try {
+ var i_rrd_data=new RRDFile(bf);
+ } catch(err) {
+ alert("File "+fname+" is not a valid RRD archive!\n"+err);
+ }
+ if (i_rrd_data!=undefined) {
+ rrd_data=i_rrd_data;
+ update_fname()
+ }
+ }
+
+ // this function is invoked when the RRD file name changes
+ function fname_update() {
+ try {
+ FetchBinaryURLAsync(fname,update_fname_handler);
+ } catch (err) {
+ alert("Failed loading "+fname+"\n"+err);
+ }
+ }
+
+
+fname_update();
+
+ </script>
+ </body>
+</html>