var myChart_back_responsibility_module = echarts.init(document.getElementById("back_responsibility"));
var call_back_responsibility_dict = eval("(" + $("#call_back_responsibility_dict").val() + ")");
var back_responsibility = [];
var back_times = [];
var version_name = [];
for (var back_obj in call_back_responsibility_dict) {
back_responsibility.push(back_obj);
back_times.push(call_back_responsibility_dict[back_obj]["back_count"]);
}
// title显示暂无数据
if (back_responsibility.length === 0) {
var show_title = {
text: '暂无数据',
x: 'center',
y: 'center',
textStyle: {
color: '#65ABE7',
fontWeight: 'normal',
fontSize: 16
}
}
}else {
var show_title = {
text: '责任人-打回数',
left: 'center',
}
}
var option_back_responsibility = {
title: show_title,
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
enterable: true,
formatter: function (params) {
//x轴名称
var name = params[0].name;
//值
var value = Number(params[0].value);
var valueFilter = '<i style="</i>' + "打回数:" + '<span style="font-weight: bolder">' + Number(params[0].value).toString() + '</span>' + '</br>';
if (value < 100) {
return name + '</br>' + params[0].marker + valueFilter + '</br>' + '<span style="font-weight: bolder">' + '打回迭代:' + '</span>' + '</br>' + getBackInfo(params, name, call_back_responsibility_dict);
}
},
// 自定义tooltip卡片的位置
position: function (point, params, dom, rect, size) {
var x = 0; // x坐标位置
var y = 0; // y坐标位置
// 当前鼠标位置
var pointX = point[0];
var pointY = point[1];
// 提示框大小
var boxWidth = size.contentSize[0];
var boxHeight = size.contentSize[1];
// boxWidth > pointX 说明鼠标左边放不下提示框
x = pointX - boxWidth;
// boxHeight > pointY 说明鼠标上边放不下提示框
y = pointY - boxHeight;
return [x, y];
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value',
interval: 1
},
yAxis: {
type: 'category',
data: back_responsibility,
name: "责任人"
},
series: [
{
name: '打回数',
type: 'bar',
data: back_times,
}
],
};
myChart_back_responsibility_module.setOption(option_back_responsibility);
function getBackInfo(params, name, data) {
if (data[name]) {
var new_id = [];
var version_name_list = data[name]["back_info"]["version_name"];
var process_id_list = data[name]["back_info"]["process_id"];
for (var i = 0; i < process_id_list.length; i++) {
new_id.push(params[0].marker + "<a href=\"/haohan/get_process_detail/?show_back=1&process_id=" + process_id_list[i].toString() + "\"target=\"_blank\">" + version_name_list[i] + "</a></br>")
}
return new_id.toString().replace(",", " ")
}
}