考勤bar图显示bug以及五大申请流程开完完成
This commit is contained in:
@@ -64,6 +64,7 @@ export default {
|
||||
this.chart.dispose();
|
||||
this.chart = null;
|
||||
},
|
||||
|
||||
methods: {
|
||||
initChart() {
|
||||
this.chart = echarts.init(this.$el, 'macarons');
|
||||
@@ -73,37 +74,41 @@ export default {
|
||||
updateData(projectList) {
|
||||
this.colors = projectList.map((item) => item.color);
|
||||
this.laborCosts = projectList.map((item) => item.laborCost);
|
||||
this.projectNames = projectList.map((item) => item.projectName.replace(/(.{5})/g, '$1\n'));
|
||||
this.projectNames = projectList.map((item) => item.projectName.replace(/(.{5})/g, '$1\n')); // 保持换行格式
|
||||
},
|
||||
setOption() {
|
||||
this.chart.setOption({
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {type: 'shadow'},
|
||||
axisPointer: { type: 'shadow' },
|
||||
formatter: (params) => { // 自定义 tooltip 格式
|
||||
const { dataIndex } = params[0]; // 获取鼠标悬停的索引
|
||||
const projectName = this.projectNames[dataIndex]; // 获取对应的项目名称
|
||||
const laborCost = this.laborCosts[dataIndex]; // 获取对应的人工成本
|
||||
return `${projectName}<br/>人工成本: ${laborCost} 人天`; // 显示项目名称和人工成本
|
||||
},
|
||||
},
|
||||
grid: {
|
||||
top: 10,
|
||||
left: '2%',
|
||||
right: '8%', // 增加右边距以适应标签
|
||||
right: '8%',
|
||||
bottom: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
xAxis: {
|
||||
max: 'dataMax',
|
||||
name: '人天', // 设置横坐标名称
|
||||
nameLocation: 'middle', // 横坐标名称的位置
|
||||
nameGap: 25, // 横坐标名称与轴线的距离
|
||||
name: '人天',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 25,
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: this.projectNames,
|
||||
inverse: true,
|
||||
animationDuration: 300,
|
||||
animationDurationUpdate: 300,
|
||||
axisLabel: {
|
||||
rotate: 45, // 设置标签旋转角度,正值表示顺时针旋转
|
||||
rotate: 45, // 设置标签旋转角度
|
||||
interval: 0, // 强制显示所有标签
|
||||
}
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
@@ -130,5 +135,6 @@ export default {
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user