chart-equipmentDistribution.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <!-- **************************************NO.16 摄像头*************************************** -->
  2. <template>
  3. <div class="chart-container">
  4. <!-- <div id="camera1" style="width: 100%; height:25vh; ">
  5. </div> -->
  6. <div id="camera2" style="width: 100%; height:85vh; ">
  7. </div>
  8. <!-- <div id="camera3" style="width: 100%; height:30vh; ">
  9. </div> -->
  10. </div>
  11. </template>
  12. <script>
  13. import * as echarts from 'echarts';
  14. import {selectDeviceType} from '@/api/bigdata'
  15. export default {
  16. name: 'camera',
  17. data() {
  18. return {
  19. count: 0,
  20. data_sbfb:[]
  21. }
  22. },
  23. mounted() {
  24. this.selectDeviceType1()
  25. // this.myEcharts1();
  26. //this.myEcharts2();
  27. // this.myEcharts3();
  28. },
  29. methods: {
  30. selectDeviceType1() {
  31. let that = this
  32. selectDeviceType().then(res => {
  33. res.data.forEach(item => {
  34. const param = Object.assign({})
  35. param.name = item.deviceName
  36. param.数量 = item.deviceCount
  37. that.data_sbfb.push(param)
  38. })
  39. that.myEcharts2()
  40. })
  41. },
  42. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=TMyJh73uiXkeu3_v
  43. myEcharts1() {
  44. var chartDom = document.getElementById('camera1');
  45. var myChart = echarts.init(chartDom);
  46. var option;
  47. const dfColor = ['#92E1FF', '#0097FB', '#30ECA6', '#FFC227', '#FF4848'];
  48. option = {
  49. dataset: {
  50. dimensions: ['name', '摄像头'],
  51. source: [{
  52. name: '双辽市',
  53. '摄像头': 50
  54. },
  55. {
  56. name: '梨树县',
  57. '摄像头': 40
  58. },
  59. {
  60. name: '伊通县',
  61. '摄像头': 30
  62. },
  63. {
  64. name: '铁东区',
  65. '摄像头': 20
  66. },
  67. {
  68. name: '铁西区',
  69. '摄像头': 30
  70. }
  71. ]
  72. },
  73. tooltip: {
  74. trigger: 'item',
  75. position: function(point, params, dom, rect, size) {
  76. const x = point[0];
  77. const y = point[1];
  78. const viewWidth = size.viewSize[0];
  79. const viewHeight = size.viewSize[1];
  80. const boxWidth = size.contentSize[0];
  81. const boxHeight = size.contentSize[1];
  82. let posX = 0;
  83. let posY = 0;
  84. if (x < boxWidth) {
  85. // 左边放不开
  86. posX = 5;
  87. } else {
  88. // 左边放的下
  89. posX = x - boxWidth;
  90. }
  91. if (y < boxHeight) {
  92. // 上边放不开
  93. posY = 5;
  94. } else {
  95. // 上边放得下
  96. posY = y - boxHeight;
  97. }
  98. return [posX, posY];
  99. },
  100. },
  101. angleAxis: {
  102. max(value) {
  103. return value.max * 1.1;
  104. },
  105. axisLabel: {
  106. show: false
  107. },
  108. axisTick: {
  109. show: false
  110. },
  111. axisLine: {
  112. show: false
  113. },
  114. splitLine: {
  115. show: false
  116. },
  117. startAngle: 270
  118. },
  119. radiusAxis: {
  120. type: 'category',
  121. minorTick: {
  122. show: false
  123. },
  124. axisLine: {
  125. show: false
  126. },
  127. axisTick: {
  128. show: false
  129. },
  130. axisLabel: {
  131. show: false
  132. },
  133. },
  134. polar: {
  135. radius: ['40%', '90%'],
  136. },
  137. // angleAxis:{
  138. // clockwise:false
  139. // },
  140. series: [{
  141. type: 'bar',
  142. coordinateSystem: 'polar',
  143. itemStyle: {
  144. color(params) {
  145. const idx = params.dataIndex;
  146. return dfColor[idx];
  147. },
  148. },
  149. barWidth: 5,
  150. roundCap: true,
  151. showBackground: true,
  152. backgroundStyle: {
  153. color: 'RGBA(0, 69, 117, 0.5)',
  154. },
  155. }],
  156. };
  157. option && myChart.setOption(option);
  158. },
  159. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=pAD_0lcRq_zOGf_k
  160. myEcharts2() {
  161. let that = this
  162. var chartDom = document.getElementById('camera2');
  163. var myChart = echarts.init(chartDom);
  164. var option;
  165. const dfColor = ['#92E1FF', '#0097FB', '#30ECA6', '#FFC227', '#FF4848'];
  166. option = {
  167. dataset: {
  168. source: that.data_sbfb,
  169. },
  170. tooltip: {
  171. trigger: 'item',
  172. },
  173. grid: {
  174. top: "0%",
  175. left: "6%",
  176. // right: "4%",
  177. bottom: "5%",
  178. width: '75%',
  179. containLabel: true,
  180. },
  181. xAxis: {
  182. show: false,
  183. type: "value",
  184. },
  185. yAxis: {
  186. type: "category", // 不设置类目轴,抽离的dataset数据展示不出来
  187. inverse: true,
  188. axisLabel: {
  189. show: true,
  190. textStyle: {
  191. color: '#5deaff',
  192. fontSize: '12'
  193. }
  194. },
  195. splitLine: {
  196. show: false
  197. },
  198. axisTick: {
  199. show: false
  200. },
  201. axisLine: {
  202. show: false
  203. },
  204. },
  205. series: [{
  206. type: "bar",
  207. animationCurve: "easeOutBack",
  208. barWidth: 8,
  209. label: {
  210. show: true,
  211. position: "right",
  212. offset: [0, 0],
  213. color: "#88dfd5",
  214. // fontSize: "12",
  215. style: {
  216. fill: "#fff"
  217. },
  218. },
  219. backgroundBar: {
  220. show: true,
  221. style: {
  222. fill: "rgba(97,152,255,0.30)",
  223. },
  224. },
  225. barStyle: {
  226. stroke: "rgba(41,244,236,1)",
  227. },
  228. gradient: {
  229. color: ["rgba(41,244,236,1)", "rgba(41,244,236,0)"],
  230. },
  231. itemStyle: {
  232. label: {
  233. show: true
  234. },
  235. labelLine: {
  236. show: false,
  237. },
  238. color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
  239. offset: 0,
  240. color: "rgba(41,244,236,0)"
  241. },
  242. {
  243. offset: 1,
  244. color: "rgba(41,244,236,1)"
  245. },
  246. ]),
  247. borderColor: "#a2f9f7",
  248. shadowBlur: 16,
  249. shadowColor: "#a2f9f7",
  250. },
  251. },],
  252. };
  253. option && myChart.setOption(option);
  254. },
  255. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=ELjN7o3m72tLtmbv
  256. myEcharts3() {
  257. var chartDom = document.getElementById('camera3');
  258. var myChart = echarts.init(chartDom);
  259. var option;
  260. option = {
  261. color: ['#3D91F7', '#61BE67'],
  262. tooltip: {},
  263. legend: {
  264. show: true,
  265. icon: "circle",
  266. bottom: 30,
  267. center: 0,
  268. itemWidth: 14,
  269. itemHeight: 14,
  270. itemGap: 21,
  271. orient: "horizontal",
  272. data: ['a', 'b'],
  273. textStyle: {
  274. color: '#8C8C8C'
  275. },
  276. },
  277. radar: {
  278. // shape: 'circle',
  279. radius: '80%',
  280. triggerEvent: true,
  281. name: {
  282. textStyle: {
  283. color: '#fff',
  284. fontSize: '10',
  285. borderRadius: 3,
  286. padding: [3, 5]
  287. }
  288. },
  289. nameGap: '2',
  290. indicator: [{ //[4300, 10000, 28000, 35000, 50000, 19000, 21000]
  291. name: '型号1',
  292. max: 6500
  293. },
  294. {
  295. name: '型号2',
  296. max: 16000
  297. },
  298. {
  299. name: '型号3',
  300. max: 30000
  301. },
  302. {
  303. name: '型号4',
  304. max: 38000
  305. },
  306. {
  307. name: '型号5',
  308. max: 52000
  309. },
  310. {
  311. name: '型号6',
  312. max: 25000
  313. },
  314. {
  315. name: '型号7',
  316. max: 25000
  317. }
  318. ],
  319. splitArea: {
  320. areaStyle: {
  321. color: [
  322. 'rgba(222,134,85, 0.1)', 'rgba(222,134,85, 0.2)',
  323. 'rgba(222,134,85, 0.4)', 'rgba(222,134,85, 0.6)',
  324. 'rgba(222,134,85, 0.8)', 'rgba(222,134,85, 1)'
  325. ].reverse()
  326. }
  327. },
  328. // axisLabel:{//展示刻度
  329. // show: true
  330. // },
  331. axisLine: { //指向外圈文本的分隔线样式
  332. lineStyle: {
  333. color: 'rgba(0,0,0,0)'
  334. }
  335. },
  336. splitLine: {
  337. lineStyle: {
  338. width: 2,
  339. color: [
  340. 'rgba(224,134,82, 0.1)', 'rgba(224,134,82, 0.2)',
  341. 'rgba(224,134,82, 0.4)', 'rgba(224,134,82, 0.6)',
  342. 'rgba(224,134,82, 0.8)', 'rgba(224,134,82, 1)'
  343. ].reverse()
  344. }
  345. },
  346. },
  347. series: [{
  348. name: '型号统计',
  349. type: 'radar',
  350. //areaStyle: {normal: {}},
  351. areaStyle: {
  352. normal: {
  353. color: 'rgba(252,211,3, 0.3)'
  354. }
  355. },
  356. symbolSize: 0,
  357. lineStyle: {
  358. normal: {
  359. color: 'rgba(252,211,3, 1)',
  360. width: 1
  361. }
  362. },
  363. data: [{
  364. value: [4300, 10000, 28000, 35000, 50000, 19000, 21000],
  365. name: '型号统计',
  366. }]
  367. }]
  368. };
  369. option && myChart.setOption(option);
  370. },
  371. }
  372. }
  373. </script>
  374. <style rel="stylesheet/scss" lang="scss" scoped>
  375. .chart-container {
  376. width: 100%;
  377. height: auto;
  378. position: relative;
  379. padding-bottom: 10px;
  380. display: flex;
  381. flex-direction: column;
  382. }
  383. </style>