add crappy download link (not really)
authorJeremy Tan <[email protected]>
Mon, 14 Oct 2013 11:22:09 +0000 (19:22 +0800)
committerJeremy Tan <[email protected]>
Mon, 14 Oct 2013 11:22:09 +0000 (19:22 +0800)
testing/MCTXWeb/public_html/graph.html
testing/MCTXWeb/public_html/static/mctx.graph.js

index 137c004..be942bf 100644 (file)
@@ -8,9 +8,9 @@
     <![endif]-->
     <script type="text/javascript" src="static/jquery-1.10.1.min.js"></script>
     <script type="text/javascript" src="static/jquery.flot.min.js"></script>
+    
     <script type="text/javascript" src="static/mctx.gui.js"></script>
     <script type="text/javascript" src="static/mctx.graph.js"></script>
-    
     <link rel="stylesheet" type="text/css" href="static/style.css">
     <link rel="stylesheet" type="text/css" href="static/nav-menu.css">
     <script type="text/javascript">
@@ -29,7 +29,6 @@
       }).always(function () {
         $(document).ready(function () {
           $("#graph-controls").setDevices();
-          //$("#graph-run").runButton();
         });
       });
 
           <div class="widget">
             <div class="title">Graph</div>
               <div id="graph" class="plot">
-                <!-- graph placeholder -->
+              
               </div>
+              <!-- graph placeholder -->
+              <!--<div id="graph" class="plot">
+                
+              </div>-->
           </div>
           <div class="widget" id="graph-controls">
               <!--<div class="title">Visualise</div>-->
                 </div>
                 <input type="button" value="Run" id="graph-run" onClick="$('#graph-run').runButton()">
                 <input type="button" value="Open New Graph" disabled>
-                <input type="button" value="Save Graph Image" disabled>
+                <input type="button" value="Save Graph Image" id="saveimage">
                 <input type="button" value="Dump Raw Data" disabled>
+                <script>
+                  $("#saveimage").click(function () {
+                    $("canvas").each(function () {
+                      var image = new Image();
+                      
+                      window.open(this.toDataURL("image/png"));
+                      $("#graph-controls").append(image);
+                    });
+                  });
+                </script>
             </div>
         
         <!-- TODO: Put this on its own page? 
index 687db84..b91eab3 100644 (file)
@@ -15,6 +15,7 @@ mctx.graph.dependent = null;
 mctx.graph.independent = null;
 mctx.graph.timer = null;
 mctx.graph.running = false;
+mctx.graph.chart = null;
 
 /**
  * Helper - Calculate pairs of (dependent, independent) values
@@ -89,7 +90,7 @@ $.fn.setDevices = function() {
     $("#xaxis").deployDevices("radio", false, 'xaxis');
     $("#yaxis").deployDevices("checkbox", true, 'yaxis');
     $("#current_time").val(data.running_time);
-    //Add event listeners for when the inputs are changed
+    //Add event listeners for when the
     $(".change input").change(function () {
       $("#graph").setGraph();
     });
@@ -164,7 +165,14 @@ function graphUpdater() {
         }
       });
       
-      $.plot("#graph", plot_data);
+      //$.plot("#graph", plot_data);
+      if (mctx.graph.chart !== null) {
+        mctx.graph.chart.setData(plot_data);
+        mctx.graph.chart.setupGrid(); 
+        mctx.graph.chart.draw();
+      } else {
+        mctx.graph.chart = $.plot("#graph", plot_data);
+      }
       if (mctx.graph.running) {
         mctx.graph.timer = setTimeout(updater, 1000);
       }

UCC git Repository :: git.ucc.asn.au