<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>jquery-flot plug-in data visualization display </title>
<link rel= "stylesheet" href= ". /css/blue.css "media=" screen "/>
<script src= ". /jquery-1.10.2.min.js "></script>
<script src= ". /jquery.flot.v081.js "></script>
<!--[If ie]>
<script src= ". /excanvas.js "></script>
<! [endif]-->
<style type= "Text/css" >
Body{font-family:arial,helvetica,sans-serif;}
/*table{border-collapse:collapse;width:100%;}
Caption{font-weight:bold;font-size:16px;color: #61b1ee; margin-bottom:6px;}
td,th{padding:5px;border:1px solid #aaa; text-align:center;} */
. Legend Td,.legend th{padding:2px;border:0;}
#wrapper >h1{padding:0.4em 0;}
</style>
<body>
<div id= "wrapper" >
<ul id= "NAV" >
<li><a href= "index.html" class= "Current" > Visual display Statistics </a></li>
<li><a href= "#" > Using Flot plugins </a></li>
</ul>
<div id= "Content" >
<div id= "DataArea" >
<!--<table>
<caption> Site Visitor Statistics </caption>
<tbody>
<tr>
<td></td>
<th>8 Point </th>
<th>9 Point </th>
<TH>10 Point </th>
<th>11 Point </th>
<th>12 Point </th>
</tr>
<tr>
<th> site A</th>
<td>560</td>
<td>900</td>
<td>1200</td>
<td>1400</td>
<td>1500</td>
</tr>
<tr>
<th> site B</th>
<td>620</td>
<td>1200</td>
<td>1000</td>
<td>1500</td>
<td>1450</td>
</tr>
<tr>
<th> site C</th>
<td>420</td>
<td>1300</td>
<td>1800</td>
<td>1550</td>
<td>1600</td>
</tr>
<tr>
<th> site D</th>
<td>300</td>
<td>600</td>
<td>1300</td>
<td>1600</td>
<td>1800</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id= "Footer" >powered by Dennis ji.</div>
</div>
</body>
<script type= "Text/javascript" >
$ (function () {
var data = [
{
Label: "Site A",
data:[
[12,1500],
[11,1400],
[10,1200],
[9,900],
[8,560]
]
},
{
Label: "Site B",
data:[
[12,1450],
[11,1500],
[10,1000],
[9,1200],
[8,620]
]
},
{
Label: "Site C",
data:[
[12,1600],
[11,1550],
[10,1800],
[9,1300],
[8,420]
]
},
{
Label: "Site D",
data:[
[12,1800],
[11,1600],
[10,1300],
[9,600],
[8,300]
]
}
];
var options = {
legend:{
Show:true,
Labelformatter:null,
X, y positioning of the margin value of the margin:10,//[x,y] label
Position: "NE",//label positioning "NE" (Default is NE): is top-right, "NW": Is Top-left, "se": Is bottom-right, "SW": Is Bottom-left,
Labelboxbordercolor: "#dbf5ab",//Label object border color
BackgroundColor: "#dbf5ab",//Label object background color
backgroundopacity:0.5//Label object background color transparency settings
},
points:{
Show:true,
Radius:3
},
lines:{
Show:true
},
grid:{
Hoverable:true,
Clickable:true
}
};
Get display Area
var $dataarea = $ ("#dataarea");
$dataarea. CSS ("width", "600px");
$dataarea. CSS ("height", "300px");
$.plot (dataarea,data,options);
function Showtooltip (x,y,contents) {
$ (' <div id= ' tooltip > ' +contents+ ' </div> '). CSS ({
Position: ' Absolute ',
Display: ' None ',
top:y+5,//used to parameter Y
left:x+5,//for parameter X
border: ' 1px solid #fdd ',
padding: ' 2px ',
' Background-color ': ' #fee ',
opacity:0.8
}). AppendTo ("Body"). FadeIn (200);
}
var previouspoint = null;
$dataarea. Bind (' Plothover ', function (E,pos,item) {
if (item) {
if (previouspoint! = item.datapoint) {
Previouspoint = Item.datapoint;
$ ("#tooltip"). Remove ();
var x = item.datapoint[0].tofixed (2),
y = item.datapoint[1].tofixed (2);
Showtooltip (item.pagex,item.pagey,item.series.label+ ":" +x+ "point Visitor:" +y);
}
} else{//Otherwise delete the cue layer, emptying the current point marker
$ ("#tooltip"). Remove ();
Previouspoint = null;
};
});
});
</script>
jquery Plugin Flot Actual demo