Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. var option = {
  2. chart: { renderTo: "chartDiv", marginleft: 100 },
  3. title: {
  4. text: '',
  5. x: -20 //center
  6. },
  7. xAxis: {
  8. title: {
  9. text: "Shifts"
  10. },
  11.  
  12.  
  13. },
  14. yAxis: {
  15. title: {
  16. text: "Volume"
  17. },
  18. min: 0
  19. },
  20. tooltip: {
  21. crosshairs: true,
  22. shared: true,
  23. formatter: function () {
  24.  
  25. var s = [];
  26. s.push('<span> Day: <strong>' + this.points[0].x + '</strong></span>');
  27. $.each(this.points, function (i, point) {
  28. s.push('<span style="color:' + point.series.color + ';font-weight:bold;">' + point.series.name + ' : ' +
  29. Math.round(point.y * 1000) / 1000 + '<span>');
  30. });
  31.  
  32. return s.join('<br />');
  33. }
  34.  
  35. },
  36. legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', floating: true, borderWidth: 0, floating: false },
  37. plotOptions: {
  38.  
  39. }
  40.  
  41. };
  42.  
  43. function generateChart(shiftNum, days) {
  44. var chart = new Highcharts.Chart(option);
  45. for (series = 0; series < shiftNum; series++) {
  46. chart.addSeries({
  47. type: 'bar',
  48.  
  49. });
  50. }
  51. for (i = 1; i < days; i++) {
  52.  
  53. $.ajax({
  54. type: "POST",
  55. url: "/ajaxcall/ShiftData",
  56. dataType: "json",
  57. data: JSON.stringify({
  58. 'shiftnum': shiftNum,
  59. 'dayOfMonth': i
  60. }),
  61. contentType: 'application/json; charset=utf-8',
  62. success: function(result) {
  63. if (result.Success) {
  64. $.each(result.Report, function(s, rep) {
  65. chart.series[s].data.push([i, rep.FinalVol]);
  66. });
  67. }
  68. },
  69. complete: function() {
  70. console.log(chart);
  71. chart.xAxis[0].isDirty = true;
  72. chart.redraw(); //This gives error
  73.  
  74. }
  75. });
  76. }
  77. }
  78. generateChart(2, 7);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement