chart-equipmentDistribution.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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:55vh; ">
  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. source: []
  20. }
  21. },
  22. mounted() {
  23. // this.myEcharts1();
  24. // this.myEcharts2();
  25. // this.myEcharts3();
  26. this.getSbfb()
  27. },
  28. methods: {
  29. getSbfb() {
  30. let that = this
  31. selectDeviceType().then(res => {
  32. res.data.forEach(item=> {
  33. const param = Object.assign({})
  34. param.name = item.deviceName
  35. param.数量=item.deviceCount
  36. this.source.push(param)
  37. })
  38. console.log(this.source)
  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. var chartDom = document.getElementById('camera2');
  162. var myChart = echarts.init(chartDom);
  163. var option;
  164. const dfColor = ['#92E1FF', '#0097FB', '#30ECA6', '#FFC227', '#FF4848'];
  165. option = {
  166. dataset: {
  167. source: this.source,
  168. },
  169. tooltip: {
  170. trigger: 'item',
  171. },
  172. grid: {
  173. top: "0%",
  174. left: "6%",
  175. // right: "4%",
  176. bottom: "5%",
  177. width: '75%',
  178. containLabel: true,
  179. },
  180. xAxis: {
  181. show: false,
  182. type: "value",
  183. },
  184. yAxis: {
  185. type: "category", // 不设置类目轴,抽离的dataset数据展示不出来
  186. inverse: true,
  187. axisLabel: {
  188. show: true,
  189. textStyle: {
  190. color: '#5deaff',
  191. fontSize: '12'
  192. }
  193. },
  194. splitLine: {
  195. show: false
  196. },
  197. axisTick: {
  198. show: false
  199. },
  200. axisLine: {
  201. show: false
  202. },
  203. },
  204. series: [{
  205. type: "bar",
  206. animationCurve: "easeOutBack",
  207. barWidth: 8,
  208. label: {
  209. show: true,
  210. position: "right",
  211. offset: [0, 0],
  212. color: "#88dfd5",
  213. // fontSize: "12",
  214. style: {
  215. fill: "#fff"
  216. },
  217. },
  218. backgroundBar: {
  219. show: true,
  220. style: {
  221. fill: "rgba(97,152,255,0.30)",
  222. },
  223. },
  224. barStyle: {
  225. stroke: "rgba(41,244,236,1)",
  226. },
  227. gradient: {
  228. color: ["rgba(41,244,236,1)", "rgba(41,244,236,0)"],
  229. },
  230. itemStyle: {
  231. label: {
  232. show: true
  233. },
  234. labelLine: {
  235. show: false,
  236. },
  237. color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
  238. offset: 0,
  239. color: "rgba(41,244,236,0)"
  240. },
  241. {
  242. offset: 1,
  243. color: "rgba(41,244,236,1)"
  244. },
  245. ]),
  246. borderColor: "#a2f9f7",
  247. shadowBlur: 16,
  248. shadowColor: "#a2f9f7",
  249. },
  250. },],
  251. };
  252. option && myChart.setOption(option);
  253. },
  254. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=ELjN7o3m72tLtmbv
  255. myEcharts3() {
  256. var chartDom = document.getElementById('camera3');
  257. var myChart = echarts.init(chartDom);
  258. var option;
  259. option = {
  260. color: ['#3D91F7', '#61BE67'],
  261. tooltip: {},
  262. legend: {
  263. show: true,
  264. icon: "circle",
  265. bottom: 30,
  266. center: 0,
  267. itemWidth: 14,
  268. itemHeight: 14,
  269. itemGap: 21,
  270. orient: "horizontal",
  271. data: ['a', 'b'],
  272. textStyle: {
  273. color: '#8C8C8C'
  274. },
  275. },
  276. radar: {
  277. // shape: 'circle',
  278. radius: '80%',
  279. triggerEvent: true,
  280. name: {
  281. textStyle: {
  282. color: '#fff',
  283. fontSize: '10',
  284. borderRadius: 3,
  285. padding: [3, 5]
  286. }
  287. },
  288. nameGap: '2',
  289. indicator: [{ //[4300, 10000, 28000, 35000, 50000, 19000, 21000]
  290. name: '型号1',
  291. max: 6500
  292. },
  293. {
  294. name: '型号2',
  295. max: 16000
  296. },
  297. {
  298. name: '型号3',
  299. max: 30000
  300. },
  301. {
  302. name: '型号4',
  303. max: 38000
  304. },
  305. {
  306. name: '型号5',
  307. max: 52000
  308. },
  309. {
  310. name: '型号6',
  311. max: 25000
  312. },
  313. {
  314. name: '型号7',
  315. max: 25000
  316. }
  317. ],
  318. splitArea: {
  319. areaStyle: {
  320. color: [
  321. 'rgba(222,134,85, 0.1)', 'rgba(222,134,85, 0.2)',
  322. 'rgba(222,134,85, 0.4)', 'rgba(222,134,85, 0.6)',
  323. 'rgba(222,134,85, 0.8)', 'rgba(222,134,85, 1)'
  324. ].reverse()
  325. }
  326. },
  327. // axisLabel:{//展示刻度
  328. // show: true
  329. // },
  330. axisLine: { //指向外圈文本的分隔线样式
  331. lineStyle: {
  332. color: 'rgba(0,0,0,0)'
  333. }
  334. },
  335. splitLine: {
  336. lineStyle: {
  337. width: 2,
  338. color: [
  339. 'rgba(224,134,82, 0.1)', 'rgba(224,134,82, 0.2)',
  340. 'rgba(224,134,82, 0.4)', 'rgba(224,134,82, 0.6)',
  341. 'rgba(224,134,82, 0.8)', 'rgba(224,134,82, 1)'
  342. ].reverse()
  343. }
  344. },
  345. },
  346. series: [{
  347. name: '型号统计',
  348. type: 'radar',
  349. //areaStyle: {normal: {}},
  350. areaStyle: {
  351. normal: {
  352. color: 'rgba(252,211,3, 0.3)'
  353. }
  354. },
  355. symbolSize: 0,
  356. lineStyle: {
  357. normal: {
  358. color: 'rgba(252,211,3, 1)',
  359. width: 1
  360. }
  361. },
  362. data: [{
  363. value: [4300, 10000, 28000, 35000, 50000, 19000, 21000],
  364. name: '型号统计',
  365. }]
  366. }]
  367. };
  368. option && myChart.setOption(option);
  369. },
  370. },
  371. }
  372. </script>
  373. <style rel="stylesheet/scss" lang="scss" scoped>
  374. .chart-container {
  375. width: 100%;
  376. height: auto;
  377. position: relative;
  378. padding-bottom: 10px;
  379. display: flex;
  380. flex-direction: column;
  381. }
  382. </style>