PHP/JavaScript webapp to analyse spending habits
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stacking.html 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Flot Examples</title>
  6. <link href="layout.css" rel="stylesheet" type="text/css"></link>
  7. <!--[if IE]><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.stack.js"></script>
  11. </head>
  12. <body>
  13. <h1>Flot Examples</h1>
  14. <div id="placeholder" style="width:600px;height:300px;"></div>
  15. <p>With the stack plugin, you can have Flot stack the
  16. series. This is useful if you wish to display both a total and the
  17. constituents it is made of. The only requirement is that you provide
  18. the input sorted on x.</p>
  19. <p class="stackControls">
  20. <input type="button" value="With stacking">
  21. <input type="button" value="Without stacking">
  22. </p>
  23. <p class="graphControls">
  24. <input type="button" value="Bars">
  25. <input type="button" value="Lines">
  26. <input type="button" value="Lines with steps">
  27. </p>
  28. <script id="source">
  29. $(function () {
  30. var d1 = [];
  31. for (var i = 0; i <= 10; i += 1)
  32. d1.push([i, parseInt(Math.random() * 30)]);
  33. var d2 = [];
  34. for (var i = 0; i <= 10; i += 1)
  35. d2.push([i, parseInt(Math.random() * 30)]);
  36. var d3 = [];
  37. for (var i = 0; i <= 10; i += 1)
  38. d3.push([i, parseInt(Math.random() * 30)]);
  39. var stack = 0, bars = true, lines = false, steps = false;
  40. function plotWithOptions() {
  41. $.plot($("#placeholder"), [ d1, d2, d3 ], {
  42. series: {
  43. stack: stack,
  44. lines: { show: lines, steps: steps },
  45. bars: { show: bars, barWidth: 0.6 }
  46. }
  47. });
  48. }
  49. plotWithOptions();
  50. $(".stackControls input").click(function (e) {
  51. e.preventDefault();
  52. stack = $(this).val() == "With stacking" ? true : null;
  53. plotWithOptions();
  54. });
  55. $(".graphControls input").click(function (e) {
  56. e.preventDefault();
  57. bars = $(this).val().indexOf("Bars") != -1;
  58. lines = $(this).val().indexOf("Lines") != -1;
  59. steps = $(this).val().indexOf("steps") != -1;
  60. plotWithOptions();
  61. });
  62. });
  63. </script>
  64. </body>
  65. </html>