item.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title></title>
  7. <link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css" />
  8. <link rel="stylesheet" href="./bootstrap/css/bootstrap-theme.min.css" />
  9. <link rel="stylesheet" href="./css/index.css" />
  10. <script src="./js/jquery.js"></script>
  11. <script src="./js/f2.min.js"></script>
  12. <script src="./bootstrap/js/bootstrap.min.js"></script>
  13. <style>
  14. .pageAccess .row {
  15. padding-left: 15px;
  16. }
  17. .pageAccess .col-md-6 {
  18. padding-left: 0;
  19. }
  20. .totalNum {
  21. font-size: 14px;
  22. text-align: center;
  23. }
  24. .totalNum .head {
  25. font-size: 42px;
  26. color: #91afc8;
  27. }
  28. </style>
  29. </head>
  30. <body class="pageAccess">
  31. <table class="table table-striped">
  32. <thead>
  33. <tr>
  34. <td>话题</td>
  35. <td>传播量</td>
  36. <td>话题</td>
  37. <td>传播量</td>
  38. </tr>
  39. </thead>
  40. <tbody class="summary">
  41. </tbody>
  42. </table>
  43. <div class="row">
  44. <div class="col-md-6">
  45. <div class="panel panel-default">
  46. <div class="panel-heading">传播量趋势</div>
  47. <canvas id="container" style="width: 100%;height: 100%;" class=""></canvas>
  48. </div>
  49. </div>
  50. <div class="col-md-6">
  51. <div class="panel panel-default">
  52. <div class="panel-heading">部门传播量</div>
  53. <canvas id="barChart" style="width: 100%;height: 100%;" class=""></canvas>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="row">
  58. <div class="col-md-6">
  59. <div class="panel panel-default">
  60. <div class="panel-heading">任务统计</div>
  61. <div class="panel-body">
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </body>
  67. <script src="./js/base.js"></script>
  68. <script>
  69. let searchObj = getsearch();
  70. function line1(li) {
  71. // 传播量趋势
  72. const chart = new F2.Chart({
  73. id: 'container',
  74. pixelRatio: window.devicePixelRatio
  75. });
  76. chart.source(li, {
  77. time: {
  78. type: 'timeCat',
  79. tickCount: 3,
  80. range: [0, 1]
  81. },
  82. tem: {
  83. tickCount: 5,
  84. min: 0
  85. }
  86. });
  87. chart.axis('playCount', {
  88. label: function label(text, index, total) {
  89. const textCfg = {};
  90. textCfg.text = formatnum(text);
  91. return textCfg;
  92. },
  93. grid: null
  94. });
  95. chart.axis('dt', {
  96. label: function label(text, index, total) {
  97. const textCfg = {};
  98. if (index === 0) {
  99. textCfg.textAlign = 'left';
  100. } else if (index === total - 1) {
  101. textCfg.textAlign = 'right';
  102. }
  103. return textCfg;
  104. }
  105. });
  106. chart.tooltip({
  107. onShow: function onShow(ev) {
  108. const items = ev.items;
  109. items[0].name = items[0].title;
  110. items[0].value = formatnum(text);
  111. items[1].name = null;
  112. items[1].value = 0;
  113. }
  114. });
  115. chart.area()
  116. .position('dt*playCount')
  117. .color('l(90) 0:#1890FF 1:#f7f7f7')
  118. .shape('smooth');
  119. chart.line()
  120. .position('dt*playCount')
  121. .color('l(90) 0:#1890FF 1:#f7f7f7')
  122. .shape('smooth');
  123. chart.render();
  124. }
  125. function bar1(li){
  126. const chart = new F2.Chart({
  127. id: 'barChart',
  128. pixelRatio: window.devicePixelRatio
  129. });
  130. chart.source(li, {
  131. sales: {
  132. tickCount: 5
  133. }
  134. });
  135. chart.tooltip({
  136. showItemMarker: false,
  137. onShow: function onShow(ev) {
  138. const items = ev.items;
  139. items[0].name = null;
  140. items[0].name = items[0].title;
  141. items[0].value = '¥ ' + items[0].value;
  142. }
  143. });
  144. chart.interval()
  145. .position('year*sales')
  146. .color('l(90) 0:#1890ff 1:#70cdd0'); // 定义柱状图渐变色
  147. chart.render();
  148. }
  149. function getAllData() {
  150. require('GET', {
  151. url: "/topic/overview",
  152. data: {
  153. topic: searchObj.topic
  154. }
  155. }).then(data => {
  156. const li = data || [];
  157. for (let i = 0; i < li.length; i += 2) {
  158. const v = li[i], vnext = li[i+1];
  159. let tr = $("<tr></tr>");
  160. tr.append($(`<td>${v.subTopic}</td><td>${formatnum(v.playCount)}</td>`));
  161. if (vnext) tr.append($(`<td>${vnext.subTopic}</td><td>${formatnum(vnext.playCount)}</td>`));
  162. else tr.append($(`<td></td><td></td>`));
  163. $(".summary").append(tr)
  164. }
  165. })
  166. }
  167. function gethistory() {
  168. require('GET', {
  169. url: "/topic/history",
  170. data: {
  171. topic: searchObj.topic
  172. }
  173. }).then(li => {
  174. line1(li);
  175. })
  176. }
  177. function getread(){
  178. require('POST', {
  179. url: "/topic/read",
  180. data: {
  181. depRange: "ALL",
  182. title: searchObj.topic
  183. }
  184. }).then(li => {
  185. console.log('--', li);
  186. })
  187. }
  188. function init() {
  189. let h = $('.panel-body').width() * 9 / 16;
  190. $('.panel-body').height(h);
  191. getAllData();
  192. gethistory();
  193. getread();
  194. }
  195. init();
  196. </script>
  197. </html>