item.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <html>
  2. <head>
  3. <title>Item Details</title>
  4. <link href="{{ url_for('static', path='/styles.css') }}" rel="stylesheet">
  5. <!-- Chart.js v2.4.0 -->
  6. <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
  7. </head>
  8. <body>
  9. <img src="{{ url_for('static', path='/fastapi.png') }}" alt="FastAPI">
  10. <h1>Item ID: {{ id }}</h1>
  11. <h1>Title: {{ titles }}</h1>
  12. <canvas id="bar-yt" width="400" height="200"></canvas>
  13. <canvas id="myChart-pie" width="400" height="200"></canvas>
  14. <canvas id="bar-yt1" width="400" height="200"></canvas>
  15. <p>
  16. 接著
  17. </p>
  18. <script>
  19. var ctx10 = document.getElementById('bar-yt');
  20. var myChart10 = new Chart(ctx10, {
  21. type: 'bar', //圖表類型
  22. data: {
  23. //標題
  24. labels: [ "那些足球教我的事", '那些足球教我的事'],
  25. datasets: [
  26. {
  27. label: '月搜量',
  28. data: [50, 11],
  29. borderColor: 'rgba(255, 206, 86, 1)',
  30. backgroundColor: 'rgba(255, 206, 86, 1)',
  31. },
  32. {
  33. label: '金額',
  34. data: [40.57, 91.72],
  35. borderColor: 'rgba(255, 99, 132, 1)',
  36. backgroundColor: 'rgba(255, 99, 132, 1)',
  37. },
  38. ],
  39. },
  40. options: {
  41. // indexAxis: 'y',
  42. plugins: {
  43. legend: {
  44. // display: false,
  45. labels: {
  46. padding: 5,
  47. font: {
  48. display: false,
  49. size: 16,
  50. },
  51. },
  52. },
  53. },
  54. scales: {
  55. x: {
  56. ticks: {
  57. font: {
  58. size: 16,
  59. }
  60. },
  61. title: {
  62. display: false,
  63. font: {
  64. family: 'Times',
  65. size: 48,
  66. },
  67. },
  68. },
  69. y: {
  70. title: {
  71. display: true,
  72. },
  73. ticks: {
  74. font: {
  75. size: 16,
  76. }
  77. },
  78. beginAtZero: true,
  79. }
  80. }
  81. }
  82. });
  83. </script>
  84. <h1>id: {{ id }}</h1>
  85. <script>
  86. var ctx10 = document.getElementById('bar-yt');
  87. var myChart10 = new Chart(ctx10, {
  88. type: 'bar', //圖表類型
  89. data: {
  90. //標題
  91. labels: [ "{{ keyword }}", '那些足球教我的事'],
  92. datasets: [
  93. {
  94. label: '月搜量',
  95. data: [50, 11],
  96. borderColor: 'rgba(255, 206, 86, 1)',
  97. backgroundColor: 'rgba(255, 206, 86, 1)',
  98. },
  99. {
  100. label: '金額',
  101. data: [40.57, 91.72],
  102. borderColor: 'rgba(255, 99, 132, 1)',
  103. backgroundColor: 'rgba(255, 99, 132, 1)',
  104. },
  105. ],
  106. },
  107. options: {
  108. // indexAxis: 'y',
  109. plugins: {
  110. legend: {
  111. // display: false,
  112. labels: {
  113. padding: 5,
  114. font: {
  115. display: false,
  116. size: 16,
  117. },
  118. },
  119. },
  120. },
  121. scales: {
  122. x: {
  123. ticks: {
  124. font: {
  125. size: 16,
  126. }
  127. },
  128. title: {
  129. display: false,
  130. font: {
  131. family: 'Times',
  132. size: 48,
  133. },
  134. },
  135. },
  136. y: {
  137. title: {
  138. display: true,
  139. },
  140. ticks: {
  141. font: {
  142. size: 16,
  143. }
  144. },
  145. beginAtZero: true,
  146. }
  147. }
  148. }
  149. });
  150. </script>
  151. {% block script %}{% endblock %}
  152. <script>
  153. var ctx10 = document.getElementById('bar-yt1');
  154. var myChart11 = new Chart(ctx10, {
  155. type: 'bar', //圖表類型
  156. data: {
  157. //標題
  158. labels: [ "{{ keyword }}", '那些足球教我的事'],
  159. datasets: [
  160. {
  161. label: '月搜量',
  162. data: [50, 11],
  163. borderColor: 'rgba(255, 206, 86, 1)',
  164. backgroundColor: 'rgba(255, 206, 86, 1)',
  165. },
  166. {
  167. label: '金額',
  168. data: [40.57, 91.72],
  169. borderColor: 'rgba(255, 99, 132, 1)',
  170. backgroundColor: 'rgba(255, 99, 132, 1)',
  171. },
  172. ],
  173. },
  174. options: {
  175. // indexAxis: 'y',
  176. plugins: {
  177. legend: {
  178. // display: false,
  179. labels: {
  180. padding: 5,
  181. font: {
  182. display: false,
  183. size: 16,
  184. },
  185. },
  186. },
  187. },
  188. scales: {
  189. x: {
  190. ticks: {
  191. font: {
  192. size: 16,
  193. }
  194. },
  195. title: {
  196. display: false,
  197. font: {
  198. family: 'Times',
  199. size: 48,
  200. },
  201. },
  202. },
  203. y: {
  204. title: {
  205. display: true,
  206. },
  207. ticks: {
  208. font: {
  209. size: 16,
  210. }
  211. },
  212. beginAtZero: true,
  213. }
  214. }
  215. }
  216. });
  217. </script>
  218. <!-- <script>
  219. var ctx = document.getElementById( "example" ),
  220. example = new Chart(ctx, {
  221. // 參數設定[註1]
  222. type: "bar", // 圖表類型
  223. data: {
  224. // 資料設定[註2]
  225. labels: [ "{{ id }}", "{{ id }}", "{{ id }}" ], // 標題
  226. datasets: [{
  227. // 資料參數設定[註3]
  228. label: "# of Votes", // 標籤
  229. data: [ {{ id }}, {{ num }}, {{ num }} ], // 資料
  230. backgroundColor: [ // 背景色
  231. "#FF0000",
  232. "#00FF00",
  233. "#0000FF",
  234. ],
  235. borderWidth: 1 // 外框寬度
  236. }]
  237. }
  238. });
  239. </script> -->
  240. </body>
  241. </html>