Guest User

Untitled

a guest
Feb 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4.  
  5. <script language="javascript" type="text/javascript" src="flot/jquery.js"></script>
  6. <script language="javascript" type="text/javascript" src="flot/jquery.flot.js"></script>
  7.  
  8. <script type="text/javascript">
  9.  
  10. $(document).ready( function() {
  11.  
  12. // Setup flot
  13. var options = {
  14. lines: { show: true },
  15. points: { show: true },
  16. xaxis: { tickDecimals: 0, tickSize: 1 }
  17. };
  18.  
  19. var data = [];
  20.  
  21. var chart = $("#chart");
  22.  
  23. $.plot(chart, data, options);
  24.  
  25. // Bind select
  26. $("#series").change( function() {
  27.  
  28. requestData($(this).val());
  29. });
  30.  
  31.  
  32. // Send request
  33. function requestData(series) {
  34.  
  35. $.ajax({
  36. url: "flotdata.cfm",
  37. method: "GET",
  38. data: {"series": series},
  39. dataType: "json",
  40. success: onData
  41. });
  42. }
  43.  
  44. // Handle response
  45. function onData(series) {
  46.  
  47. data[0] = series;
  48. $.plot(chart, data, options);
  49. }
  50. });
  51.  
  52. </script>
  53.  
  54. </head>
  55.  
  56. <body>
  57.  
  58. <select id="series">
  59. <option value="a">Series A</option>
  60. <option value="b">Series B</option>
  61. </select>
  62.  
  63. <div id="chart" style="height:300px;width:600px;" />
  64.  
  65. </body>
  66.  
  67. </html>
Add Comment
Please, Sign In to add comment