_positive_review_graph.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <div class="container-fluid">
  2. <canvas id="myPosChart" width="960" height="320"></canvas>
  3. <canvas id="myNegChart" width="960" height="120"></canvas>
  4. </div>
  5. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
  6. <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js" integrity="sha256-TQq84xX6vkwR0Qs1qH5ADkP+MvH0W+9E7TdHJsoIQiM=" crossorigin="anonymous"></script>
  7. <script>
  8. var ctx = document.getElementById("myPosChart");
  9. var neg_ctx = document.getElementById("myNegChart");
  10. var endpoint = 'http://178.128.152.51:8000/managers/graphs/review-analysis';
  11. $.ajax({
  12. type: "get",
  13. url: endpoint,
  14. dataType: 'json',
  15. success: function(data) {
  16. var myBarChart = new Chart(ctx, {
  17. type: 'bar',
  18. data: {
  19. labels: data.labels,
  20. datasets: [
  21. {
  22. label: data.weeks[0],
  23. data: data.pos_data[0],
  24. borderColor: 'rgb(24, 106, 59)',
  25. backgroundColor: 'rgb(24, 106, 59)',
  26. borderWidth: 1,
  27. fill: false
  28. },
  29. {
  30. label: data.weeks[1],
  31. data: data.pos_data[1],
  32. borderColor: 'rgb(25, 111, 61)',
  33. backgroundColor: 'rgb(25, 111, 61)',
  34. borderWidth: 1,
  35. fill: false
  36. },
  37. {
  38. label: data.weeks[2],
  39. data: data.pos_data[2],
  40. borderColor: 'rgb(30, 132, 73)',
  41. backgroundColor: 'rgb(30, 132, 73)',
  42. borderWidth: 1,
  43. fill: false
  44. },
  45. {
  46. label: data.weeks[3],
  47. data: data.pos_data[3],
  48. borderColor: 'rgb(34, 153, 84)',
  49. backgroundColor: 'rgb(34, 153, 84)',
  50. borderWidth: 1,
  51. fill: false
  52. },
  53. {
  54. label: data.weeks[4],
  55. data: data.pos_data[4],
  56. borderColor: 'rgb(39, 174, 96)',
  57. backgroundColor: 'rgb(39, 174, 96)',
  58. borderWidth: 1,
  59. fill: false
  60. },
  61. {
  62. label: data.weeks[5],
  63. data: data.pos_data[5],
  64. borderColor: 'rgb(125, 206, 160)',
  65. backgroundColor: 'rgb(125, 206, 160)',
  66. borderWidth: 1,
  67. fill: false
  68. },
  69. {
  70. label: data.weeks[6],
  71. data: data.pos_data[6],
  72. borderColor: 'rgb(130, 224, 170)',
  73. backgroundColor: 'rgb(130, 224, 170)',
  74. borderWidth: 1,
  75. fill: false
  76. },
  77. {
  78. label: data.weeks[7],
  79. data: data.pos_data[7],
  80. borderColor: 'rgb(171, 235, 198)',
  81. backgroundColor: 'rgb(171, 235, 198)',
  82. borderWidth: 1,
  83. fill: false
  84. },
  85. {
  86. label: data.weeks[8],
  87. data: data.pos_data[8],
  88. borderColor: 'rgb(130, 224, 170)',
  89. backgroundColor: 'rgb(130, 224, 170)',
  90. borderWidth: 1,
  91. fill: false
  92. },
  93. {
  94. label: data.weeks[9],
  95. data: data.pos_data[9],
  96. borderColor: 'rgb(171, 235, 198)',
  97. backgroundColor: 'rgb(171, 235, 198)',
  98. borderWidth: 1,
  99. fill: false
  100. }]
  101. },
  102. options: {
  103. scales: {
  104. yAxes: [{
  105. display: true,
  106. scaleLabel: {
  107. display: true,
  108. fontSize: 16,
  109. fontStyle: 'italic',
  110. labelString: 'Total review count'
  111. },
  112. ticks: {
  113. beginAtZero: true,
  114. stepSize: 1
  115. }
  116. }],
  117. xAxes: [{
  118. display: true,
  119. scaleLabel: {
  120. display: true,
  121. fontSize: 16,
  122. fontStyle: 'italic',
  123. labelString: 'Location'
  124. },
  125. ticks: {
  126. autoSkip: false
  127. },
  128. gridLines: {
  129. drawOnChartArea:false
  130. }
  131. }]
  132. },
  133. title: {
  134. display: true,
  135. fontSize: 16,
  136. text: "Review of this month in all platforms."
  137. }
  138. }
  139. });
  140. var myNegBarChart = new Chart(neg_ctx, {
  141. type: 'bar',
  142. data: {
  143. labels: data.labels,
  144. datasets: [
  145. {
  146. label: data.weeks[0],
  147. data: data.neg_data[0],
  148. borderColor: 'rgb(117, 3, 0)',
  149. backgroundColor: 'rgb(117, 3, 0)',
  150. borderWidth: 1,
  151. fill: false
  152. },
  153. {
  154. label: data.weeks[1],
  155. data: data.neg_data[1],
  156. borderColor: 'rgb(164, 8, 4)',
  157. backgroundColor: 'rgb(164, 8, 4)',
  158. borderWidth: 1,
  159. fill: false
  160. },
  161. {
  162. label: data.weeks[2],
  163. data: data.neg_data[2],
  164. borderColor: 'rgb(178, 5, 0)',
  165. backgroundColor: 'rgb(178, 5, 0)',
  166. borderWidth: 1,
  167. fill: false
  168. },
  169. {
  170. label: data.weeks[3],
  171. data: data.neg_data[3],
  172. borderColor: 'rgb(220, 6, 0)',
  173. backgroundColor: 'rgb(220, 6, 0)',
  174. borderWidth: 1,
  175. fill: false
  176. },
  177. {
  178. label: data.weeks[4],
  179. data: data.neg_data[4],
  180. borderColor: 'rgb(216, 59, 54)',
  181. backgroundColor: 'rgb(216, 59, 54)',
  182. borderWidth: 1,
  183. fill: false
  184. },
  185. {
  186. label: data.weeks[5],
  187. data: data.neg_data[5],
  188. borderColor: 'rgb(241, 8, 1)',
  189. backgroundColor: 'rgb(241, 8, 1)',
  190. borderWidth: 1,
  191. fill: false
  192. },
  193. {
  194. label: data.weeks[6],
  195. data: data.neg_data[6],
  196. borderColor: 'rgb(233, 61, 56)',
  197. backgroundColor: 'rgb(233, 61, 56)',
  198. borderWidth: 1,
  199. fill: false
  200. },
  201. {
  202. label: data.weeks[7],
  203. data: data.neg_data[7],
  204. borderColor: 'rgb(232, 83, 78)',
  205. backgroundColor: 'rgb(232, 83, 78)',
  206. borderWidth: 1,
  207. fill: false
  208. },
  209. {
  210. label: data.weeks[8],
  211. data: data.neg_data[8],
  212. borderColor: 'rgb(235, 119, 116)',
  213. backgroundColor: 'rgb(235, 119, 116)',
  214. borderWidth: 1,
  215. fill: false
  216. },
  217. {
  218. label: data.weeks[9],
  219. data: data.neg_data[9],
  220. borderColor: 'rgb(255, 157, 154)',
  221. backgroundColor: 'rgb(255, 157, 154)',
  222. borderWidth: 1,
  223. fill: false
  224. }]
  225. },
  226. options: {
  227. scales: {
  228. yAxes: [{
  229. display: true,
  230. scaleLabel: {
  231. display: true,
  232. fontSize: 16,
  233. fontStyle: 'italic',
  234. labelString: 'Total review count'
  235. },
  236. ticks: {
  237. beginAtZero: true,
  238. stepSize: 1
  239. }
  240. }],
  241. xAxes: [{
  242. display: true,
  243. ticks: {
  244. autoSkip: false
  245. },
  246. gridLines: {
  247. drawOnChartArea:false
  248. }
  249. }]
  250. },
  251. }
  252. });
  253. },
  254. error: function(error_data) {
  255. console.log(error_data);
  256. }
  257. });
  258. </script>