Changeset 648b048a9c5f5d8e0fb7d6ed20f40a352d602688

Show
Ignore:
Timestamp:
09/26/08 12:29:24 (10 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1222432164 +0000
git-parent:

[c73b2b53bb74c7e8135888bc652903c9327f7dbd]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1222432164 +0000
Message:

experiment with flot

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ui/web/htdocs/.htaccess

    r668d3a3 r648b048  
    1010RewriteRule ^graph/template/bw/small/([^/]+)$ bw_settings.php?id=$1&type=small [PT,QSA] 
    1111RewriteRule ^amcharts/graph/settings/([^/]+) graph_settings.php?id=$1 [PT,QSA] 
     12RewriteRule ^flot/graph/settings/([^/]+) json_graph_flot.php?id=$1 [PT,QSA] 
  • ui/web/htdocs/bw_graph.php

    r668d3a3 r648b048  
    33<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
    44<title>Bandwidth Graph</title> 
     5<script src="js/jquery.min.js"></script> 
     6<script language="javascript" type="text/javascript" src="js/jquery.flot.js"></script> 
    57</head> 
    68<body> 
    7   <script type="text/javascript" src="js/swfobject.js"></script> 
    8         <div id="flashcontent"> 
    9                 <strong>You need to upgrade your Flash Player</strong> 
     9        <div id="maingraph" style="text-align:center; width:600px;"> 
     10        <span class="plot-title"></span><br/> 
     11        <div class="plot-area" style="width:600px;height:300px"></div><br/> 
     12        <div><div class="plot-legend">[legend]</div></div> 
    1013        </div> 
    1114 
    12         <script type="text/javascript"> 
    13                 // <![CDATA[             
    14                 var so = new SWFObject("amcharts/amline/amline.swf", "amline", "780", "400", "8", "#FFFFFF"); 
    15                 so.addVariable("path", "amcharts/amline/"); 
    16                 so.addVariable("settings_file", escape("graph/template/bw/large/<?php print $_GET['id'] ?>?start=<?php print $_GET['start'] ?>&end=<?php print $_GET['end'] ?>&cnt=<?php print isset($_GET['cnt']) ? $_GET['cnt'] : 500 ?>&view=<?php print $_GET['view'] ?>")); 
    17                 so.addVariable("preloader_color", "#999999"); 
    18                 so.write("flashcontent"); 
    19                 // ]]> 
    20         </script> 
    21 <!-- end of amline script --> 
     15  <script language="javascript"> 
     16  function plot_id(r) { 
     17    $("span.plot-title").html(r.title); 
     18    var placeholder = $("#maingraph > div.plot-area"); 
     19    placeholder.bind("plotselected", function (event, ranges) { 
     20/* 
     21        $("#selection").text(ranges.xaxis.from.toFixed(1) + " to " + ranges.xaxis.to.toFixed(1)); 
     22        var zoom = $("#zoom").attr("checked"); 
     23        if (zoom) 
     24            plot = $.plot(placeholder, data, 
     25                          $.extend(true, {}, options, { 
     26                              xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to } 
     27                          })); 
     28*/ 
     29    }); 
     30    r.options.legend.container = $("#maingraph div.plot-legend"); 
     31    var plot = $.plot(placeholder, r.data, r.options); 
     32 
     33/* 
     34    $("#clearSelection").click(function () { 
     35        plot.clearSelection(); 
     36    }); 
     37 
     38    $("#setSelection").click(function () { 
     39        plot.setSelection({ x1: 1994, x2: 1995 }); 
     40    }); 
     41*/ 
     42  } 
     43  $(document).ready(function () { 
     44    $('').ajaxError(function (a,b,c) { console.log(a); console.log(b); console.log(c); }); 
     45    //$.getJSON('bw_settings.php', {'id': '<?php print $_GET['id'] ?>', 'cnt': '<?php print $_GET['cnt'] ?>'}, function(r) { plot_id(r); } ); 
     46    $.getJSON('flot/graph/settings/48dc5706-abc8-29d2-ef23-ce754a8ec3d9?cnt=&start=1209600&end=&cnt=&start=1209600&end=', function(r) { plot_id(r); } ); 
     47  }); 
     48  </script> 
     49 
    2250</body> 
    2351</html> 
  • ui/web/htdocs/bw_settings.php

    r668d3a3 r648b048  
    1 <?xml version="1.0" encoding="UTF-8"?> 
    21<?php 
    32 
    4 require_once('Reconnoiter_amLine_Driver.php'); 
     3require_once('Reconnoiter_flot_Driver.php'); 
    54global $graph_settings; 
    65require_once('graph_settings.inc'); 
     
    1716} 
    1817 
    19 $driver = new Reconnoiter_amLine_Driver($start, $end, 
    20                                         isset($_GET['cnt']) ? $_GET['cnt'] : 400); 
     18$driver = new Reconnoiter_flot_Driver($start, $end, 
     19                                      isset($_GET['cnt']) ? $_GET['cnt'] : 400); 
    2120$i = 0; 
    2221$math = 'auto,2,round'; 
     
    4544 
    4645$i = 0; 
     46 
     47$data = $driver->graphdata(); 
     48$options = array( 
     49  'xaxis' => array ( 'mode' => 'time' ), 
     50  'legend' => array ( 'noColumns' => 1 ), 
     51  'selection' => array ( 'mode' => 'x' ), 
     52  'shadowSize' => 0, 
     53); 
     54print json_encode(array('data' => $data, 'options' => $options, 'title' => $driver->title())); 
    4755?> 
    48 <settings> 
    49 <type></type> 
    50 <?php if($_GET['type'] == 'small') { ?> 
    51   <legend><enabled>false</enabled></legend> 
    52   <grid><x><enabled>false</enabled></x></grid> 
    53   <plot_area> 
    54     <margins><top>20</top><right>50</right><bottom>30</bottom><left>50</left></margins> 
    55   </plot_area> 
    56 <?php } ?> 
    57 <data> 
    58 <chart> 
    59   <?php $driver->seriesXML() ?> 
    60   <?php $driver->graphsXML() ?> 
    61   <?php $driver->guidesXML() ?> 
    62 </chart> 
    63 </data> 
    64 <labels> 
    65   <label> 
    66     <x>0</x> 
    67     <y>0</y> 
    68     <align>center</align> 
    69     <text_size><?php print ($_GET['type'] == 'small') ? 12 : 16 ?></text_size> 
    70     <text_color>#000000</text_color> 
    71     <text><![CDATA[<?php print $driver->title() ?>]]></text> 
    72   </label> 
    73 </labels> 
    74 <decimals_separator>.</decimals_separator> 
    75 <values> 
    76  <y_left> 
    77   <unit><?php print $driver->autounit() ?></unit> 
    78  </y_left> 
    79 <?php if($_GET['type'] == 'small') { ?> 
    80   <x><enabled>false</enabled></x> 
    81 <?php } ?> 
    82 </values> 
    83 </settings> 
  • ui/web/htdocs/graph_controls.inc

    r668d3a3 r648b048  
    1 <script
     1<script type="text/javascript"
    22<!-- 
    3 var awake = {}; 
    4 function amChartInited(chart_id){ 
    5  // Ugliest hack on the planet. 
    6  while(!document.getElementById(chart_id).reloadSettings) { sleep(1); } 
    7  awake[chart_id] = true; 
    8  redraw_current_graph(); 
    9 } 
    10  
    113var current_graph_id = ''; 
    124var graphinfo; 
     
    179} 
    1810var recurse = 0; 
     11function plot_id(r) { 
     12      var placeholder = $("#maingraph > div.plot-area"); 
     13      placeholder.bind("plotselected", function (event, ranges) { 
     14        plot = $.plot(placeholder, data, 
     15                    $.extend(true, {}, options, { 
     16                               xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to } 
     17                             })); 
     18      }); 
     19      r.options.legend.container = $("#maingraph div.plot-legend"); 
     20      var plot = $.plot(placeholder, r.data, r.options); 
     21} 
    1922function redraw_current_graph() { 
    20   if(!awake.maingraph) return; 
    2123  if(graphinfo.datapoints.length > 0) { 
    22     $("#flashcontent").slideDown("normal"); 
    23     var url = "amcharts/graph/settings/" + graphinfo.id + 
    24               "?cnt=" + displayinfo.cnt + 
    25               "&start=" + displayinfo.start + 
    26               "&end=" + displayinfo.end; 
    27     document.getElementById("maingraph").reloadSettings(url); 
     24    $("#maingraph > div.plot-area").slideDown("normal"); 
     25    var url = "flot/graph/settings/" + graphinfo.id; 
     26    $.getJSON(url, {'cnt':displayinfo.cnt, 'start':displayinfo.start, 'end':displayinfo.end}, plot_id); 
    2827  } 
    2928  else { 
    30     $("#flashcontent").slideUp("normal"); 
     29    $("#maingraph > div.plot-area").slideUp("normal"); 
    3130  } 
    3231} 
     
    227226 
    228227<div> 
    229         <script type="text/javascript" src="http://postgres83dev.office.omniti.com/reconnoiter/js/swfobject.js"></script> 
    230         <script type="text/javascript"> 
    231                 function mainGraphData(settings) { 
    232                         var mg = document.getElementById("maingraph"); 
    233                         mg.reloadSettings(settings); 
    234                 } 
    235         </script> 
    236         <div id="flashcontent"> 
    237                 <strong>You need to upgrade your Flash Player</strong> 
    238         </div> 
    239         <script type="text/javascript"> 
    240                 // <![CDATA[             
    241                 var so = new SWFObject("amcharts/amline/amline.swf", "maingraph", "697", "400", "8", "#FFFFFF"); 
    242                 so.addVariable("path", "amcharts/amline/"); 
    243                 so.addVariable("settings_file", escape("blank.xml")); 
    244                 so.addVariable("preloader_color", "#999999"); 
    245                 so.addVariable("chart_id", "maingraph"); 
    246                 so.addParam('wmode','transparent');//added for confirm box 
    247                 so.write("flashcontent"); 
    248                 // ]]> 
    249         </script> 
     228        <div id="maingraph"> 
     229        <div class="plot-area" style="width:780px;height:400px"></div> 
     230        <div class="plot-legend"></div> 
     231        </div> 
    250232        <form action="#" name="form4" id="form4" style="margin:1em 0;text-align:center;"> 
    251233        <fieldset> 
  • ui/web/htdocs/index.php

    r51b29b5 r648b048  
    88<script src="js/json2.js"></script> 
    99<script src="js/jquery.min.js"></script> 
     10<script src="js/jquery.flot.js"></script> 
    1011<script src="js/jquery.jeditable.pack.js"></script> 
    1112<script src="js/jquery.cookie.js" type="text/javascript"></script> 
  • ui/web/lib/Reconnoiter_DB.php

    rcbb1d8e r648b048  
    2525  function get_data_for_window($uuid, $name, $start, $end, $expected, $derive) { 
    2626    $type = preg_match('/^\d+$/', $uuid) ? '::integer' : '::uuid'; 
    27     $sth = $this->db->prepare("select * from stratcon.fetch_dataset(? $type,?,?,?,?,?)"); 
     27    $sth = $this->db->prepare("select sid, name, extract(epoch from rollup_time) as rollup_time, count_rows, avg_value from stratcon.fetch_dataset(? $type,?,?,?,?,?)"); 
    2828    $sth->execute(array($uuid,$name,$start,$end,$expected,$derive)); 
    2929    $rv = array();