8b9488599f4e402785f3b62750949de0047287cd.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <!-- -->
  2. <template>
  3. <div>
  4. <div style="width:100%;" :style="{'height': colHeight - 40 + 'px'}" ref="normal_bar_chart"></div>
  5. </div>
  6. </template>
  7. <script>
  8. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  9. //例如:import 《组件名称》 from '《组件路径》';
  10. import echarts from 'echarts'
  11. export default {
  12. //import引入的组件需要注入到对象中才能使用
  13. props:['barData_zy','pieData_zy'],
  14. components: {},
  15. data() {
  16. //这里存放数据
  17. return {
  18. colHeight:window.innerHeight - 300,
  19. };
  20. },
  21. //监听属性 类似于data概念
  22. computed: {},
  23. //监控data中的数据变化
  24. watch: {
  25. // barData_zy(){
  26. // this.init_Serious_BarLineChart();
  27. // }
  28. },
  29. //方法集合
  30. methods: {
  31. init_Serious_BarLineChart:function(){
  32. var _self = this;
  33. var scale = 1;
  34. let chart = echarts.init(this.$refs['normal_bar_chart']);
  35. var rich = {
  36. yellow: {
  37. color: "#ffc72b",
  38. fontSize: 30 * scale,
  39. padding: [5, 4],
  40. align: 'center'
  41. },
  42. black: {
  43. // color: "#3a3a3a",
  44. fontSize: 30 * scale,
  45. padding: [5, 4],
  46. align: 'center'
  47. },
  48. blackSmall: {
  49. // color: "#3a3a3a",
  50. fontSize: 16 * scale,
  51. padding: [5, 4],
  52. align: 'center'
  53. },
  54. total: {
  55. // color: "#ffc72b",
  56. fontSize: 40 * scale,
  57. align: 'center'
  58. },
  59. white: {
  60. // color: "#fff",
  61. align: 'center',
  62. fontSize: 14 * scale,
  63. padding: [21, 0]
  64. },
  65. blue: {
  66. color: '#49dff0',
  67. fontSize: 16 * scale,
  68. align: 'center'
  69. },
  70. hr: {
  71. borderColor: '#3a3a3a',
  72. width: '100%',
  73. borderWidth: 1,
  74. height: 0,
  75. }
  76. }
  77. let option = {
  78. title: {
  79. text: _self.barData_zy.count + '个问题分布情况',
  80. textStyle: {
  81. align: 'center',
  82. // color: '#fff',
  83. fontSize: 20,
  84. },
  85. top: '3%',
  86. left: '5%',
  87. },
  88. // backgroundColor: '#0f375f',
  89. grid: {
  90. top: "15%",
  91. bottom: "5%",
  92. left: "2%",
  93. right: "30%",
  94. containLabel: true
  95. },
  96. tooltip: {
  97. trigger: "axis",
  98. axisPointer: {
  99. type: "shadow",
  100. label: {
  101. show: true
  102. }
  103. }
  104. },
  105. legend: {
  106. data: ["占比","一般问题","较重问题", "严重问题"],
  107. top: "5%",
  108. textStyle: {
  109. // color: "#ffffff"
  110. }
  111. },
  112. xAxis: {
  113. data:_self.barData_zy.name,
  114. axisLine: {
  115. show: true //隐藏X轴轴线
  116. },
  117. axisTick: {
  118. show: true //隐藏X轴刻度
  119. },
  120. axisLabel: {
  121. rotate:15,
  122. show: true,
  123. textStyle: {
  124. // color: "#ebf8ac" //X轴文字颜色
  125. }
  126. },
  127. axisLine: {
  128. lineStyle: {
  129. // color: '#01FCE3'
  130. }
  131. },
  132. },
  133. yAxis: [{
  134. type: "value",
  135. name: "个",
  136. nameTextStyle: {
  137. // color: "#ebf8ac"
  138. },
  139. splitLine: {
  140. show: false
  141. },
  142. splitLine: {
  143. show: false
  144. },
  145. axisTick: {
  146. show: true
  147. },
  148. axisLine: {
  149. show: true
  150. },
  151. axisLabel: {
  152. show: true,
  153. textStyle: {
  154. // color: "#ebf8ac"
  155. }
  156. },
  157. },
  158. {
  159. type: "value",
  160. name: "占比",
  161. nameTextStyle: {
  162. // color: "#ebf8ac"
  163. },
  164. position: "right",
  165. splitLine: {
  166. show: false
  167. },
  168. splitLine: {
  169. show: false
  170. },
  171. axisTick: {
  172. show: true
  173. },
  174. axisLine: {
  175. show: true
  176. },
  177. axisLabel: {
  178. show: true,
  179. formatter: "{value} %", //右侧Y轴文字显示
  180. textStyle: {
  181. // color: "#ebf8ac"
  182. }
  183. }
  184. },
  185. {
  186. type: "value",
  187. gridIndex: 0,
  188. min: 50,
  189. max: 100,
  190. splitNumber: 8,
  191. splitLine: {
  192. show: false
  193. },
  194. axisLine: {
  195. show: false
  196. },
  197. axisTick: {
  198. show: false
  199. },
  200. axisLabel: {
  201. show: false
  202. },
  203. splitArea: {
  204. show: true,
  205. areaStyle: {
  206. color: ["rgba(250,250,250,0.0)", "rgba(250,250,250,0.05)"]
  207. }
  208. }
  209. }
  210. ],
  211. series: [{
  212. name: "占比",
  213. type: "line",
  214. yAxisIndex: 1, //使用的 y 轴的 index,在单个图表实例中存在多个 y轴的时候有用
  215. showAllSymbol: true, //显示所有图形。
  216. symbol: "circle", //标记的图形为实心圆
  217. symbolSize: 10, //标记的大小
  218. itemStyle: {
  219. //折线拐点标志的样式
  220. color: "#49dff0"
  221. },
  222. lineStyle: {
  223. color: "#49dff0"
  224. },
  225. areaStyle:{
  226. color: "rgba(5,140,255, 0.2)"
  227. },
  228. // data: [23,21,16,16,16,8]
  229. data: _self.barData_zy.nhs_zb
  230. },
  231. {
  232. name: "一般问题",
  233. stack: "总量",
  234. type: "bar",
  235. barWidth: 25,
  236. itemStyle: {
  237. normal: {
  238. color: "#5ce9c7"
  239. }
  240. },
  241. // data: [47,47,35,36,35,15]
  242. data: _self.barData_zy.normal,
  243. },
  244. {
  245. name: "较重问题",
  246. stack: "总量",
  247. type: "bar",
  248. barWidth: 25,
  249. itemStyle: {
  250. normal: {
  251. color: "#fed172"
  252. }
  253. },
  254. // data: [47,47,35,36,35,15]
  255. data: _self.barData_zy.heavier,
  256. },
  257. {
  258. name: "严重问题",
  259. stack: "总量",
  260. type: "bar",
  261. barWidth: 25,
  262. itemStyle: {
  263. normal: {
  264. color: "#fb6086"
  265. }
  266. },
  267. // data: [7,4,3,2,2,5]
  268. data: _self.barData_zy.serious,
  269. },
  270. {
  271. name: '严重程度分布情况',
  272. type: 'pie',
  273. radius:'20%',
  274. center: ['85%', '20%'],
  275. // hoverAnimation: false,
  276. color: ['#5ce9c7', '#fed172', '#fb6086'],
  277. label: {
  278. normal: {
  279. formatter: function(params, ticket, callback) {
  280. var total = 0;
  281. var percent = 0;
  282. _self.pieData_zy.forEach(function(value, index, array) {
  283. total += value.value;
  284. });
  285. if(total != 0){
  286. percent = ((params.value / total) * 100).toFixed(1);
  287. return '{blackSmall|' + params.name + '}{black|' + params.value + '}\n{blue|' + percent + '%}';
  288. }else{
  289. return '{blackSmall|' + params.name + '}{black|' + params.value + '}\n{blue|' + "0" + '%}';
  290. }
  291. },
  292. rich: rich
  293. },
  294. },
  295. data: _self.pieData_zy,
  296. itemStyle: {
  297. emphasis: {
  298. shadowBlur: 10,
  299. shadowOffsetX: 0,
  300. shadowColor: 'rgba(0, 0, 0, 0.5)'
  301. }
  302. }
  303. },
  304. {
  305. name: '典型问题分布',
  306. type: 'pie',
  307. radius:'20%',
  308. center: ['85%', '65%'],
  309. // hoverAnimation: false,
  310. color: ['#fb6086', '#fed172'],
  311. label: {
  312. normal: {
  313. formatter: function(params, ticket, callback) {
  314. var total = 0;
  315. var percent = 0;
  316. _self.pieData_zy.forEach(function(value, index, array) {
  317. total += value.value;
  318. });
  319. if(total != 0){
  320. percent = ((params.value / total) * 100).toFixed(1);
  321. return '{blackSmall|' + params.name + '}{black|' + params.value + '}\n{blue|' + percent + '%}';
  322. }else{
  323. return '{blackSmall|' + params.name + '}{black|' + params.value + '}\n{blue|' + "0" + '%}';
  324. }
  325. },
  326. rich: rich
  327. },
  328. },
  329. data: [
  330. {
  331. "value":32,
  332. "name": "典型问题"
  333. },
  334. {
  335. "value":23,
  336. "name": "非典型问题"
  337. },
  338. ],
  339. itemStyle: {
  340. emphasis: {
  341. shadowBlur: 10,
  342. shadowOffsetX: 0,
  343. shadowColor: 'rgba(0, 0, 0, 0.5)'
  344. }
  345. }
  346. }
  347. ]
  348. };
  349. chart.setOption(option);
  350. window.addEventListener("resize", () => {
  351. chart.resize();
  352. });
  353. },
  354. },
  355. //生命周期 - 创建完成(可以访问当前this实例)
  356. created() {
  357. },
  358. //生命周期 - 挂载完成(可以访问DOM元素)
  359. mounted() {
  360. this.init_Serious_BarLineChart();
  361. },
  362. beforeCreate() {}, //生命周期 - 创建之前
  363. beforeMount() {}, //生命周期 - 挂载之前
  364. beforeUpdate() {}, //生命周期 - 更新之前
  365. updated() {}, //生命周期 - 更新之后
  366. beforeDestroy() {}, //生命周期 - 销毁之前
  367. destroyed() {}, //生命周期 - 销毁完成
  368. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  369. }
  370. </script>
  371. <style scoped>
  372. </style>