chart-equipmentDistribution.vue 8.0 KB

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