Current File : //home/tradevaly/www/node_modules/jquery.flot.tooltip/examples/threshold.html |
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>flot.tooltip plugin example page</title>
<meta name="author" content="@krzysu, myviews.pl">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<!--[if lte IE 8]><script src="js/excanvas.min.js"></script><![endif]-->
<script src="js/jquery.flot.js"></script>
<script src="js/jquery.flot.threshold.js"></script>
<script src="../js/jquery.flot.tooltip.js"></script>
<style type="text/css">
body {font-family: sans-serif; font-size: 16px; margin: 50px; max-width: 800px;}
#flotTip {}
</style>
</head>
<body>
<div id="header">
<h2>Thresholds</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder" style="width:800px; height:450px;"></div>
</div>
<p>With the threshold plugin, you can apply a specific color to the part of a data series below a threshold. This is can be useful for highlighting negative values, e.g. when displaying net results or what's in stock.</p>
<p class="controls">
<button>Threshold at 5</button>
<button>Threshold at 0</button>
<button>Threshold at -2.5</button>
</p>
</div>
<div id="footer">
Copyright © 2007 - 2013 IOLA and Ole Laursen
</div>
<script type="text/javascript">
$(function() {
var d1 = [];
for (var i = 0; i <= 60; i += 1) {
d1.push([i, parseInt(Math.random() * 30 - 10)]);
}
function plotWithOptions(t) {
$.plot("#placeholder", [{
data: d1,
label: "test",
color: "rgb(30, 180, 20)",
threshold: {
below: t,
color: "rgb(200, 20, 30)"
},
lines: {
steps: true
}
}], {
grid: {
hoverable: true //IMPORTANT! this is needed for tooltip to work
},
tooltip: {
show: true,
content: "x: %x, y: %y, series: %s"
}
});
}
plotWithOptions(0);
$(".controls button").click(function (e) {
e.preventDefault();
var t = parseFloat($(this).text().replace("Threshold at ", ""));
plotWithOptions(t);
});
// Add the Flot version string to the footer
$("#footer").prepend("Flot " + $.plot.version + " – ");
});
</script>
</body>
</html>