location-wise-reviews.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. {% extends 'user-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.value)
  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(204, 51, 0)',
  83. backgroundColor: 'rgb(204, 51, 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: 16,
  203. text: 'This is google reviews'
  204. }
  205. }
  206. });
  207. // Facebook review charts
  208. // Facebook line chart
  209. var myFacebookLineChart = new Chart(facebook_line_ctx, {
  210. type: 'line',
  211. data: {
  212. labels: data.facebook.labels,
  213. datasets: [
  214. {
  215. label: 'Not Recommended',
  216. data: data.facebook.star_rating[0],
  217. borderColor: 'rgb(204, 0, 17)',
  218. backgroundColor: 'rgb(204, 0, 17)',
  219. borderWidth: 1,
  220. lineTension: 0,
  221. fill: false
  222. },
  223. {
  224. label: 'Recommended',
  225. data: data.facebook.star_rating[1],
  226. borderColor: 'rgb(0, 51, 204)',
  227. backgroundColor: 'rgb(0, 51, 204)',
  228. borderWidth: 1,
  229. lineTension: 0,
  230. fill: false
  231. }]
  232. },
  233. options: {
  234. borderJoinStyle: "bevel",
  235. scales: {
  236. yAxes: [{
  237. ticks: {
  238. beginAtZero: true
  239. }
  240. }],
  241. xAxes: [{
  242. gridLines: {
  243. drawOnChartArea:false
  244. }
  245. }]
  246. },
  247. title: {
  248. display: true,
  249. fontSize: 16,
  250. text: "Monthly review in Facebook."
  251. }
  252. }
  253. });
  254. // Google pie chart
  255. var myFacebookPieChart = new Chart(facebook_pie_ctx, {
  256. type: 'pie',
  257. data: {
  258. labels: data.facebook.curr_month.label,
  259. datasets: [
  260. {
  261. data: data.facebook.curr_month.total,
  262. backgroundColor: [
  263. 'rgb(0, 51, 204)',
  264. 'rgb(204, 0, 17)'
  265. ]
  266. }]
  267. },
  268. options: {
  269. title: {
  270. display: true,
  271. fontSize: 16,
  272. text: 'This is google reviews'
  273. }
  274. }
  275. });
  276. // Yelp review charts
  277. // Yelp line chart
  278. var myYelpLineChart = new Chart(yelp_line_ctx, {
  279. type: 'line',
  280. data: {
  281. labels: data.yelp.labels,
  282. datasets: [
  283. {
  284. label: '1*',
  285. data: data.yelp.star_rating[0],
  286. borderColor: 'rgb(204, 0, 17)',
  287. backgroundColor: 'rgb(204, 0, 17)',
  288. borderWidth: 1,
  289. lineTension: 0,
  290. fill: false
  291. },
  292. {
  293. label: '2*',
  294. data: data.yelp.star_rating[1],
  295. borderColor: 'rgb(255, 119, 0)',
  296. backgroundColor: 'rgb(255, 119, 0)',
  297. borderWidth: 1,
  298. lineTension: 0,
  299. fill: false
  300. },
  301. {
  302. label: '3*',
  303. data: data.yelp.star_rating[2],
  304. borderColor: 'rgb(219, 208, 0)',
  305. backgroundColor: 'rgb(219, 208, 0)',
  306. borderWidth: 1,
  307. lineTension: 0,
  308. fill: false
  309. },
  310. {
  311. label: '4*',
  312. data: data.yelp.star_rating[3],
  313. borderColor: 'rgb(0, 157, 166)',
  314. backgroundColor: 'rgb(0, 157, 166)',
  315. borderWidth: 1,
  316. lineTension: 0,
  317. fill: false
  318. },
  319. {
  320. label: '5*',
  321. data: data.yelp.star_rating[4],
  322. borderColor: 'rgb(0, 97, 0)',
  323. backgroundColor: 'rgb(0, 97, 0)',
  324. borderWidth: 1,
  325. lineTension: 0,
  326. fill: false,
  327. }]
  328. },
  329. options: {
  330. borderJoinStyle: "bevel",
  331. scales: {
  332. yAxes: [{
  333. ticks: {
  334. beginAtZero: true
  335. }
  336. }],
  337. xAxes: [{
  338. gridLines: {
  339. drawOnChartArea:false
  340. }
  341. }]
  342. },
  343. title: {
  344. display: true,
  345. fontSize: 16,
  346. text: "Monthly review in Yelp."
  347. }
  348. }
  349. });
  350. // Yelp pie chart
  351. var myGooglePieChart = new Chart(yelp_pie_ctx, {
  352. type: 'pie',
  353. data: {
  354. labels: data.yelp.curr_month.label,
  355. datasets: [
  356. {
  357. data: data.yelp.curr_month.total,
  358. backgroundColor: [
  359. 'rgb(0, 97, 0)',
  360. 'rgb(0, 157, 166)',
  361. 'rgb(219, 208, 0)',
  362. 'rgb(255, 119, 0)',
  363. 'rgb(204, 0, 17)'
  364. ]
  365. }]
  366. },
  367. options: {
  368. title: {
  369. display: true,
  370. fontSize: 16,
  371. text: 'This is yelp reviews'
  372. }
  373. }
  374. });
  375. },
  376. error: function(error_data) {
  377. console.log(error_data);
  378. }
  379. });
  380. </script>
  381. {% endblock content %}