location-wise-reviews-man.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. {% extends 'manager-base.html' %}
  2. {% block content %}
  3. <div class="graph-card graph-card-shadow graph-container">
  4. <div style="width: 100%;">
  5. <canvas id="myChart" width="1200" height="300"></canvas>
  6. </div>
  7. </div>
  8. <div class="graph-card graph-card-shadow graph-container">
  9. <div id="bar-chart-container" style="position: relative; width: 70%;">
  10. <canvas id="googleLineChart" width="900" height="300"></canvas>
  11. </div>
  12. <div id="pie-chart-container" style="position: relative; width: 30%;">
  13. <canvas id="googlePieChart" width="200" height="150"></canvas>
  14. </div>
  15. </div>
  16. <div class="graph-card graph-card-shadow graph-container">
  17. <div style="position: relative; width: 70%;">
  18. <canvas id="facebookLineChart" width="900" height="300"></canvas>
  19. </div>
  20. <div style="position: relative; width: 30%;">
  21. <canvas id="facebookPieChart" width="200" height="150"></canvas>
  22. </div>
  23. </div>
  24. <!-- <div class="graph-card graph-card-shadow graph-container">-->
  25. <!-- <div style="position: relative; width: 70%;">-->
  26. <!-- <canvas id="yelpLineChart" width="900" height="300"></canvas>-->
  27. <!-- </div>-->
  28. <!-- <div style="position: relative; width: 30%;">-->
  29. <!-- <canvas id="yelpPieChart" width="200" height="150"></canvas>-->
  30. <!-- </div>-->
  31. <!-- </div>-->
  32. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
  33. <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>
  34. <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>
  35. <script>
  36. var ctx = document.getElementById("myChart");
  37. var google_line_ctx = document.getElementById("googleLineChart");
  38. var google_pie_ctx = document.getElementById("googlePieChart");
  39. var facebook_line_ctx = document.getElementById("facebookLineChart");
  40. var facebook_pie_ctx = document.getElementById("facebookPieChart");
  41. var location_id = document.getElementById("location_id").value;
  42. console.log(location_id)
  43. var endpoint = '/user/api/analytics/all-platform';
  44. params = {
  45. "location_id": location_id.trim()
  46. }
  47. console.log(params)
  48. $.ajax({
  49. type: "get",
  50. url: endpoint,
  51. data: params,
  52. dataType: 'json',
  53. success: function(data) {
  54. console.log(data)
  55. // All data together in a bar chart..
  56. var myBarChart = new Chart(ctx, {
  57. type: 'bar',
  58. data: {
  59. labels: data.google.labels,
  60. datasets: [
  61. {
  62. label: 'Google',
  63. data: data.google.total_review,
  64. borderColor: 'rgb(255, 204, 0)',
  65. backgroundColor: 'rgb(255, 204, 0)',
  66. borderWidth: 1,
  67. fill: false
  68. },
  69. {
  70. label: 'Facebook',
  71. data: data.facebook.total_review,
  72. borderColor: 'rgb(0, 51, 204)',
  73. backgroundColor: 'rgb(0, 51, 204)',
  74. borderWidth: 1,
  75. fill: false
  76. }]
  77. },
  78. options: {
  79. scales: {
  80. yAxes: [{
  81. ticks: {
  82. beginAtZero: true
  83. }
  84. }],
  85. xAxes: [{
  86. gridLines: {
  87. drawOnChartArea:false
  88. }
  89. }]
  90. },
  91. title: {
  92. display: true,
  93. fontSize: 16,
  94. text: "Review of this month in all platforms."
  95. }
  96. }
  97. });
  98. // Google review charts
  99. // Google line chart
  100. var myGoogleLineChart = new Chart(google_line_ctx, {
  101. type: 'line',
  102. data: {
  103. labels: data.google.labels,
  104. datasets: [
  105. {
  106. label: '1*',
  107. data: data.google.star_rating[0],
  108. borderColor: 'rgb(204, 0, 17)',
  109. backgroundColor: 'rgb(204, 0, 17)',
  110. borderWidth: 1,
  111. lineTension: 0,
  112. fill: false
  113. },
  114. {
  115. label: '2*',
  116. data: data.google.star_rating[1],
  117. borderColor: 'rgb(255, 119, 0)',
  118. backgroundColor: 'rgb(255, 119, 0)',
  119. borderWidth: 1,
  120. lineTension: 0,
  121. fill: false
  122. },
  123. {
  124. label: '3*',
  125. data: data.google.star_rating[2],
  126. borderColor: 'rgb(219, 208, 0)',
  127. backgroundColor: 'rgb(219, 208, 0)',
  128. borderWidth: 1,
  129. lineTension: 0,
  130. fill: false
  131. },
  132. {
  133. label: '4*',
  134. data: data.google.star_rating[3],
  135. borderColor: 'rgb(0, 157, 166)',
  136. backgroundColor: 'rgb(0, 157, 166)',
  137. borderWidth: 1,
  138. lineTension: 0,
  139. fill: false
  140. },
  141. {
  142. label: '5*',
  143. data: data.google.star_rating[4],
  144. borderColor: 'rgb(0, 97, 0)',
  145. backgroundColor: 'rgb(0, 97, 0)',
  146. borderWidth: 1,
  147. lineTension: 0,
  148. fill: false,
  149. }]
  150. },
  151. options: {
  152. borderJoinStyle: "bevel",
  153. scales: {
  154. yAxes: [{
  155. ticks: {
  156. beginAtZero: true
  157. }
  158. }],
  159. xAxes: [{
  160. gridLines: {
  161. drawOnChartArea:false
  162. }
  163. }]
  164. },
  165. title: {
  166. display: true,
  167. fontSize: 16,
  168. text: "Monthly review in Google."
  169. }
  170. }
  171. });
  172. // Google pie chart
  173. var myGooglePieChart = new Chart(google_pie_ctx, {
  174. type: 'pie',
  175. data: {
  176. labels: data.google.curr_month.label,
  177. datasets: [
  178. {
  179. data: data.google.curr_month.total,
  180. backgroundColor: [
  181. 'rgb(0, 97, 0)',
  182. 'rgb(0, 157, 166)',
  183. 'rgb(219, 208, 0)',
  184. 'rgb(255, 119, 0)',
  185. 'rgb(204, 0, 17)'
  186. ]
  187. }]
  188. },
  189. options: {
  190. title: {
  191. display: true,
  192. fontSize: 12,
  193. // position: 'bottom',
  194. text: 'All reviews of this month'
  195. }
  196. }
  197. });
  198. // Facebook review charts
  199. // Facebook line chart
  200. var myFacebookLineChart = new Chart(facebook_line_ctx, {
  201. type: 'line',
  202. data: {
  203. labels: data.facebook.labels,
  204. datasets: [
  205. {
  206. label: 'Not Recommended',
  207. data: data.facebook.star_rating[0],
  208. borderColor: 'rgb(204, 0, 17)',
  209. backgroundColor: 'rgb(204, 0, 17)',
  210. borderWidth: 1,
  211. lineTension: 0,
  212. fill: false
  213. },
  214. {
  215. label: 'Recommended',
  216. data: data.facebook.star_rating[1],
  217. borderColor: 'rgb(0, 51, 204)',
  218. backgroundColor: 'rgb(0, 51, 204)',
  219. borderWidth: 1,
  220. lineTension: 0,
  221. fill: false
  222. }]
  223. },
  224. options: {
  225. borderJoinStyle: "bevel",
  226. scales: {
  227. yAxes: [{
  228. ticks: {
  229. beginAtZero: true
  230. }
  231. }],
  232. xAxes: [{
  233. gridLines: {
  234. drawOnChartArea:false
  235. }
  236. }]
  237. },
  238. title: {
  239. display: true,
  240. fontSize: 16,
  241. text: "Monthly review in Facebook."
  242. }
  243. }
  244. });
  245. // Google pie chart
  246. var myFacebookPieChart = new Chart(facebook_pie_ctx, {
  247. type: 'pie',
  248. data: {
  249. labels: data.facebook.curr_month.label,
  250. datasets: [
  251. {
  252. data: data.facebook.curr_month.total,
  253. backgroundColor: [
  254. 'rgb(0, 51, 204)',
  255. 'rgb(204, 0, 17)'
  256. ]
  257. }]
  258. },
  259. options: {
  260. title: {
  261. display: true,
  262. fontSize: 12,
  263. text: 'All reviews of this month'
  264. }
  265. }
  266. });
  267. },
  268. error: function(error_data) {
  269. console.log(error_data);
  270. }
  271. });
  272. </script>
  273. {% endblock content %}