Fourth.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. import { onMount, createSignal } from "solid-js"
  2. import DataSet from '@antv/data-set';
  3. import { Chart } from '@antv/g2';
  4. import utils from "../utils/index"
  5. import ItemHead from "../components/itemHead";
  6. import Table from "../components/table";
  7. import Water from "../components/water";
  8. import "../assets/style/Fourth.css"
  9. let WordEle, WordCanvas;
  10. let lastTime = Date.now();
  11. window.animationID = -1;
  12. const [timeDate, setTimeDate] = createSignal(utils.getTime())
  13. const [itemHeight, setItemHeight] = createSignal(utils.getTime())
  14. function animation() {
  15. window.animationID = window.requestAnimFrame(() => {
  16. const nowTime = Date.now();
  17. window.cancelrequestAnimFrame(window.animationID);
  18. animation()
  19. if ((nowTime - lastTime) < 1000) return
  20. lastTime = nowTime;
  21. setTimeDate(utils.getTime())
  22. })
  23. }
  24. function ClassificationChart() {
  25. const data = [
  26. { item: '执法形象', a: 70, b: 30 },
  27. { item: '突发事件', a: 60, b: 70 },
  28. { item: '突发事故', a: 50, b: 60 },
  29. { item: '涉警、涉公务人员问题', a: 40, b: 50 },
  30. { item: '政府形象问题', a: 60, b: 70 },
  31. { item: '涉稳事件', a: 70, b: 50 },
  32. { item: '治安管理', a: 50, b: 40 },
  33. { item: '民生问题', a: 30, b: 40 },
  34. { item: '地区重点企业', a: 60, b: 40 },
  35. { item: '案件问题', a: 50, b: 60 },
  36. ];
  37. const { DataView } = DataSet;
  38. const dv = new DataView().source(data);
  39. dv.transform({
  40. type: 'fold',
  41. fields: ['a', 'b'], // 展开字段集
  42. key: 'user', // key字段
  43. value: 'score', // value字段
  44. renderer: 'svg'
  45. });
  46. const chart = new Chart({
  47. container: 'Classification',
  48. autoFit: true,
  49. padding: 20,
  50. height: WordEle.offsetHeight - 110,
  51. });
  52. chart.data(dv.rows);
  53. chart.scale('score', {
  54. min: 0,
  55. max: 80,
  56. });
  57. chart.coordinate('polar', {
  58. radius: 0.8,
  59. });
  60. chart.tooltip({
  61. shared: true,
  62. showCrosshairs: true,
  63. crosshairs: {
  64. line: {
  65. style: {
  66. lineDash: [4, 4],
  67. stroke: '#333'
  68. }
  69. }
  70. }
  71. });
  72. chart.axis('item', {
  73. line: null,
  74. tickLine: null,
  75. grid: {
  76. line: {
  77. style: {
  78. lineDash: null,
  79. },
  80. },
  81. },
  82. });
  83. chart.axis('score', {
  84. line: null,
  85. tickLine: null,
  86. grid: {
  87. line: {
  88. type: 'line',
  89. style: {
  90. lineDash: null,
  91. },
  92. },
  93. },
  94. });
  95. chart
  96. .line()
  97. .position('item*score')
  98. .color('user')
  99. .size(2);
  100. chart
  101. .point()
  102. .position('item*score')
  103. .color('user')
  104. .shape('circle')
  105. .size(4)
  106. .style({
  107. stroke: '#fff',
  108. lineWidth: 1,
  109. fillOpacity: 1,
  110. });
  111. chart
  112. .area()
  113. .position('item*score')
  114. .color('user');
  115. chart.render();
  116. }
  117. function TrendChart() {
  118. const data = [
  119. { year: '1991', value: 15468 },
  120. { year: '1992', value: 16100 },
  121. { year: '1993', value: 15900 },
  122. { year: '1994', value: 17409 },
  123. { year: '1995', value: 17000 },
  124. { year: '1996', value: 31056 },
  125. { year: '1997', value: 31982 },
  126. { year: '1998', value: 32040 },
  127. { year: '1999', value: 33233 },
  128. ];
  129. const chart = new Chart({
  130. container: 'Trend',
  131. autoFit: true,
  132. height: WordEle.offsetHeight - 110,
  133. renderer: 'svg',
  134. padding: [20, 20, 30, 50],
  135. });
  136. chart.data(data);
  137. chart.scale({
  138. value: {
  139. min: 10000,
  140. nice: true,
  141. },
  142. year: {
  143. range: [0, 1],
  144. },
  145. });
  146. chart.tooltip({
  147. showCrosshairs: true,
  148. shared: true,
  149. });
  150. chart.axis('value', {
  151. label: {
  152. formatter: (val) => {
  153. return (val / 1000).toFixed(1) + 'k';
  154. },
  155. },
  156. });
  157. chart.area().position('year*value').shape('smooth');
  158. chart.line().position('year*value').shape('smooth');
  159. chart.render();
  160. }
  161. function WordsChart() {
  162. WordCanvas.width = WordEle.offsetWidth
  163. WordCanvas.height = WordEle.offsetHeight - 110
  164. window.TagCanvas.Start("wordCloud", "tags", {
  165. textColour: "#3AEDE4",
  166. outlineColour: "rgba(0,0,0,0)",
  167. maxSpeed: 0.003,
  168. lock: "y",
  169. });
  170. window.TagCanvas.SetSpeed("wordCloud", [3, 3]);
  171. }
  172. function Fourth() {
  173. onMount(() => {
  174. ClassificationChart()
  175. TrendChart()
  176. WordsChart()
  177. animation()
  178. setItemHeight(WordEle.offsetHeight - 43)
  179. })
  180. const tHead = [{ text: '发布时间', type: 'Text' }, { text: '信息来源', type: 'Text' }, { text: '信息标题', type: 'Text', flex: 2 }];
  181. const tBody = [
  182. {
  183. color: "",
  184. col: [
  185. { text: '31分钟前', type: 'Text', color: "rgb(215 1 1 / 60%)", flex: 1 },
  186. { text: '懂车帝', type: 'Text', color: "rgb(215 1 1 / 60%)", flex: 1 },
  187. {
  188. flex: 2,
  189. text: '国足又输了 [流泪][流泪][流泪] 孔老二搬家 ……尽是书 说实话,怪不了这帮小子,他们尽力了,他们也就这能耐。 没有高考不行! 但是,高考为大众目标的教育,必然导致足球人口畸少而且素质极差。 此题',
  190. type: 'Scroll',
  191. color: "rgb(215 1 1 / 60%)"
  192. }
  193. ]
  194. }
  195. ]
  196. return (
  197. <div class="page">
  198. <div class="row FourthLayout height50">
  199. <div class="col4" style={{"padding":"0 .5em"}}>
  200. <div class="timeSub">
  201. 预警运行时间:
  202. <div class="numberFonts">
  203. <span>{timeDate().year[2]}</span>
  204. <span>{timeDate().year[3]}</span>
  205. <span>{timeDate().month[0]}</span>
  206. <span>{timeDate().month[1]}</span>
  207. <span>{timeDate().day[0]}</span>
  208. <span>{timeDate().day[1]}</span>
  209. </div>
  210. <div class="numberFonts">
  211. <span>{timeDate().hour[0]}</span>
  212. <span>{timeDate().hour[1]}</span>
  213. <span>{timeDate().min[0]}</span>
  214. <span>{timeDate().min[1]}</span>
  215. <span>{timeDate().sec[0]}</span>
  216. <span>{timeDate().sec[1]}</span>
  217. </div>
  218. </div>
  219. <div class="dataTotal" style={'height: ' + itemHeight() + 'px'}>
  220. <img style={{"float":"right"}} src="/src/assets/img/border_right.png" height="100%" />
  221. <div class="error">
  222. <div>
  223. <img src="/src/assets/img/all_error.png" style={{"width":"7em"}} />
  224. <div>全部预警</div>
  225. </div>
  226. <div>
  227. <img src="/src/assets/img/public_error.png" style={{"width":"7em"}} />
  228. <div>公共预警</div>
  229. </div>
  230. </div>
  231. <img src="/src/assets/img/link.gif" style={{"float":"right","width":"35%","height":"80%","margin-top":"2em"}} />
  232. <div class="data" style={{"width":"calc(75% - 1.68rem)","height":"100%"}}>
  233. <div class="allData">
  234. <div>监测信息总量</div>
  235. <img src="/src/assets/img/arrow_right.png" class="arrow" />
  236. <p>445349</p>
  237. </div>
  238. <div class="filterData">
  239. <div>排除信息量</div>
  240. <img src="/src/assets/img/arrow_right.png" class="arrow" />
  241. <p>444393</p>
  242. </div>
  243. <div class="proData">
  244. <div>排除信息占比</div>
  245. <img src="/src/assets/img/arrow_right.png" class="arrow arrow_left" />
  246. <p>99.79%</p>
  247. </div>
  248. <div style={{"height":"180px"}}>
  249. <div class="img">
  250. <img src="/src/assets/img/w1.png" style={{"top":"16px"}} alt="" />
  251. <img src="/src/assets/img/w2.png" style={{"top":"106px"}} alt="" />
  252. </div>
  253. </div>
  254. <Water percentage={0.21} text="舆情预警" />
  255. </div>
  256. </div>
  257. </div>
  258. <div class="col3">
  259. <ItemHead title="预警信息" subtitle="Warning Information" />
  260. <Table head={tHead} body={tBody} />
  261. </div>
  262. </div>
  263. <div class="row FourthLayout height50">
  264. <div class="col1">
  265. <ItemHead title="预警分类" subtitle="Warning Classification" />
  266. <div class="chart3" id="Classification"></div>
  267. </div>
  268. <div class="col1">
  269. <ItemHead title="预警趋势" subtitle="Warning Trend" />
  270. <div class="chart3" id="Trend"></div>
  271. </div>
  272. <div class="col1" ref={WordEle}>
  273. <ItemHead title="高频热词" subtitle="High-frequency words" />
  274. <div class="chart3 heightWord">
  275. <canvas id="wordCloud" ref={WordCanvas}></canvas>
  276. <div id="tags" class="tags" style={{"display":"none"}}>
  277. <ul>
  278. <li>
  279. <a href="http://www.google.com" target="_blank">Google</a>
  280. </li>
  281. <li><a href="/fish">Fish</a></li>
  282. <li><a href="/chips">Chips</a></li>
  283. <li><a href="/salt">Salt</a></li>
  284. <li><a href="/vinegar">Vinegar</a></li>
  285. <li>
  286. <a href="http://www.google.com" target="_blank">Google</a>
  287. </li>
  288. <li><a href="/fish">Fish</a></li>
  289. <li><a href="/chips">Chips</a></li>
  290. <li><a href="/salt">Salt</a></li>
  291. <li><a href="/vinegar">Vinegar</a></li>
  292. <li>
  293. <a href="http://www.google.com" target="_blank">Google</a>
  294. </li>
  295. <li><a href="/fish">Fish</a></li>
  296. <li><a href="/chips">Chips</a></li>
  297. <li><a href="/salt">Salt</a></li>
  298. <li><a href="/vinegar">Vinegar</a></li>
  299. <li>
  300. <a href="http://www.google.com" target="_blank">Google</a>
  301. </li>
  302. <li><a href="/fish">Fish</a></li>
  303. <li><a href="/chips">Chips</a></li>
  304. <li><a href="/salt">Salt</a></li>
  305. <li><a href="/vinegar">Vinegar</a></li>
  306. <li>
  307. <a href="http://www.google.com" target="_blank">Google</a>
  308. </li>
  309. <li><a href="/fish">Fish</a></li>
  310. <li><a href="/chips">Chips</a></li>
  311. <li><a href="/salt">Salt</a></li>
  312. <li><a href="/vinegar">Vinegar</a></li>
  313. </ul>
  314. </div>
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. );
  320. }
  321. export default Fourth;