578 lines
19 KiB
JavaScript
578 lines
19 KiB
JavaScript
let myChart = echarts.init(document.getElementById('pro-risk'));
|
||
let myChart2 = echarts.init(document.getElementById('pro-progress-echarts'));
|
||
let myChart3 = echarts.init(document.getElementById('pro-cost'));
|
||
|
||
/* 项目风险 */
|
||
function initEchartsOne() {
|
||
let fontSize = '14', fontFamily = 'Alibaba PuHuiTi R', fontColor = '#fff';
|
||
let xLabel = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'];
|
||
let dataValue = [20, 30, 40, 35, 34, 15, 56, 15, 12, 25, 34, 42];
|
||
let dataValue1 = [40, 35, 34, 15, 56, 15, 12, 25, 34, 42, 20, 30,];
|
||
const tooltip = {
|
||
show: true,
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'shadow'
|
||
},
|
||
backgroundColor: 'rgba(75, 79, 82, 0.80)', //设置背景颜色
|
||
textStyle: {
|
||
color: fontColor,
|
||
fontFamily: fontFamily
|
||
},
|
||
borderColor: "rgba(255,255,255, .5)",
|
||
};
|
||
let option = {
|
||
backgroundColor: 'transparent',
|
||
tooltip,
|
||
legend: {
|
||
show: true,
|
||
top: '15%',
|
||
right: '2%',
|
||
itemWidth: 30, // 图例标记的图形宽度。
|
||
// itemGap: 20, // 图例每项之间的间隔。
|
||
itemHeight: 10, // 图例标记的图形高度。
|
||
textStyle: {
|
||
color: '#fff',
|
||
fontSize: 14,
|
||
padding: [0, 8, 0, 8]
|
||
}
|
||
},
|
||
grid: {
|
||
top: '25%',
|
||
left: '5%',
|
||
right: '5%',
|
||
bottom: '15%',
|
||
},
|
||
xAxis: [
|
||
{
|
||
type: 'category',
|
||
boundaryGap: true,
|
||
axisLine: {
|
||
//坐标轴轴线相关设置。数学上的x轴
|
||
show: true,
|
||
lineStyle: {
|
||
color: '#5A6E71',
|
||
},
|
||
},
|
||
axisLabel: {
|
||
//坐标轴刻度标签的相关设置
|
||
textStyle: {
|
||
color: fontColor,
|
||
fontSize: fontSize,
|
||
fontFamily: fontFamily
|
||
},
|
||
},
|
||
splitLine: {
|
||
show: false,
|
||
lineStyle: {
|
||
color: '#233653',
|
||
},
|
||
},
|
||
axisTick: {
|
||
show: false,
|
||
},
|
||
data: xLabel,
|
||
},
|
||
],
|
||
yAxis: [
|
||
{
|
||
name: "",
|
||
nameTextStyle: {
|
||
color: fontColor,
|
||
fontSize: fontSize,
|
||
padding: [0, 60, 0, 0],
|
||
fontFamily: fontFamily
|
||
},
|
||
// minInterval: 1,
|
||
type: 'value',
|
||
splitLine: {
|
||
show: true,
|
||
lineStyle: {
|
||
color: '#25393B',
|
||
type: 'dashed'
|
||
},
|
||
},
|
||
axisLine: {
|
||
show: false,
|
||
lineStyle: {
|
||
color: '#008de7',
|
||
},
|
||
},
|
||
axisLabel: {
|
||
show: true,
|
||
textStyle: {
|
||
color: fontColor,
|
||
fontSize: fontSize,
|
||
fontFamily: fontFamily
|
||
}
|
||
},
|
||
axisTick: {
|
||
show: false,
|
||
},
|
||
},
|
||
],
|
||
series: [
|
||
{
|
||
name: '周计划数',
|
||
type: 'line',
|
||
symbol: 'circle', // 默认是空心圆(中间是白色的),改成实心圆
|
||
smooth: true,
|
||
lineStyle: {
|
||
normal: {
|
||
width: 3,
|
||
color: '#1ED6FF', // 线条颜色
|
||
},
|
||
},
|
||
itemStyle: {
|
||
normal: {
|
||
color: '#1ED6FF',//拐点颜色
|
||
// borderColor: '#fff600',//拐点边框颜色
|
||
// borderWidth: 13//拐点边框大小
|
||
label: {
|
||
show: true, //开启显示
|
||
color: fontColor,
|
||
fontFamily: fontFamily,
|
||
position: 'top', //在上方显示
|
||
formatter: function (res) {
|
||
if (res.value) {
|
||
return res.value
|
||
} else {
|
||
return 0
|
||
}
|
||
},
|
||
},
|
||
},
|
||
|
||
},
|
||
symbolSize: 8, //设定实心点的大小
|
||
areaStyle: {
|
||
normal: {
|
||
//线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
|
||
color: new echarts.graphic.LinearGradient(
|
||
0,
|
||
0,
|
||
0,
|
||
1,
|
||
[
|
||
{
|
||
offset: 0,
|
||
color: '#1ED6FF30',
|
||
},
|
||
{
|
||
offset: 0.6,
|
||
color: '#1ED6FF20',
|
||
},
|
||
{
|
||
offset: 1,
|
||
color: '#1ED6FF10',
|
||
},
|
||
],
|
||
false
|
||
),
|
||
},
|
||
},
|
||
data: dataValue,
|
||
},
|
||
{
|
||
name: '风险数',
|
||
type: 'line',
|
||
symbol: 'circle', // 默认是空心圆(中间是白色的),改成实心圆
|
||
smooth: true,
|
||
lineStyle: {
|
||
normal: {
|
||
width: 3,
|
||
color: '#FE533C', // 线条颜色
|
||
},
|
||
},
|
||
itemStyle: {
|
||
normal: {
|
||
color: '#FE533C',//拐点颜色
|
||
// borderColor: '#fff600',//拐点边框颜色
|
||
// borderWidth: 13//拐点边框大小
|
||
label: {
|
||
show: true, //开启显示
|
||
color: fontColor,
|
||
fontFamily: fontFamily,
|
||
position: 'top', //在上方显示
|
||
formatter: function (res) {
|
||
if (res.value) {
|
||
return res.value
|
||
} else {
|
||
return 0
|
||
}
|
||
},
|
||
},
|
||
},
|
||
|
||
},
|
||
symbolSize: 8, //设定实心点的大小
|
||
areaStyle: {
|
||
normal: {
|
||
//线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
|
||
color: new echarts.graphic.LinearGradient(
|
||
0,
|
||
0,
|
||
0,
|
||
1,
|
||
[
|
||
{
|
||
offset: 0,
|
||
color: '#FE533C30',
|
||
},
|
||
{
|
||
offset: 0.6,
|
||
color: '#FE533C20',
|
||
},
|
||
{
|
||
offset: 1,
|
||
color: '#ffba0010',
|
||
},
|
||
],
|
||
false
|
||
),
|
||
},
|
||
},
|
||
data: dataValue1,
|
||
}
|
||
]
|
||
}
|
||
myChart.setOption(option, true);
|
||
window.addEventListener("resize", function () {
|
||
myChart.resize();
|
||
});
|
||
}
|
||
|
||
/* 计划进度 */
|
||
function initEchartsTwo() {
|
||
let fontSize = '14', fontFamily = 'Alibaba PuHuiTi R', fontColor = '#fff';
|
||
let kg = 0.3
|
||
// 计划进度、实际进度
|
||
let total = 20;
|
||
let total_add = 30;
|
||
// 进度条占比
|
||
let ljdata = total;
|
||
let newdata = total_add - total > 0 ? total_add - total : 0;;
|
||
let max = 100;
|
||
var option = {
|
||
backgroundColor: 'transparent',
|
||
yAxis: {
|
||
type: 'category',
|
||
axisLine: {
|
||
show: false, //坐标线
|
||
},
|
||
axisTick: {
|
||
show: false, //小横线
|
||
},
|
||
axisLabel: {
|
||
show: false, //小横线
|
||
color: '#999', //坐标轴字颜色
|
||
},
|
||
},
|
||
|
||
xAxis: {
|
||
show: false,
|
||
max: max,
|
||
},
|
||
grid: {
|
||
top: '20',
|
||
right: '10',
|
||
left: '20',
|
||
bottom: '0', //图表尺寸大小
|
||
},
|
||
animationDuration: 2000,
|
||
series: [
|
||
// 框
|
||
{
|
||
name: '框',
|
||
type: 'bar',
|
||
barGap: '-100%',
|
||
data: [max],
|
||
barWidth: '30px',
|
||
itemStyle: {
|
||
normal: {
|
||
color: 'none',
|
||
borderColor: '#06DDDBFF',
|
||
borderWidth: 1,
|
||
barBorderRadius: 0,
|
||
},
|
||
},
|
||
|
||
},
|
||
// 间隔
|
||
{
|
||
type: 'bar',
|
||
barWidth: '25px',
|
||
barGap: '-92%',
|
||
stack: 'total',
|
||
showBackground: false,
|
||
backgroundStyle: {
|
||
color: 'transparent',
|
||
},
|
||
label: {
|
||
normal: {
|
||
show: false,
|
||
},
|
||
},
|
||
itemStyle: {
|
||
normal: {
|
||
color: 'transparent', //每个数据的颜色
|
||
},
|
||
},
|
||
data: [kg],
|
||
},
|
||
{
|
||
type: 'bar',
|
||
barWidth: '25px',
|
||
barGap: '-92%',
|
||
stack: 'total',
|
||
showBackground: false,
|
||
backgroundStyle: {
|
||
color: 'transparent',
|
||
},
|
||
label: {
|
||
// normal: {
|
||
// show: true,
|
||
// position: 'insideBottomRight',
|
||
// formatter: (params) => {
|
||
// return total
|
||
// },
|
||
// distance: 0,
|
||
// offset: [-20, -5],
|
||
// color: '#fff',
|
||
// fontSize: 12,
|
||
// },
|
||
normal: {
|
||
show: true,
|
||
position: 'insideBottomRight',
|
||
formatter: '计划进度' + ' ' + `${total}` + '%',
|
||
distance: 0,
|
||
offset: [50, 35],
|
||
color: fontColor,
|
||
fontSize: fontSize,
|
||
padding: [12, 12, 12, 12],
|
||
},
|
||
},
|
||
itemStyle: {
|
||
color: {
|
||
x: 1,
|
||
y: 0,
|
||
x2: 0,
|
||
y2: 0,
|
||
colorStops: [{
|
||
offset: 0,
|
||
color: '#03FDBAFF' // 0% 处的颜色
|
||
}, {
|
||
offset: 1,
|
||
color: '#A8FBE7FF' // 100% 处的颜色
|
||
}],
|
||
},
|
||
},
|
||
data: [ljdata],
|
||
},
|
||
{
|
||
type: 'bar',
|
||
barWidth: '25px',
|
||
stack: 'total',
|
||
silent: true,
|
||
showBackground: false,
|
||
backgroundStyle: {
|
||
color: 'transparent',
|
||
},
|
||
label: {
|
||
normal: {
|
||
show: true,
|
||
position: 'insideBottomRight',
|
||
formatter: '实际进度' + ' ' + `${total_add}` + '%',
|
||
distance: 0,
|
||
offset: [50, -21],
|
||
color: fontColor,
|
||
fontSize: fontSize,
|
||
padding: [12, 12, 12, 12],
|
||
},
|
||
},
|
||
itemStyle: {
|
||
color: {
|
||
x: 1,
|
||
y: 0,
|
||
x2: 0,
|
||
y2: 0,
|
||
colorStops: [{
|
||
offset: 0,
|
||
color: '#FD9B02FF' // 0% 处的颜色
|
||
}, {
|
||
offset: 1,
|
||
color: '#FFE0B0FF' // 100% 处的颜色
|
||
}],
|
||
},
|
||
},
|
||
data: [newdata],
|
||
},
|
||
{
|
||
type: 'bar',
|
||
barWidth: '25px',
|
||
stack: 'total',
|
||
silent: true,
|
||
showBackground: false,
|
||
backgroundStyle: {
|
||
color: 'transparent',
|
||
},
|
||
label: {
|
||
// normal: {
|
||
// show: true,
|
||
// position: 'insideBottomRight',
|
||
// formatter: (params) => {
|
||
// return total_add
|
||
// },
|
||
// distance: 0,
|
||
// offset: [-20, -5],
|
||
// color: '#fff',
|
||
// fontSize: 12,
|
||
// },
|
||
},
|
||
itemStyle: {
|
||
normal: {
|
||
color: 'transparent', //每个数据的颜色
|
||
},
|
||
},
|
||
data: [kg],
|
||
},
|
||
],
|
||
};
|
||
|
||
myChart2.setOption(option, true);
|
||
window.addEventListener("resize", function () {
|
||
myChart2.resize();
|
||
});
|
||
}
|
||
|
||
/* 项目成本 */
|
||
function initEchartsThree() {
|
||
let fontSize = '14', fontFamily = 'Alibaba PuHuiTi R', fontColor = '#fff';
|
||
const tooltip = {
|
||
show: true,
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'shadow'
|
||
},
|
||
backgroundColor: 'rgba(75, 79, 82, 0.80)', //设置背景颜色
|
||
textStyle: {
|
||
color: fontColor,
|
||
fontFamily: fontFamily
|
||
},
|
||
borderColor: "rgba(255,255,255, .5)",
|
||
};
|
||
option = {
|
||
backgroundColor: 'transparent',
|
||
tooltip,
|
||
grid: {
|
||
left: '5%',
|
||
right: '6%',
|
||
bottom: '15%',
|
||
top: '25%',
|
||
},
|
||
xAxis: {
|
||
type: 'category',
|
||
data: ['黄家村', '曹家村', '吕家村', '大草坝村', '庙坡村', '廉家庄村', '莲花池村', '小西关村', '杜家漕村', '栗子园村', '翟家寺村'],
|
||
|
||
axisLine: {
|
||
show: true,
|
||
lineStyle: {
|
||
color: '#FFFFFF66',
|
||
// width: 1
|
||
},
|
||
},
|
||
axisLabel: {
|
||
interval: 0,
|
||
// rotate: 50,
|
||
textStyle: {
|
||
color: fontColor,
|
||
fontSize: fontSize,
|
||
fontFamily: fontFamily
|
||
},
|
||
},
|
||
axisTick: {
|
||
show: false,
|
||
},
|
||
},
|
||
yAxis: {
|
||
type: 'value',
|
||
// min: 0,
|
||
// max: 140,
|
||
splitLine: { //分割线配置
|
||
lineStyle: {
|
||
color: "#25393B",
|
||
// type: 'dashed'
|
||
}
|
||
},
|
||
axisLine: {
|
||
show: false,
|
||
lineStyle: {
|
||
color: '#758FA6'
|
||
}
|
||
},
|
||
axisTick: {
|
||
show: false,
|
||
},
|
||
axisLabel: {
|
||
textStyle: {
|
||
color: fontColor,
|
||
fontSize: fontSize,
|
||
fontFamily: fontFamily
|
||
},
|
||
},
|
||
},
|
||
series: [{
|
||
barWidth: 14,
|
||
data: ['2', '3', '1', '1', '2', '2', '2', '6', '5', '3', '2'],
|
||
type: 'bar',
|
||
itemStyle: {
|
||
normal: {
|
||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
||
offset: 0,
|
||
color: '#C9FFFAFF' // 0% 处的颜色
|
||
}, {
|
||
offset: 1,
|
||
color: '#0AFFBFFF' // 100% 处的颜色
|
||
}], false),
|
||
// barBorderRadius: [30, 30, 30, 30],
|
||
shadowColor: 'rgba(0,160,221,1)',
|
||
shadowBlur: 4,
|
||
label: {
|
||
show: true, //开启显示
|
||
color: fontColor,
|
||
fontFamily: fontFamily,
|
||
position: 'top', //在上方显示
|
||
formatter: function (res) {
|
||
if (res.value) {
|
||
return res.value
|
||
} else {
|
||
return 0
|
||
}
|
||
},
|
||
},
|
||
}
|
||
},
|
||
markLine: {
|
||
symbol: 'none',
|
||
label: {
|
||
position: "middle",
|
||
formatter: '{b}:{c}',
|
||
color: '#FF8845FF',
|
||
fontSize: fontSize
|
||
},
|
||
data: [{
|
||
silent: true,
|
||
name: "阈值",
|
||
yAxis: 5,//res.targetTwo,
|
||
lineStyle: {
|
||
color: "#FF8845FF"
|
||
},
|
||
}]
|
||
}
|
||
}]
|
||
};
|
||
myChart3.setOption(option, true);
|
||
window.addEventListener("resize", function () {
|
||
myChart3.resize();
|
||
});
|
||
} |