var option = {
legend: {
bottom: "0",
textStyle: { color: "#65ABE7", fontSize: fontSize }
},
"grid": {
"top": "15%",
"bottom": "25%",
"right": "3%",
"left": "10%"
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
},
position: function (point, params, dom, rect, size) {
// 鼠标坐标和提示框位置的参考坐标系是:以外层div的左上角那一点为原点,x轴向右,y轴向下
// 提示框位置
var x = 0; // x坐标位置
var y = 0; // y坐标位置
// 当前鼠标位置
var pointX = point[0];
var pointY = point[1];
// 外层div大小
// var viewWidth = size.viewSize[0];
// var viewHeight = size.viewSize[1];
// 提示框大小
var boxWidth = size.contentSize[0];
var boxHeight = size.contentSize[1];
// boxWidth > pointX 说明鼠标左边放不下提示框
if (boxWidth > pointX) {
x = pointX + 10;
} else { // 左边放的下
x = pointX - boxWidth - 10;
}
// boxHeight > pointY 说明鼠标上边放不下提示框
if (boxHeight > pointY) {
y = 5;
} else { // 上边放得下
y = pointY - boxHeight;
}
return [x, y];
},
},
xAxis: {
data: timeName,
axisLine: {
show: false
},
axisTick: {
show: false,
lineStyle: {
color: "#65ABE7",
width: 1
},
},
axisLabel: { //X轴标签
show: true,
interval: 0,
rotate: 12,
textStyle: {
color: '#65ABE7', //字体颜色
fontSize: fontSize //字体大小
}
}
},
yAxis: [
{
type: 'value',
min: 0,
//max: 100,
//interval: 1,
axisLabel: {
formatter: '{value}',
textStyle: {
color: '#65ABE7', //字体颜色
fontSize: fontSize //字体大小
}
},
axisTick: {
show: false
},
axisLine: {
show: false
},
splitLine: { //Y轴分隔符
show: true,
lineStyle: {
color: '#65ABE7',
}
}
},
],
series: [
{
name: 'A01',
type: 'bar',
data: oneNum,
itemStyle: {
normal: {
//color: '#00d98b',
//这里是颜色
color: function (params) {
console.log("params", params);
if (params.name == "360天以上" || params.name == "181~360天") {
return "red";
} else if (params.name == "121~180天") {
return "yellow";
} else {
return "#00d98b";
}
},
label: {
show: false, //显示
formatter: "{c}",
position: 'top', //在上方
textStyle: { //文字样式
color: '#fff',
fontSize: fontSize
}
}
}
},
},
{
name: 'D07',
type: 'bar',
data: twoNum,
itemStyle: {
normal: {
color: function (params) {
console.log("params", params);
if (params.name == "360天以上" || params.name == "181~360天") {
return "red";
} else if (params.name == "121~180天") {
return "yellow";
} else {
return "#00d98b";
}
},
label: {
show: false, //显示
formatter: "{c}",
position: 'top', //在上方
textStyle: { //文字样式
color: '#fff',
fontSize: fontSize
}
}
}
},
},
{
name: 'W09',
type: 'bar',
data: threeNum,
itemStyle: {
normal: {
color: function (params) {
console.log("params", params);
if (params.name == "360天以上" || params.name == "181~360天") {
return "red";
} else if (params.name == "121~180天") {
return "yellow";
} else {
return "#00d98b";
}
},
label: {
show: false, //显示
formatter: "{c}",
position: 'top', //在上方
textStyle: { //文字样式
color: '#fff',
fontSize: fontSize
}
}
}
},
},
{
name: 'W29',
type: 'bar',
data: fourNum,
itemStyle: {
normal: {
color: function (params) {
console.log("params", params);
if (params.name == "360天以上" || params.name == "181~360天") {
return "red";
} else if (params.name == "121~180天") {
return "yellow";
} else {
return "#00d98b";
}
},
label: {
show: false, //显示
formatter: "{c}",
position: 'top', //在上方
textStyle: { //文字样式
color: '#fff',
fontSize: fontSize
}
}
}
},
},
{
name: 'A21',
type: 'bar',
data: fiveNum,
itemStyle: {
normal: {
color: function (params) {
console.log("params", params);
if (params.name == "360天以上" || params.name == "181~360天") {
return "red";
} else if (params.name == "121~180天") {
return "yellow";
} else {
return "#00d98b";
}
},
label: {
show: false, //显示
formatter: "{c}",
position: 'top', //在上方
textStyle: { //文字样式
color: '#fff',
fontSize: fontSize
}
}
}
},
},
{
name: 'D27',
type: 'bar',
data: sixNum,
itemStyle: {
normal: {
color: function (params) {
console.log("params", params);
if (params.name == "360天以上" || params.name == "181~360天") {
return "red";
} else if (params.name == "121~180天") {
return "yellow";
} else {
return "#00d98b";
}
},
label: {
show: false, //显示
formatter: "{c}",
position: 'top', //在上方
textStyle: { //文字样式
color: '#fff',
fontSize: fontSize
}
}
}
},
}
]
};
var timeName=materailStorageList.map(x=>x.NAME);
var oneNum=materailStorageList.map(x=>x.A01_NUM);
var twoNum=materailStorageList.map(x=>x.D07_NUM);
var threeNum=materailStorageList.map(x=>x.W09_NUM);
var fourNum=materailStorageList.map(x=>x.W29_NUM);
var fiveNum=materailStorageList.map(x=>x.A21_NUM);
var sixNum=materailStorageList.map(x=>x.D27_NUM);
//伪数据
materailStorageList:[
{NAME:"1~7天(正产)",A01_NUM:474,D07_NUM:611,W09_NUM:577,W29_NUM:563,A21_NUM:258,D27_NUM:458},
{NAME:"8~15天",A01_NUM:656,D07_NUM:511,W09_NUM:477,W29_NUM:548,A21_NUM:582,D27_NUM:752},
{NAME:"16~21天",A01_NUM:567,D07_NUM:411,W09_NUM:377,W29_NUM:785,A21_NUM:465,D27_NUM:564},
{NAME:"22~30天",A01_NUM:500,D07_NUM:311,W09_NUM:677,W29_NUM:256,A21_NUM:854,D27_NUM:285},
{NAME:"31~60天",A01_NUM:400,D07_NUM:677,W09_NUM:345,W29_NUM:485,A21_NUM:235,D27_NUM:853},
{NAME:"61~90天",A01_NUM:300,D07_NUM:777,W09_NUM:567,W29_NUM:256,A21_NUM:876,D27_NUM:253},
{NAME:"91~120天",A01_NUM:100,D07_NUM:300,W09_NUM:432,W29_NUM:845,A21_NUM:582,D27_NUM:458},
{NAME:"121~180天",A01_NUM:121,D07_NUM:455,W09_NUM:784,W29_NUM:256,A21_NUM:458,D27_NUM:762},
{NAME:"181~360天",A01_NUM:647,D07_NUM:666,W09_NUM:257,W29_NUM:385,A21_NUM:358,D27_NUM:965},
{NAME:"360天以上",A01_NUM:878,D07_NUM:366,W09_NUM:874,W29_NUM:415,A21_NUM:956,D27_NUM:584}
]