Guest User

Untitled

a guest
Jan 16th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. function getData() {
  2.  
  3.  
  4. var URL = '@Url.Action("LoadData")';
  5.  
  6. $.ajax({
  7. type: "GET",
  8. url: URL,
  9. data: { id_cource: $("#cource").val() },
  10. contentType: "application/json; charset=windows-2151",
  11. dataType: "json",
  12. success: function (response) {
  13.  
  14. alert("Great! Записи были обновлены успешно");
  15. },
  16. error: function (msg) {
  17. debugger;
  18. alert("Error");
  19. }
  20. });
  21.  
  22. jQuery(document).ready(function($) {
  23.  
  24. $("#chart").kendoChart({
  25. @*theme: $(document).data("kendoSkin") || "default",*@
  26. title: {
  27. text: "Анкета организации",
  28. font: "14px Arial,Helvetica,sans-serif",
  29. position: "top"
  30. },
  31.  
  32. legend: { position: "top" },
  33.  
  34. chartArea: {
  35. // width: 800,
  36. height: 1200
  37. },
  38.  
  39. dataSource: new kendo.data.DataSource({
  40. transport: {
  41. read: {
  42. url: '@Url.Action("LoadData", "Anketa_org")',
  43. data: { id_cource: $("#cource").val() },
  44. dataType: "json",
  45. type: "GET",
  46. contentType: "application/json; charset=windows-2151"
  47. }
  48. },
  49. schema: {
  50.  
  51. fields: {
  52. Col1: { type: "double" },
  53. Col2: { type: "double" },
  54. Legend: { type: "string" }
  55. }
  56.  
  57. }
  58. }),
  59.  
  60. seriesDefaults: { type: "column" },
  61. series:
  62. [{
  63. name: "Важность критерия",
  64. field: "Col1"
  65. },
  66. {
  67. name: "Удовлетворение полученным",
  68. field: "Col2"
  69. }],
  70.  
  71. categoryAxis: {
  72. field: "Legend",
  73.  
  74. labels: {
  75. template: "<#= shortLabels(value) #>",
  76. rotation: -90
  77. },
  78.  
  79. valueAxis: {
  80. labels: { format: "{0}%" },
  81. majorUnit: 10,
  82. max: 100
  83. },
  84. tooltip: {
  85. visible: true,
  86. format: "{0}%"
  87. }
  88. }
  89. });
  90.  
  91. });
  92.  
  93.  
  94.  
  95. function refresh() {
  96.  
  97.  
  98. var chart = $('#chart').data("kendoChart");
  99.  
  100. var dataSource = new kendo.data.DataSource({
  101. transport: {
  102. read: {
  103. type: "GET",
  104. url: '@Url.Action("LoadData")',
  105. data: { id_cource: $("#cource").val() },
  106. contentType: "application/json; charset=windows-2151",
  107. dataType: "json",
  108. }
  109. },
  110. schema: {
  111. model:{
  112. fields: {
  113. Col1: { type: "double" },
  114. Col2: { type: "double" },
  115. Legend: { type: "string" }
  116. }
  117. }
  118. }
  119. });
  120.  
  121.  
  122.  
  123. chart.dataSource = dataSource;
  124. chart.refresh();
  125. };
  126.  
  127.  
  128. Controller
  129.  
  130.  
  131. [HttpGet]
  132. public ActionResult BarCharts_org()
  133. {
  134. // WebMsgBox.Show("Привет");
  135. return View();
  136.  
  137. }
  138.  
  139. [HttpGet]
  140. public JsonResult LoadData(Guid id_cource)
  141. {
  142.  
  143. var ListItems = new List<Item>();
  144.  
  145. double[] tempVal_1 = new double[27];
  146. double[] tempVal_2 = new double[27];
  147. int cnt;
  148.  
  149. ...
  150.  
  151. for(int i=0;i<27; i++)
  152. {
  153. Item itm =new Item();
  154.  
  155. itm.Col1 = tempVal_1[i];
  156. itm.Col2 = tempVal_2[i];
  157. itm.Legend = tempStr[i];
  158. ListItems.Add(itm);
  159. }
  160.  
  161. return Json(ListItems, JsonRequestBehavior.AllowGet);
Add Comment
Please, Sign In to add comment