Нет описания

trafficData.js 6.3KB

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