| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- /**
- * 总呼数据图形分析
- * */
- var token = $.cookie("token"),
- hjCompaer, //图形
- legendCon; //图形legend
- $(document).ready(function() {
- $('.tool_bars').authorizeButton();
- var preYear = helper.DateFormat.getPreYear();
- var nowYear = helper.DateFormat.getNowYear();
- var nowValue = preYear + ' - ' + nowYear;
- laydate.render({
- elem: '#choseTime',
- type: 'year',
- value: nowValue,
- theme: '#249fea',
- range: true //或 range: '~' 来自定义分割字符
- });
- $('#choseTime').trigger('change');
- hjCompaer = echarts.init(document.getElementById('hjCompaer'));
- option = {
- tooltip: {
- trigger: 'axis',
- },
- legend: {
- data: legendCon,
- bottom: 0
- },
- xAxis: [{
- type: 'category',
- data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
- axisPointer: {
- type: ''
- }
- }],
- yAxis: [{
- type: 'value',
- name: '电话数量',
- nameLocation: 'middle',
- nameGap: 40,
- min: 0,
- max: 500,
- interval: 50,
- axisLabel: {
- formatter: '{value} '
- }
- },
- {
- type: 'value',
- name: '百分比',
- nameLocation: 'middle',
- nameGap: 35,
- min: 0,
- max: 100,
- interval: 10,
- axisLabel: {
- formatter: '{value}%'
- }
- }
- ],
- series: [{
- name: '',
- type: 'bar',
- data: []
- },
- {
- name: '',
- type: 'bar',
- data: []
- },
- {
- name: '',
- type: 'line',
- data: []
- },
- {
- name: '',
- type: 'bar',
- data: []
- },
- {
- name: '',
- type: 'bar',
- yAxisIndex: 1,
- data: []
- },
- {
- name: '',
- type: 'line',
- yAxisIndex: 1,
- data: []
- }
- ],
- color: ['#1ab394', '#adcbfd', '#fbbe5b', '#f26ea2', '#88ebc4', '#fa957f']
- };
- getChartDataList(preYear,nowYear);
- hjCompaer.setOption(option);
- //搜索事件
- $("#sc_btns").click(function() {
- var st = $('#choseTime').val() && $('#choseTime').val().split(' - ')[0];
- var et = $('#choseTime').val() && $('#choseTime').val().split(' - ')[1];
- if(st == et){
- layer.confirm('选择的年份不能一样!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- getChartDataList(st,et);
- hjCompaer.setOption(option);
- });
- });
- function getChartDataList(py,ny) {
- var arr = [];
- var allData = [];
- $.ajax({
- type: 'get',
- url: huayi.config.callcenter_url + 'YearContrast/GetDataList',
- dataType: 'json',
- data: {
- beginyear: py,
- endyear: ny,
- token: token,
- },
- async: false,
- success: function(res) {
- var content = res.data;
- $.each(content, function(index, ele) {
- arr.push(content[index].key)
- allData.push(content[index].value)
-
- });
- }
- });
- legendCon = arr;
- seriesData = allData;
- //console.log(legendCon);
- option.legend.data = legendCon; //图例
- option.series[0].name = legendCon[0]; //图例
- //添加数据name
- for(var i = 0; i < legendCon.length; i++) {
- option.series[i].name = legendCon[i];
- }
- //添加图形数据
- for(var j = 0; j < seriesData.length; j++) {
- option.series[j].data = seriesData[j];
- }
- }
- //导出功能
- function btn_export(obj) {
- var url = huayi.config.callcenter_url + "YearContrast/ExptList?token=" + token;
- var byear = $('#choseTime').val() && $('#choseTime').val().split(' - ')[0];
- var lyear = $('#choseTime').val() && $('#choseTime').val().split(' - ')[1];
- url += "&beginyear=" + byear + "&endyear=" + lyear;
- window.location.href = url;
- }
|