Commit fa7e04e5 authored by “yiyousong”'s avatar “yiyousong”

perf: 优化首页图表

parent eb4e46f5
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
v-model="form.businessName" v-model="form.businessName"
placeholder="请选择业务" placeholder="请选择业务"
clearable clearable
filterable
> >
<el-option <el-option
v-for="v in businessList" v-for="v in businessList"
...@@ -74,6 +75,7 @@ ...@@ -74,6 +75,7 @@
v-model="form.pjOption" v-model="form.pjOption"
placeholder="请选择评价选项" placeholder="请选择评价选项"
clearable clearable
filterable
> >
<el-option <el-option
v-for="(v, i) in pjOption" v-for="(v, i) in pjOption"
...@@ -89,6 +91,7 @@ ...@@ -89,6 +91,7 @@
v-model="form.deptName" v-model="form.deptName"
placeholder="请选择部门" placeholder="请选择部门"
clearable clearable
filterable
> >
<el-option <el-option
v-for="v in deptList" v-for="v in deptList"
...@@ -104,6 +107,7 @@ ...@@ -104,6 +107,7 @@
v-model="form.windowName" v-model="form.windowName"
placeholder="请选择窗口" placeholder="请选择窗口"
clearable clearable
filterable
> >
<el-option <el-option
v-for="v in windowList" v-for="v in windowList"
......
...@@ -194,7 +194,9 @@ export default { ...@@ -194,7 +194,9 @@ export default {
this.totalDataset.source = thirtyStatList this.totalDataset.source = thirtyStatList
.map((item) => { .map((item) => {
return { return {
name: `${item.month}-${item.day}`, name: this.$moment(
`${item.year}-${item.month}-${item.day}`
).format("YYYY-MM-DD"),
value: item.count, value: item.count,
}; };
}) })
...@@ -202,7 +204,9 @@ export default { ...@@ -202,7 +204,9 @@ export default {
this.phDataset.source = thirtyPhStatList this.phDataset.source = thirtyPhStatList
.map((item) => { .map((item) => {
return { return {
name: `${item.month}-${item.day}`, name: this.$moment(
`${item.year}-${item.month}-${item.day}`
).format("YYYY-MM-DD"),
value: item.phCount, value: item.phCount,
}; };
}) })
...@@ -210,7 +214,9 @@ export default { ...@@ -210,7 +214,9 @@ export default {
this.pjDataset.source = thirtyPjStatList this.pjDataset.source = thirtyPjStatList
.map((item) => { .map((item) => {
return { return {
name: `${item.month}-${item.day}`, name: this.$moment(
`${item.year}-${item.month}-${item.day}`
).format("YYYY-MM-DD"),
value: item.pjCount, value: item.pjCount,
}; };
}) })
......
...@@ -11,7 +11,7 @@ export default { ...@@ -11,7 +11,7 @@ export default {
}, },
endValue: { endValue: {
type: Number, type: Number,
default: 6, default: 10,
}, },
color: { color: {
type: String, type: String,
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
this.myChart && this.myChart.resize(); this.myChart && this.myChart.resize();
}, },
initChart(dataset) { initChart(dataset) {
let data = dataset.source || []; // let data = dataset.source || [];
let dom = this.$refs.MyEchart; let dom = this.$refs.MyEchart;
// 获取或者初始化 ECharts 实例 // 获取或者初始化 ECharts 实例
this.myChart = this.$echarts.getInstanceByDom(dom); this.myChart = this.$echarts.getInstanceByDom(dom);
...@@ -73,19 +73,23 @@ export default { ...@@ -73,19 +73,23 @@ export default {
}</span>${params[0].value.value}</div>`; }</span>${params[0].value.value}</div>`;
}, },
}, },
dataZoom: [ // dataZoom: [
{ // {
type: "inside", // type: "inside",
show: false, // show: false,
startValue: 0, // startValue: 0,
endValue: this.endValue - 1, // endValue: this.endValue - 1,
}, // },
], // ],
xAxis: { xAxis: {
type: "category", type: "category",
boundaryGap: false, boundaryGap: false,
axisLabel: { axisLabel: {
color: "#5A5C60", color: "#5A5C60",
formatter: (name) => {
let formatterName = name.split("-");
return `${formatterName[1]}-${formatterName[2]}`;
},
}, },
axisLine: { axisLine: {
show: true, show: true,
...@@ -180,39 +184,40 @@ export default { ...@@ -180,39 +184,40 @@ export default {
window.addEventListener("resize", this.adapterEcharts); window.addEventListener("resize", this.adapterEcharts);
// 清除现有定时器,防止多次调用 // 清除现有定时器,防止多次调用
clearInterval(this.timer); // clearInterval(this.timer);
// 定义并启动定时器 // 定义并启动定时器
this.timer = setInterval(() => { // this.timer = setInterval(() => {
if (option.dataZoom[0].endValue >= data.length - 1) { // if (option.dataZoom[0].endValue >= data.length - 1) {
option.dataZoom[0].endValue = this.endValue - 1; // option.dataZoom[0].endValue = this.endValue - 1;
option.dataZoom[0].startValue = 0; // option.dataZoom[0].startValue = 0;
} else { // } else {
option.dataZoom[0].endValue += 1; // option.dataZoom[0].endValue += 1;
option.dataZoom[0].startValue += 1; // option.dataZoom[0].startValue += 1;
} // }
this.myChart.setOption(option); // this.myChart.setOption(option);
}, 2000); // }, 2000);
// 绑定鼠标移入事件 // // 绑定鼠标移入事件
this.myChart.on("mousemove", () => { // this.myChart.on("mousemove", () => {
clearInterval(this.timer); // 清除定时器 // console.log(111);
}); // clearInterval(this.timer); // 清除定时器
// });
// 绑定鼠标移出事件 // 绑定鼠标移出事件
this.myChart.on("mouseout", () => { // this.myChart.on("mouseout", () => {
clearInterval(this.timer); // 清除定时器 // clearInterval(this.timer); // 清除定时器
this.timer = setInterval(() => { // this.timer = setInterval(() => {
if (option.dataZoom[0].endValue >= data.length - 1) { // if (option.dataZoom[0].endValue >= data.length - 1) {
option.dataZoom[0].endValue = this.endValue - 1; // option.dataZoom[0].endValue = this.endValue - 1;
option.dataZoom[0].startValue = 0; // option.dataZoom[0].startValue = 0;
} else { // } else {
option.dataZoom[0].endValue += 1; // option.dataZoom[0].endValue += 1;
option.dataZoom[0].startValue += 1; // option.dataZoom[0].startValue += 1;
} // }
this.myChart.setOption(option); // this.myChart.setOption(option);
}, 2000); // }, 2000);
}); // });
}, },
hexToRgba(hex, opacity) { hexToRgba(hex, opacity) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment