暫無描述

trafficData.js 6.2KB

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