item.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. <div class="panel-body">
  48. <canvas id="container" style="width: 100%;height: 100%;" class=""></canvas>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="col-md-6">
  53. <div class="panel panel-default">
  54. <div class="panel-heading">Panel heading without title</div>
  55. <div class="panel-body">
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="row">
  61. <div class="col-md-6">
  62. <div class="panel panel-default">
  63. <div class="panel-heading">传播量趋势</div>
  64. <div class="panel-body">
  65. </div>
  66. </div>
  67. </div>
  68. <div class="col-md-6">
  69. <div class="panel panel-default">
  70. <div class="panel-heading">Panel heading without title</div>
  71. <div class="panel-body">
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </body>
  77. <script src="./js/base.js"></script>
  78. <script>
  79. let searchObj = getsearch();
  80. function line1(li) {
  81. // 传播量趋势
  82. const chart = new F2.Chart({
  83. id: 'container',
  84. pixelRatio: window.devicePixelRatio
  85. });
  86. chart.source(li, {
  87. time: {
  88. type: 'timeCat',
  89. tickCount: 3,
  90. range: [0, 1]
  91. },
  92. tem: {
  93. tickCount: 5,
  94. min: 0
  95. }
  96. });
  97. chart.axis('playCount', {
  98. label: function label(text, index, total) {
  99. const textCfg = {};
  100. textCfg.text = formatnum(text);
  101. return textCfg;
  102. },
  103. grid: null
  104. });
  105. chart.axis('dt', {
  106. label: function label(text, index, total) {
  107. const textCfg = {};
  108. if (index === 0) {
  109. textCfg.textAlign = 'left';
  110. } else if (index === total - 1) {
  111. textCfg.textAlign = 'right';
  112. }
  113. return textCfg;
  114. }
  115. });
  116. chart.tooltip({
  117. onShow: function onShow(ev) {
  118. const items = ev.items;
  119. items[0].name = items[0].title;
  120. items[0].value = formatnum(text);
  121. items[1].name = null;
  122. items[1].value = 0;
  123. }
  124. });
  125. chart.area()
  126. .position('dt*playCount')
  127. .color('l(90) 0:#1890FF 1:#f7f7f7')
  128. .shape('smooth');
  129. chart.line()
  130. .position('dt*playCount')
  131. .color('l(90) 0:#1890FF 1:#f7f7f7')
  132. .shape('smooth');
  133. chart.render();
  134. }
  135. function getAllData() {
  136. require('GET', {
  137. url: "/topic/overview",
  138. data: {
  139. topic: searchObj.topic
  140. }
  141. }).then(data => {
  142. const li = data || [];
  143. for (let i = 0; i < li.length; i += 2) {
  144. const v = li[i], vnext = li[i+1];
  145. let tr = $("<tr></tr>");
  146. tr.append($(`<td>${v.subTopic}</td><td>${formatnum(v.playCount)}</td>`));
  147. if (vnext) tr.append($(`<td>${vnext.subTopic}</td><td>${formatnum(vnext.playCount)}</td>`));
  148. else tr.append($(`<td></td><td></td>`));
  149. $(".summary").append(tr)
  150. }
  151. })
  152. }
  153. function gethistory() {
  154. require('GET', {
  155. url: "/topic/history",
  156. data: {
  157. topic: searchObj.topic
  158. }
  159. }).then(li => {
  160. line1(li);
  161. })
  162. }
  163. function getread(){
  164. require('GET', {
  165. url: "/topic/read",
  166. data: {
  167. topic: searchObj.topic,
  168. depRange: "MONTH"
  169. }
  170. }).then(li => {
  171. console.log('--', li);
  172. })
  173. }
  174. function init() {
  175. let h = $('.panel-body').width() * 9 / 16;
  176. $('.panel-body').height(h);
  177. getAllData();
  178. gethistory();
  179. getread();
  180. }
  181. init();
  182. </script>
  183. </html>