function drawDayECharts(xArray,array_y1,array_y2,array_y3){
var dom_day = document.getElementById('main_area');
var myChart = echarts.init(dom_day);
myChart.off('click');
var option = {
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},
//formatter: '{b0}
{a0}: {c0}
{a1}: {c1}
{a2}: {c2}%'
},
legend: {
data: ['提交成功', '提交失败', '提交成功率']
},
grid: {
left: '0%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
axisTick: {show: false},
data: xArray,
}
],
yAxis: [
{
type: 'value',
name: '数量',
axisTick: {
show: false
},
},
{
type: 'value',
name: '成功率',
axisLabel: {
formatter: '{value} %'
}
}
],
series: [
{
name: '提交成功',
type: 'bar',
stack: '提交',
color: '#6edaee',
data: array_y1
},
{
name: '提交失败',
type: 'bar',
stack: '提交',
color: '#d4d4d3',
data: array_y2
},
{
name: "提交成功率",
type: 'line',
yAxisIndex: 1,
color: '#00a2e6',
data: array_y3
}
]
};
option.tooltip.formatter = function (params) {
console.log(params);
return '20'+params[0].name.substr(0,2)+'年'+params[0].name.substr(3,2)+'月'+params[0].name.substr(6,2)+'日'+'
'
+params[0].seriesName+':'+params[0].value+'
'
+params[1].seriesName+':'+params[1].value+'
'
+params[2].seriesName+':'+params[2].value+'%';
}
myChart.clear();
myChart.setOption(option);
$(dom_day).sizeChanged(myChart.resize);
}
function drawMonthECharts(xArray,array_y1,array_y2,array_y3){
var dom_month = document.getElementById('main_area');
var myChart = echarts.init(dom_month);
myChart.off('click');
var option = {
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},
//formatter: '{b0}
{a0}: {c0}
{a1}: {c1}
{a2}: {c2}%'
},
legend: {
data: ['提交成功', '提交失败', '提交成功率']
},
grid: {
left: '0%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
axisTick: {show: false},
data: xArray,
}
],
yAxis: [
{
type: 'value',
name: '数量',
axisTick: {
show: false
},
},
{
type: 'value',
name: '成功率',
axisLabel: {
formatter: '{value} %'
}
}
],
series: [
{
name: '提交成功',
type: 'bar',
stack: '提交',
clickable:false,
color: '#6edaee',
data: array_y1
},
{
name: '提交失败',
type: 'bar',
stack: '提交',
clickable:false,
color: '#d4d4d3',
data: array_y2
},
{
name: "提交成功率",
type: 'line',
yAxisIndex: 1,
clickable:false,
color: '#00a2e6',
data: array_y3
}
]
};
option.tooltip.formatter = function (params) {
console.log(params);
return params[0].name.substr(0,4)+'年'+params[0].name.substr(5,2)+'月'+'
'
+params[0].seriesName+':'+params[0].value+'
'
+params[1].seriesName+':'+params[1].value+'
'
+params[2].seriesName+':'+params[2].value+'%';
}
myChart.clear();
myChart.setOption(option);
$(dom_month).sizeChanged(myChart.resize);
}
function drawComECharts(xArray,array_y1,array_y2,service_type,date_start,date_end,company_id){
var dom_com = document.getElementById('main_area');
var myChart = echarts.init(dom_com);
var option = {
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},
//formatter: '{b0}
{a0}: {c0}
{a1}: {c1}
{a2}: {c2}%'
},
legend: {
data: ['提交成功', '提交失败']
},
grid: {
left: '0%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
axisTick: {show: false},
data: xArray,
}
],
yAxis: [
{
type: 'value',
name: '数量',
axisTick: {
show: false
},
},
],
series: [
{
name: '提交成功',
type: 'bar',
stack: '提交',
color: '#6edaee',
data: array_y1
},
{
name: '提交失败',
type: 'bar',
stack: '提交',
color: '#d4d4d3',
data: array_y2
},
]
};
option.tooltip.formatter = function (params) {
console.log(params);
return params[0].name+'
'
+params[0].seriesName+':'+params[0].value+'
'
+params[1].seriesName+':'+params[1].value;
}
myChart.clear();
myChart.setOption(option);
myChart.on('click', function (params) {
//console.log(params);
//console.log(service_type);
//console.log(date_start);
//console.log(date_end);
window.location.href = "stat_user_company.php?service_type=" + service_type + "&dimension_type=0" +
"&date_start=" + date_start + "&date_end=" + date_end + "&company_id=" + company_id[params.dataIndex];
});
$(dom_com).sizeChanged(myChart.resize);
}
(function ($) {
$.fn.sizeChanged = function (handleFunction) {
var element = this;
var lastWidth = element.width();
var lastHeight = element.height();
setInterval(function () {
if (lastWidth === element.width() && lastHeight === element.height())
return;
if (typeof (handleFunction) == 'function') {
element.height(element.width()*2/5);
handleFunction();
lastWidth = element.width();
lastHeight = element.height();
}
}, 100);
return element;
};
}(jQuery));