location-wise-reviews-man.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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 yelp_line_ctx = document.getElementById("yelpLineChart");
  42. var yelp_pie_ctx = document.getElementById("yelpPieChart");
  43. var location_id = document.getElementById("location_id").value;
  44. console.log(location_id)
  45. var endpoint = '/user/api/analytics/all-platform';
  46. params = {
  47. "location_id": location_id.trim()
  48. }
  49. console.log(params)
  50. $.ajax({
  51. type: "get",
  52. url: endpoint,
  53. data: params,
  54. dataType: 'json',
  55. success: function(data) {
  56. console.log(data)
  57. // All data together in a bar chart..
  58. var myBarChart = new Chart(ctx, {
  59. type: 'bar',
  60. data: {
  61. labels: data.google.labels,
  62. datasets: [
  63. {
  64. label: 'Google',
  65. data: data.google.total_review,
  66. borderColor: 'rgb(255, 204, 0)',
  67. backgroundColor: 'rgb(255, 204, 0)',
  68. borderWidth: 1,
  69. fill: false
  70. },
  71. {
  72. label: 'Facebook',
  73. data: data.facebook.total_review,
  74. borderColor: 'rgb(0, 51, 204)',
  75. backgroundColor: 'rgb(0, 51, 204)',
  76. borderWidth: 1,
  77. fill: false
  78. },
  79. {
  80. label: 'Yelp',
  81. data: data.yelp.total_review,
  82. borderColor: 'rgb(255, 51, 51)',
  83. backgroundColor: 'rgb(204, 0, 0)',
  84. borderWidth: 1,
  85. fill: false
  86. }]
  87. },
  88. options: {
  89. scales: {
  90. yAxes: [{
  91. ticks: {
  92. beginAtZero: true
  93. }
  94. }],
  95. xAxes: [{
  96. gridLines: {
  97. drawOnChartArea:false
  98. }
  99. }]
  100. },
  101. title: {
  102. display: true,
  103. fontSize: 16,
  104. text: "Review of this month in all platforms."
  105. }
  106. }
  107. });
  108. // Google review charts
  109. // Google line chart
  110. var myGoogleLineChart = new Chart(google_line_ctx, {
  111. type: 'line',
  112. data: {
  113. labels: data.google.labels,
  114. datasets: [
  115. {
  116. label: '1*',
  117. data: data.google.star_rating[0],
  118. borderColor: 'rgb(204, 0, 17)',
  119. backgroundColor: 'rgb(204, 0, 17)',
  120. borderWidth: 1,
  121. lineTension: 0,
  122. fill: false
  123. },
  124. {
  125. label: '2*',
  126. data: data.google.star_rating[1],
  127. borderColor: 'rgb(255, 119, 0)',
  128. backgroundColor: 'rgb(255, 119, 0)',
  129. borderWidth: 1,
  130. lineTension: 0,
  131. fill: false
  132. },
  133. {
  134. label: '3*',
  135. data: data.google.star_rating[2],
  136. borderColor: 'rgb(219, 208, 0)',
  137. backgroundColor: 'rgb(219, 208, 0)',
  138. borderWidth: 1,
  139. lineTension: 0,
  140. fill: false
  141. },
  142. {
  143. label: '4*',
  144. data: data.google.star_rating[3],
  145. borderColor: 'rgb(0, 157, 166)',
  146. backgroundColor: 'rgb(0, 157, 166)',
  147. borderWidth: 1,
  148. lineTension: 0,
  149. fill: false
  150. },
  151. {
  152. label: '5*',
  153. data: data.google.star_rating[4],
  154. borderColor: 'rgb(0, 97, 0)',
  155. backgroundColor: 'rgb(0, 97, 0)',
  156. borderWidth: 1,
  157. lineTension: 0,
  158. fill: false,
  159. }]
  160. },
  161. options: {
  162. borderJoinStyle: "bevel",
  163. scales: {
  164. yAxes: [{
  165. ticks: {
  166. beginAtZero: true
  167. }
  168. }],
  169. xAxes: [{
  170. gridLines: {
  171. drawOnChartArea:false
  172. }
  173. }]
  174. },
  175. title: {
  176. display: true,
  177. fontSize: 16,
  178. text: "Monthly review in Google."
  179. }
  180. }
  181. });
  182. // Google pie chart
  183. var myGooglePieChart = new Chart(google_pie_ctx, {
  184. type: 'pie',
  185. data: {
  186. labels: data.google.curr_month.label,
  187. datasets: [
  188. {
  189. data: data.google.curr_month.total,
  190. backgroundColor: [
  191. 'rgb(0, 97, 0)',
  192. 'rgb(0, 157, 166)',
  193. 'rgb(219, 208, 0)',
  194. 'rgb(255, 119, 0)',
  195. 'rgb(204, 0, 17)'
  196. ]
  197. }]
  198. },
  199. options: {
  200. title: {
  201. display: true,
  202. fontSize: 12,
  203. // position: 'bottom',
  204. text: 'All reviews of this month'
  205. }
  206. }
  207. });
  208. // Yelp review charts
  209. // Yelp line chart
  210. var myYelpLineChart = new Chart(yelp_line_ctx, {
  211. type: 'line',
  212. data: {
  213. labels: data.yelp.labels,
  214. datasets: [
  215. {
  216. label: '1*',
  217. data: data.yelp.star_rating[0],
  218. borderColor: 'rgb(204, 0, 17)',
  219. backgroundColor: 'rgb(204, 0, 17)',
  220. borderWidth: 1,
  221. lineTension: 0,
  222. fill: false
  223. },
  224. {
  225. label: '2*',
  226. data: data.yelp.star_rating[1],
  227. borderColor: 'rgb(255, 119, 0)',
  228. backgroundColor: 'rgb(255, 119, 0)',
  229. borderWidth: 1,
  230. lineTension: 0,
  231. fill: false
  232. },
  233. {
  234. label: '3*',
  235. data: data.yelp.star_rating[2],
  236. borderColor: 'rgb(219, 208, 0)',
  237. backgroundColor: 'rgb(219, 208, 0)',
  238. borderWidth: 1,
  239. lineTension: 0,
  240. fill: false
  241. },
  242. {
  243. label: '4*',
  244. data: data.yelp.star_rating[3],
  245. borderColor: 'rgb(0, 157, 166)',
  246. backgroundColor: 'rgb(0, 157, 166)',
  247. borderWidth: 1,
  248. lineTension: 0,
  249. fill: false
  250. },
  251. {
  252. label: '5*',
  253. data: data.yelp.star_rating[4],
  254. borderColor: 'rgb(0, 97, 0)',
  255. backgroundColor: 'rgb(0, 97, 0)',
  256. borderWidth: 1,
  257. lineTension: 0,
  258. fill: false,
  259. }]
  260. },
  261. options: {
  262. borderJoinStyle: "bevel",
  263. scales: {
  264. yAxes: [{
  265. ticks: {
  266. beginAtZero: true
  267. }
  268. }],
  269. xAxes: [{
  270. gridLines: {
  271. drawOnChartArea:false
  272. }
  273. }]
  274. },
  275. title: {
  276. display: true,
  277. fontSize: 16,
  278. text: "Monthly review in Google."
  279. }
  280. }
  281. });
  282. // Yelp pie chart
  283. var myYelpPieChart = new Chart(yelp_pie_ctx, {
  284. type: 'pie',
  285. data: {
  286. labels: data.yelp.curr_month.label,
  287. datasets: [
  288. {
  289. data: data.yelp.curr_month.total,
  290. backgroundColor: [
  291. 'rgb(0, 97, 0)',
  292. 'rgb(0, 157, 166)',
  293. 'rgb(219, 208, 0)',
  294. 'rgb(255, 119, 0)',
  295. 'rgb(204, 0, 17)'
  296. ]
  297. }]
  298. },
  299. options: {
  300. title: {
  301. display: true,
  302. fontSize: 12,
  303. // position: 'bottom',
  304. text: 'All reviews of this month'
  305. }
  306. }
  307. });
  308. // Facebook review charts
  309. // Facebook line chart
  310. var myFacebookLineChart = new Chart(facebook_line_ctx, {
  311. type: 'line',
  312. data: {
  313. labels: data.facebook.labels,
  314. datasets: [
  315. {
  316. label: 'Not Recommended',
  317. data: data.facebook.star_rating[0],
  318. borderColor: 'rgb(204, 0, 17)',
  319. backgroundColor: 'rgb(204, 0, 17)',
  320. borderWidth: 1,
  321. lineTension: 0,
  322. fill: false
  323. },
  324. {
  325. label: 'Recommended',
  326. data: data.facebook.star_rating[1],
  327. borderColor: 'rgb(0, 51, 204)',
  328. backgroundColor: 'rgb(0, 51, 204)',
  329. borderWidth: 1,
  330. lineTension: 0,
  331. fill: false
  332. }]
  333. },
  334. options: {
  335. borderJoinStyle: "bevel",
  336. scales: {
  337. yAxes: [{
  338. ticks: {
  339. beginAtZero: true
  340. }
  341. }],
  342. xAxes: [{
  343. gridLines: {
  344. drawOnChartArea:false
  345. }
  346. }]
  347. },
  348. title: {
  349. display: true,
  350. fontSize: 16,
  351. text: "Monthly review in Facebook."
  352. }
  353. }
  354. });
  355. // Google pie chart
  356. var myFacebookPieChart = new Chart(facebook_pie_ctx, {
  357. type: 'pie',
  358. data: {
  359. labels: data.facebook.curr_month.label,
  360. datasets: [
  361. {
  362. data: data.facebook.curr_month.total,
  363. backgroundColor: [
  364. 'rgb(0, 51, 204)',
  365. 'rgb(204, 0, 17)'
  366. ]
  367. }]
  368. },
  369. options: {
  370. title: {
  371. display: true,
  372. fontSize: 12,
  373. text: 'All reviews of this month'
  374. }
  375. }
  376. });
  377. },
  378. error: function(error_data) {
  379. console.log(error_data);
  380. }
  381. });
  382. </script>
  383. {% endblock content %}