Guest User

Untitled

a guest
May 23rd, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. $(document).ready(function () {
  2.  
  3. // set up plot
  4. $.jqplot.config.enablePlugins = true;
  5.  
  6. s1 = [['23-May-08',1],['24-May-08',4],['25-May-08',2],['26-May-08', 6]];
  7.  
  8. plot1 = $.jqplot('chart1',[s1],{
  9. title: 'Highlighting, Dragging, Cursor and Trend Line',
  10. axes: {
  11. xaxis: {
  12. renderer: $.jqplot.DateAxisRenderer,
  13. tickOptions: {
  14. formatString: '%#m/%#d/%y'
  15. },
  16. numberTicks: 4
  17. },
  18. yaxis: {
  19. tickOptions: {
  20. formatString: '$%.2f'
  21. }
  22. }
  23. },
  24. highlighter: {
  25. sizeAdjust: 10,
  26. tooltipLocation: 'n',
  27. tooltipAxes: 'y',
  28. tooltipFormatString: '<b><i><span style="color:red;">hello</span></i></b> %.2f',
  29. useAxesFormatters: false
  30. },
  31. cursor: {
  32. show: true
  33. }
  34. });
  35.  
  36. // add our hook, to fire after a series update
  37. $.jqplot.postDrawSeriesHooks.push(updatedSeries);
  38.  
  39. function updatedSeries(sctx, options) {
  40. console.log(plot1.series[0].data); //data for the series is here
  41. }
  42.  
  43. });
  44.  
  45. [
  46. Array[2]
  47. ,
  48. Array[2]
  49. ,
  50. Array[2]
  51. ,
  52. Array[2]
  53. ]
  54.  
  55. $("#chart1").on("jqplotClick", function(ev, gridpos, datapos, neighbor) {
  56. if ( neighbor ) {
  57. // specific point that has been clicked
  58. console.log('x:' + neighbor.data[0] + ' y:' + neighbor.data[1]);
  59. }
  60. // all the data from this plot's single series
  61. console.log(plot1.series[0].data);
  62. });
  63.  
  64. var plots = [
  65. $.jqplot('chart1', [s0], graph_opts),
  66. $.jqplot('chart2', [s1], graph_opts)
  67. ];
  68. $("#chart1, #chart2").on("jqplotClick", function(ev, gridpos, datapos, neighbor) {
  69. var data = [];
  70. $.each(plots, function(key, plot) {
  71. data[key] = plot.series[0].data;
  72. });
  73.  
  74. var ajax_opts = {
  75. url: ajax_info.url,
  76. type: 'post',
  77. async: true,
  78. cache: false,
  79. dataType: 'json',
  80. data: {
  81. action: 'store_graphs',
  82. data: data
  83. },
  84. success: function( response ) {
  85. console.log(response);
  86. },
  87. error: function( xhr, textStatus, e ) {
  88. console.log(xhr.responseText);
  89. }
  90. };
  91. $.ajax(ajax_opts);
  92. });
Advertisement
Add Comment
Please, Sign In to add comment