Changeset dfed3eb59c93220d58be194a69926922213ec314

Show
Ignore:
Timestamp:
10/11/08 21:59:13 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1223762353 +0000
git-parent:

[11f8bf87099c8a01239c24b9ebc9fd44eccf07ae]

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

build out tooltips, refs #22

Files:

Legend:

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

    r47a8b0a rdfed3eb  
    234234#browselist ul li ul li ul li ul li ul li span.text {background:url(../images/icon-data-txt.png) 60px 1px no-repeat;padding-left:75px;} 
    235235 
     236div.tooltip { 
     237  background: white; 
     238  opacity: 0.9; 
     239  border: 1px solid #999; 
     240  padding: 0 3px; 
     241} 
     242 
    236243/* graph list */ 
    237244#graphlist p.graph-search-summary {margin-bottom: 0;} 
  • ui/web/htdocs/graph_panel.inc

    r6e38cf9 rdfed3eb  
    1212} 
    1313var recurse = 0; 
    14 function plot_id(r, domid) { 
     14function plot_id(r, domid, redraw) { 
    1515      var placeholder = $(domid + " > div.plot-area"); 
    1616      placeholder.bind("plotselected", function (event, ranges) { 
    17         alert(ranges.xaxis.from + " -> " + ranges.xaxis.to); 
    18         plot = $.plot(placeholder, data, 
    19                     $.extend(true, {}, options, { 
    20                                xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to } 
    21                              })); 
     17        var start = new Date(Math.floor(ranges.xaxis.from)); 
     18        var end = new Date(Math.floor(ranges.xaxis.to)); 
     19        displayinfo.start = start.toUTCString(); 
     20        displayinfo.end = end.toUTCString(); 
     21        if(redraw) redraw(); 
     22      }); 
     23      if(!r.options.grid) r.options.grid = {}; 
     24      r.options.grid.hoverable = true; 
     25      $(domid + " > div.tooltip").remove(); 
     26      placeholder.bind("plothover", function (event, pos, item) { 
     27        if(item) { 
     28          if(! $(domid + " > div.tooltip")[0]) 
     29            $('<div class="tooltip"></div>').appendTo($(domid)); 
     30          $(domid + " > div.tooltip") 
     31            .html(item.datapoint[2] ? item.datapoint[2] : item.datapoint[1]) 
     32            .css( { top: $(domid).offset().top - 
     33                          placeholder.offset().top + item.pageY, 
     34                    left: item.pageX, 
     35                    position: 'absolute' }); 
     36        } 
     37        else { 
     38          $(domid + " > div.tooltip").remove(); 
     39        } 
    2240      }); 
    2341      r.options.legend.container = $(domid + " div.plot-legend"); 
     
    3452    var url = "flot/graph/settings/" + graphinfo.id; 
    3553    $(domid + " .plot-area").html('<div class="centered"><div class="loading">&nbsp;</div></div>'); 
    36     $.getJSON(url, {'cnt':displayinfo.cnt, 'start':displayinfo.start, 'end':displayinfo.end}, function (r) { plot_id(r,domid); }); 
     54    $.getJSON(url, {'cnt':displayinfo.cnt, 'start':displayinfo.start, 'end':displayinfo.end}, function (r) { plot_id(r,domid, function() { redraw_current_graph("#maingraph"); }); }); 
    3755  } 
    3856  else { 
     
    4361  if(recurse > 0) return; 
    4462  var str = JSON.stringify(graphinfo); 
    45   $("#payload").html(str); 
     63  //$("#payload").html(str); 
    4664  $.post("json/graph/store", 
    4765         {'json':str}, 
     
    283301        <div class="plot-area" style="width:780px;height:400px"></div> 
    284302        <div class="plot-legend"></div> 
     303        <div class="plot-debug"></div> 
    285304        </div> 
    286305        <form action="#" name="form4" id="form4" style="margin:1em 0;text-align:center;"> 
  • ui/web/htdocs/worksheet_panel.inc

    rac2e836 rdfed3eb  
    55<!-- 
    66var ws_displayinfo = { start : 14*86400, cnt: '100', end: '' }; 
    7 function plot_id(r, domid) { 
    8       var placeholder = $(domid + " > div.plot-area"); 
    9       placeholder.bind("plotselected", function (event, ranges) { 
    10         alert(ranges.xaxis.from + " -> " + ranges.xaxis.to); 
    11         plot = $.plot(placeholder, data, 
    12                     $.extend(true, {}, options, { 
    13                                xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to } 
    14                              })); 
    15       }); 
    16       r.options.legend.container = $(domid + " div.plot-legend"); 
    17       if(!r.options.yaxis) r.options.yaxis = {}; 
    18       if(r.options.yaxis.suffix) 
    19         r.options.yaxis.tickFormatter = function (val, axis) { 
    20           return val.toFixed(axis.tickDecimals) + r.options.yaxis.suffix; 
    21         }; 
    22       var plot = $.plot(placeholder, r.data, r.options); 
    23 } 
    247function ws_redraw_graph(info, domid) { 
    258  if(info.datapoints.length > 0) { 
     
    2912                    'start':ws_displayinfo.start, 
    3013                    'end':ws_displayinfo.end}, 
    31               function (r) { plot_id(r,domid); }); 
     14              function (r) { plot_id(r,domid, function() { ws_displayinfo = displayinfo; load_worksheet(); }); }); 
    3215  } 
    3316  else { 
  • ui/web/lib/Reconnoiter_ChangeSet.php

    rc33606c rdfed3eb  
    88    $db = Reconnoiter_DB::getDB(); 
    99    $this->data = $db->get_var_for_window($uuid, $name, $start, $end, $cnt); 
    10     end($this->data); 
    11     $last = current($this->data); 
     10    $last = end($this->data); 
    1211    if($last) $this->last_value = $last['value']; 
    1312  } 
    1413  function points() { 
    15     throw Exception("You can't use a ChangeSet to drive a timeline"); 
     14    return array_keys($this->data); 
    1615  } 
    1716  function description($ts) { 
     
    2423    return $this->last_value; 
    2524  } 
     25  function expression() { return ''; } 
    2626} 
    2727 
  • ui/web/lib/Reconnoiter_DB.php

    r6e38cf9 rdfed3eb  
    3535  function get_var_for_window($uuid, $name, $start, $end, $expected) { 
    3636    $sth = preg_match('/^\d+$/', $uuid) ? 
    37       $this->db->prepare("select * from stratcon.fetch_varset(? ::int,?,?,?,?)") : 
    38       $this->db->prepare("select * from stratcon.fetch_varset(? ::uuid,?,?,?,?)"); 
     37      $this->db->prepare("select sid, extract(epoch from whence) as whence, name, value from stratcon.fetch_varset(? ::int,?,?,?,?)") : 
     38      $this->db->prepare("select sid, extract(epoch from whence) as whence, name, value from stratcon.fetch_varset(? ::uuid,?,?,?,?)"); 
    3939    $sth->execute(array($uuid,$name,$start,$end,$expected)); 
    4040    $rv = array(); 
  • ui/web/lib/Reconnoiter_DataSet.php

    r47a8b0a rdfed3eb  
    3131    return null; 
    3232  } 
     33  function expression() { 
     34    return $this->expr; 
     35  } 
    3336  function data($ts, $attr = NULL) { 
    3437    if(!isset($attr)) $attr = $this->default_attr; 
  • ui/web/lib/Reconnoiter_flot_Driver.php

    r6e38cf9 rdfed3eb  
    2727    $i = 0; 
    2828    foreach($this->sets as $name => $set) { 
    29       $a[] = array ( 
     29      $ds = array ( 
     30        'reconnoiter_source_expression' => $set->expression(), 
     31        'reconnoiter_display_expression' => $this->sets_config[$name]['expression'], 
    3032        'label' => $this->sets_config[$name]['title'] ? $this->sets_config[$name]['title'] : $name, 
    3133        'data' => $this->graphdataset($set, $this->sets_config[$name]), 
    3234        'yaxis' => ($this->sets_config[$name]['axis'] == 'right') ? 2 : 1, 
    33         'lines' => array ( 'show' => 'true', 'fill' => '0.3', 'lineWidth' => '1' ) 
    3435      ); 
     36      if(get_class($set) == "Reconnoiter_DataSet") { 
     37        $ds['lines'] = array ( 'show' => 'true', 'fill' => '0.3', 'lineWidth' => '1' ); 
     38      } 
     39      if(get_class($set) == "Reconnoiter_ChangeSet") { 
     40        $ds['points'] = array ( 'show' => 'true', 'fill' => 'false', 'lineWidth' => 1, radius => 5 ); 
     41      } 
     42      $a[] = $ds; 
    3543    } 
    3644    $start_ts = $a[0]['data'][0][0]; 
     
    5462    $a = array(); 
    5563    $prev_value = '0'; 
    56     foreach ($this->series() as $ts) { 
    57       $value = $set->data($ts); 
    58       if($value != "") { 
    59         if(isset($config['expression'])) { 
    60           $value = $this->rpn_eval($value, $config['expression']); 
     64    $timeline = (get_class($set) == "Reconnoiter_ChangeSet") ? $set->points() : $this->series(); 
     65    foreach($timeline as $ts) { 
     66        $value = $set->data($ts); 
     67        if($value != "") { 
     68          if(isset($config['expression'])) { 
     69            $value = $this->rpn_eval($value, $config['expression']); 
     70          } 
     71          $desc = $set->description($ts); 
     72          if($desc) { 
     73            $a[] = array( $ts * 1000, "$value", $desc ); 
     74          } else { 
     75            $a[] = array( $ts * 1000, "$value" ); 
     76          } 
    6177        } 
    62         $desc = $set->description($ts); 
    63         if($desc) { 
    64           $a[] = array( $ts * 1000, "$value" ); 
    65         } else { 
    66           $a[] = array( $ts * 1000, "$value" ); 
    67         } 
     78        else $a[] = array( $ts * 1000, "" ); 
     79        $i++; 
    6880      } 
    69       else $a[] = array( $ts * 1000, "" ); 
    70       $i++; 
    71     } 
    7281    return $a; 
    7382  }