s14bufuhexiangCol.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <!-- <div @click="toDetailed()" class="statisticsPage" :style="{width:width}"> -->
  3. <div class="statisticsPage" :style="{width:width}">
  4. <div :id="id" :style="{height:height}"/>
  5. <!-- 打开详情弹窗-->
  6. <div v-if="dialogOff">
  7. <dialogView
  8. :dialogOff = "dialogOff"
  9. @close = "close"
  10. :title="title"
  11. :data="data"
  12. />
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import * as echarts from 'echarts'
  18. import dialogView from '../properties/s14bufehexiangPro.vue'
  19. import {GetPercent,GetMax} from '../js/config.js'
  20. export default {
  21. components:{
  22. dialogView
  23. },
  24. props: {
  25. data: {
  26. type: Object,
  27. },
  28. width:{
  29. type:String,
  30. default:"20%"
  31. },
  32. height:{
  33. type:String,
  34. default: "100%"
  35. },
  36. id:{
  37. type:String,
  38. default:"s14bufuhexiang"
  39. },
  40. click:{
  41. type:String,
  42. default:'true'
  43. },
  44. colorw:{
  45. type:String,
  46. default:'true'
  47. },
  48. direction:{
  49. type:String,
  50. default:'y'
  51. }
  52. },
  53. data () {
  54. return {
  55. title:'不符合项各部门完成情况',
  56. dialogOff:false,
  57. measured:[]
  58. }
  59. },
  60. mounted(){
  61. this.drawLine();
  62. },
  63. methods: {
  64. close(){
  65. this.dialogOff = false
  66. },
  67. /* 跳转统计页面*/
  68. toDetailed(){
  69. if(this.click == "true"){
  70. this.dialogOff = true
  71. }
  72. },
  73. drawLine(){
  74. // let beginInof = Number(this.data.t_complaintBegin.number)
  75. // let endInof = Number(this.data.t_complaintEnd.number)
  76. let s14bufuhexiang = echarts.init(document.getElementById(this.id))
  77. let option;
  78. let that = this
  79. let barColor = ['#00CCFF','#33FF00','#FF0000','#FF66CC','#EC5800','#AAFF00','#F8DE7E','#B87333','#FF4433',' #9F2B68','#C9A9A6','#C3B1E1','#880808','#097969','#89CFF0','#5D3FD3',' #FBCEB1','#E49B0F','#ECFFDC','#A52A2A','#D27D2D','#FFBF00','#A0522D','#FF00FF','#FFB6C1','#F89880','#D8BFD8','#5D3FD3','#770737','#DA70D6']
  80. let barNum = []
  81. for (let i = 0; i < this.data.num.title.length-1; i++) {
  82. if(i==this.data.num.title.length-3){
  83. barNum.push({
  84. type: 'bar',
  85. itemStyle: {color: barColor[i]},
  86. label:{
  87. show: true,
  88. formatter:function(params){ //标签内容
  89. let str = that.direction=='x'?params.value[params.seriesName]+' '+params.data.chu+'%':params.data.chu+'%\n'+params.value[params.seriesName]
  90. return str
  91. },
  92. position: this.direction=='x'?'right':'top',
  93. textStyle:{
  94. fontSize: 12,
  95. color:'#B0CEFC'
  96. }
  97. }
  98. })
  99. }else{
  100. barNum.push({
  101. type: 'bar',
  102. itemStyle: {color: barColor[i]},
  103. label:{
  104. normal:{
  105. show:true,
  106. position:this.direction=='x'?'right':'top',
  107. textStyle:{
  108. fontSize: 12,
  109. color:'#B0CEFC'
  110. }
  111. }
  112. }
  113. })
  114. }
  115. }
  116. let heng = {
  117. splitLine:{show: false},
  118. type: 'category',
  119. minInterval: 1,
  120. min: 0,
  121. axisLabel: {
  122. show: true,
  123. textStyle: {
  124. color: this.colorw //这里用参数代替了
  125. },
  126. fontSize: 12
  127. },
  128. axisLine:{
  129. show: true,
  130. lineStyle:{
  131. color:this.colorw,
  132. width:1, //x轴线的宽度
  133. }
  134. },
  135. axisTick:{
  136. show:true
  137. }
  138. }
  139. let zong = {
  140. splitLine:{show: false},
  141. minInterval: 1,
  142. min: 0,
  143. axisLabel: {
  144. show: true,
  145. textStyle: {
  146. color: this.colorw //这里用参数代替了
  147. },
  148. fontSize: 12
  149. },
  150. axisLine:{
  151. show: true,
  152. lineStyle:{
  153. color:this.colorw,
  154. width:1, //x轴线的宽度
  155. }
  156. },
  157. axisTick:{
  158. show:true
  159. }
  160. }
  161. option = {
  162. title: {
  163. text: this.title,
  164. textStyle:{ fontSize:14,color: this.colorw }
  165. },
  166. legend: {
  167. textStyle: {
  168. fontSize: 12,
  169. color: '#B0CEFC' // 图例文字颜色
  170. },
  171. top:"5%",
  172. formatter: function (name) {
  173. if(name === 'wnum'){
  174. return '未完成数量';
  175. }else if(name === 'num'){
  176. return '已完成数量(完成率)';
  177. }else if(name === 'numA'){
  178. return '计划数量';
  179. }
  180. }
  181. },
  182. grid: {
  183. top: '15%',
  184. left: '3%',
  185. right: '4%',
  186. bottom: '5%',
  187. containLabel: true
  188. },
  189. xAxis: this.direction=='x'?zong:heng,
  190. yAxis: this.direction=='x'?heng:zong,
  191. dataset: {
  192. dimensions: this.data.num.title,
  193. source: this.data.num.number
  194. },
  195. series: barNum,
  196. dataZoom: [
  197. {
  198. id: 'dataZoomY',
  199. type: 'inside',
  200. yAxisIndex: [0],
  201. filterMode: 'empty'
  202. }
  203. ],
  204. };
  205. option && s14bufuhexiang.setOption(option);
  206. }
  207. }
  208. }
  209. </script>
  210. <style scoped>
  211. #s14bufuhexiang:hover{
  212. transition: all 0.5s;
  213. transform:scale(1.03);
  214. }
  215. .statisticsPage{
  216. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  217. float: left;
  218. }
  219. </style>