Ei kuvausta

trafficData.js 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. getworkOrder()
  2. var telCountData
  3. var barWidth = 20
  4. $('.btn_time').click(function(e) {
  5. if(e.target.tagName == 'SPAN') {
  6. if($(e.target).attr('data-state') == '1') {
  7. $(".hwsjtj").hide()
  8. $('.daySeat').css('display', 'none')
  9. $('.timeTraffic').css('display', 'inline-block')
  10. $('#traffic').css('display', 'none')
  11. $('#timeTraffic').css('display', 'block')
  12. $(this).siblings(".act").children("label").attr("indexTitle", "日话务数据统计1")
  13. $('.call_situation h2').text('话务数据统计')
  14. getworkOrder()
  15. trafficState = 0
  16. }
  17. }
  18. e.stopPropagation();
  19. })
  20. function getworkOrder() {
  21. let workOrderData = [];
  22. let workOrderName = []
  23. new doAjax({
  24. url: huayi.config.callcenter_url + "/InfoNew/GetTelCountByNow",
  25. data: {
  26. timetype: telCountByNowType
  27. },
  28. callBack: function(res) {
  29. var data = res.data.hw[0]
  30. telCountData = data
  31. trafficDataChart(data)
  32. }
  33. });
  34. }
  35. function getLabelOption(positionObj, numberType) {
  36. var labelOption = {
  37. show: true,
  38. rotate: 0,
  39. align: 'left',
  40. color: '#fff',
  41. verticalAlign: 'middle',
  42. position: positionObj,
  43. formatter: function(params) {
  44. if(params.value > 0) {
  45. dataValue = params.seriesName + ': ' + params.value
  46. if(params.seriesName === "回拨") {
  47. dataValue = dataValue + '(' + telCountData.hbbili + '%)'
  48. } else if(params.seriesName === "自助") {
  49. dataValue = dataValue + '(' + telCountData.zzbili + '%)'
  50. } else if(params.seriesName === "人工") {
  51. dataValue = dataValue + '(' + telCountData.jtbili + '%)'
  52. } else if(params.seriesName === "呼出接通") {
  53. dataValue = dataValue + '(' + telCountData.hcbili + '%)'
  54. }
  55. return dataValue;
  56. } else {
  57. return ' ';
  58. }
  59. },
  60. fontSize: 12,
  61. };
  62. return labelOption
  63. }
  64. function getItemStyleColor(colorSting){
  65. var ColorData
  66. if (colorSting === 'red') {
  67. ColorData = ['#DC0707','#DC0707','#AF0808','#AF0808']
  68. } else if(colorSting === 'yellow'){
  69. ColorData = ['#EE7923','#F67C20','#D16A1E','#CC681E']
  70. } else if (colorSting === 'green'){
  71. ColorData = ['#2ADFE1','#32FFEE','#04D1C1','#00E8D5']
  72. }
  73. var color = {
  74. type: 'linear',
  75. x: 0,
  76. x2: 1,
  77. y: 0,
  78. y2: 0,
  79. colorStops: [{
  80. offset: 0,
  81. color: ColorData[0]
  82. },
  83. {
  84. offset: 0.5,
  85. color: ColorData[1]
  86. },
  87. {
  88. offset: 0.5,
  89. color: ColorData[2]
  90. },
  91. {
  92. offset: 1,
  93. color: ColorData[3]
  94. }
  95. ]
  96. }
  97. return color
  98. }
  99. function trafficDataChart(getdata) {
  100. let hotThingsLeft = echarts.init(document.getElementById("timeTrafficLeft"));
  101. let hotThingsRight = echarts.init(document.getElementById("timeTrafficRight"));
  102. window.onresize = function() {
  103. hotThingsLeft.resize()
  104. hotThingsRight.resize()
  105. }
  106. hotThingsLeft.setOption(getOption(getSeriesLeftData(),['呼入量接通量']));
  107. hotThingsRight.setOption(getOption(getSeriesRightData(),['呼出量呼出接通量']));
  108. }
  109. function getSeriesLeftData (){
  110. return [{
  111. name: '有效来电',
  112. type: 'bar',
  113. stack: 'A',
  114. label: getLabelOption(['-350%', 40], 0),
  115. barWidth,
  116. emphasis: {
  117. focus: 'series'
  118. },
  119. data: [telCountData.effective],
  120. itemStyle: {
  121. color: getItemStyleColor('red')
  122. }
  123. },
  124. {
  125. name: '无效来电',
  126. type: 'bar',
  127. stack: 'A',
  128. label: getLabelOption(['-350%', 0], 0),
  129. barWidth,
  130. emphasis: {
  131. focus: 'series'
  132. },
  133. data: [telCountData.invalid],
  134. itemStyle: {
  135. color: getItemStyleColor('yellow')
  136. }
  137. },
  138. {
  139. name: '人工',
  140. type: 'bar',
  141. stack: 'Ad',
  142. barWidth, //hbbili
  143. label: getLabelOption(['100%', 20], 0),
  144. emphasis: {
  145. focus: 'series'
  146. },
  147. data: [telCountData.jtcount],
  148. itemStyle: {
  149. color: getItemStyleColor('green')
  150. }
  151. },
  152. {
  153. name: '自助',
  154. type: 'bar',
  155. stack: 'Ad',
  156. barWidth,
  157. label: getLabelOption(['100%', 0], 0),
  158. emphasis: {
  159. focus: 'series'
  160. },
  161. data: [telCountData.zzcount],
  162. itemStyle: {
  163. color: getItemStyleColor('yellow')
  164. }
  165. },
  166. {
  167. name: '回拨',
  168. type: 'bar',
  169. stack: 'Ad',
  170. barWidth,
  171. label: getLabelOption(['100%', -20], 0),
  172. emphasis: {
  173. focus: 'series'
  174. },
  175. data: [telCountData.hbcount],
  176. itemStyle: {
  177. color: getItemStyleColor('red')
  178. }
  179. },
  180. ]
  181. }
  182. function getSeriesRightData (){
  183. return [{
  184. name: '呼出',
  185. type: 'bar',
  186. barWidth,
  187. label: getLabelOption(['-200%', -5], 0),
  188. labelLine:{
  189. show:true,
  190. normal:{
  191. length:15,
  192. length2: 0,
  193. }
  194. },
  195. emphasis: {
  196. focus: 'series'
  197. },
  198. data: [telCountData.hccount],
  199. itemStyle: {
  200. color: getItemStyleColor('red')
  201. }
  202. },
  203. {
  204. name: '呼出接通',
  205. type: 'bar',
  206. barWidth,
  207. label: getLabelOption(['-100%', -5], 0),
  208. emphasis: {
  209. focus: 'series'
  210. },
  211. data: [telCountData.hcjtcount],
  212. itemStyle: {
  213. color: getItemStyleColor('green')
  214. }
  215. }
  216. ]
  217. }
  218. function getOption(getSeriesData,xAxisData) {
  219. return option = {
  220. tooltip: {
  221. trigger: 'item',
  222. show: true,
  223. // 进行数据处理
  224. formatter: function(params) {
  225. console.log(params, 'params')
  226. var html = '';
  227. if(params.value > 0) {
  228. html += params.marker;
  229. if(params.name.indexOf('率') >= 0) {
  230. html += params.seriesName + ': ' + params.value + '%<br/>';
  231. } else {
  232. html += params.seriesName + ': ' + params.value + '<br/>';
  233. }
  234. }
  235. return html;
  236. }
  237. },
  238. grid: {
  239. left: '3%',
  240. right: '4%',
  241. bottom: '15%',
  242. containLabel: true
  243. },
  244. xAxis: [{
  245. type: 'category',
  246. axisLine: {
  247. lineStyle: {
  248. color: '#ffffff'
  249. }
  250. },
  251. axisLabel: {
  252. show: true,
  253. rotate: 0, // 角度值:Number
  254. interval: '0',
  255. verticalAlign: 'left',
  256. fontSize: 12, // 顺便调小一点字体大小
  257. padding: [0, 0, 0, -10],
  258. textStyle: {
  259. color: '#ffffff'
  260. },
  261. formatter: function(value) {
  262. //x轴的文字改为竖版显示
  263. var str;
  264. console.log(value)
  265. if(value === "呼入量接通量") {
  266. str = "呼入量 接通量"
  267. } else if(value === "呼出量呼出接通量") {
  268. str = " 呼出量 呼出接通量"
  269. }
  270. return str
  271. }
  272. },
  273. data: xAxisData
  274. }],
  275. yAxis: [{
  276. type: 'value',
  277. splitLine: {
  278. show: false
  279. },
  280. axisLine: {
  281. lineStyle: {
  282. color: '#ffffff'
  283. }
  284. }
  285. }],
  286. color: ['#cd5c5c', '#87cefa', '#da70d6', '#32cd32', '#6495ed',
  287. '#ff69b4', '#ba55d3', '#cd5c5c', '#ffa500', '#40e0d0'
  288. ],
  289. series: getSeriesData
  290. };
  291. }