index.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Flot Examples: Thresholds</title>
  6. <link href="../examples.css" rel="stylesheet" type="text/css">
  7. <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../../excanvas.min.js"></script><![endif]-->
  8. <script language="javascript" type="text/javascript" src="../../jquery.js"></script>
  9. <script language="javascript" type="text/javascript" src="../../jquery.flot.js"></script>
  10. <script language="javascript" type="text/javascript" src="../../jquery.flot.threshold.js"></script>
  11. <script type="text/javascript">
  12. $(function() {
  13. var d1 = [];
  14. for (var i = 0; i <= 60; i += 1) {
  15. d1.push([i, parseInt(Math.random() * 30 - 10)]);
  16. }
  17. function plotWithOptions(t) {
  18. $.plot("#placeholder", [{
  19. data: d1,
  20. color: "rgb(30, 180, 20)",
  21. threshold: {
  22. below: t,
  23. color: "rgb(200, 20, 30)"
  24. },
  25. lines: {
  26. steps: true
  27. }
  28. }]);
  29. }
  30. plotWithOptions(0);
  31. $(".controls button").click(function (e) {
  32. e.preventDefault();
  33. var t = parseFloat($(this).text().replace("Threshold at ", ""));
  34. plotWithOptions(t);
  35. });
  36. // Add the Flot version string to the footer
  37. $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
  38. });
  39. </script>
  40. </head>
  41. <body>
  42. <div id="header">
  43. <h2>Thresholds</h2>
  44. </div>
  45. <div id="content">
  46. <div class="demo-container">
  47. <div id="placeholder" class="demo-placeholder"></div>
  48. </div>
  49. <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>
  50. <p class="controls">
  51. <button>Threshold at 5</button>
  52. <button>Threshold at 0</button>
  53. <button>Threshold at -2.5</button>
  54. </p>
  55. </div>
  56. <div id="footer">
  57. Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
  58. </div>
  59. </body>
  60. </html>