1. Josh Caldwell
  2. jqplot

Source

jqplot / examples / highlighter2.html

<!DOCTYPE html>

<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Highlighter Test</title>
  <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../src/excanvas.js"></script><![endif]-->
  
  <link rel="stylesheet" type="text/css" href="../src/jquery.jqplot.css" />
  <link rel="stylesheet" type="text/css" href="examples.css" />
  
  <!-- BEGIN: load jquery -->
  <script language="javascript" type="text/javascript" src="../src/jquery-1.5.1.min.js"></script>
  <!-- END: load jquery -->
  
  <!-- BEGIN: load jqplot -->
  <script language="javascript" type="text/javascript" src="../src/jquery.jqplot.js"></script>
  <!-- END: load jqplot -->


<script language="javascript" type="text/javascript">

$(document).ready(function(){
      $.jqplot.config.enablePlugins = true;

// function that is run when the mouse moves inside of the plot.
    function myMove (ev, gridpos, datapos, neighbor, plot) {
        if (neighbor == null) {
            $('#myToolTip').fadeOut().empty();
            isShowing = false;
        }
        if (neighbor != null) {
            if ($('#myToolTip').is(':hidden')) {
                var d = new Date();
                var myText = d.getSeconds();   // could be any function pulling data from anywhere.  
                $('#myToolTip').html(myText).css({left:gridpos.x, top:gridpos.y}).fadeIn();
            }
        }
    }
    
// Here is how you attach the custom callback to the mouse move event on the plot.
$.jqplot.eventListenerHooks.push(['jqplotMouseMove', myMove]);

   s1 = [3, 7, 4, 9, 11, 12];

   plot1 = $.jqplot('chart1',[s1],{
       title: 'Highlighting'
   });
   
   $('#chart1').append('<div id="myToolTip" style="position:absolute;display:none;background:#E5DACA;padding:4px;"></div>');
   
});

</script>
  </head>
  <body>
<?php include "nav.inc"; ?>
<p>This page demonstrates creating your own custom highlighter by attaching a callback to the 'jqplotMouseMove' event.</p>
<div id="chart1" class="plot" style="width:500px;height:300px;"></div>

  </body>
</html>