fix: 修改 diagram tooltip的时间 未跟panel一致的问题

This commit is contained in:
zhangyu
2021-07-16 09:56:48 +08:00
parent 9ae70267bf
commit c5be6b8143
4 changed files with 34 additions and 6 deletions

View File

@@ -243,7 +243,7 @@ export default {
fromTopo: { fromTopo: {
type: Boolean, type: Boolean,
default: false default: false
}, }
}, },
computed: { computed: {
getButtonCode () { getButtonCode () {
@@ -945,7 +945,25 @@ export default {
delete option.yAxis.maxInterval delete option.yAxis.maxInterval
} }
if (this.fromTopo) { if (this.fromTopo) {
option.xAxis.minInterval = 20 * 60 * 1000 const panelTime = localStorage.getItem('panelTime') ? JSON.parse(localStorage.getItem('panelTime')) : ['', '']
if (panelTime[0]) {
const numInterval = new Date(panelTime[1]).getTime() - new Date(panelTime[0]).getTime()
console.log(numInterval)
if (numInterval >= 60 * 60 * 1000) {
option.xAxis.minInterval = 20 * 60 * 1000
} else if (numInterval >= 30 * 60 * 1000 && numInterval < 60 * 60 * 1000) {
option.xAxis.minInterval = 10 * 60 * 1000
} else if (numInterval >= 15 * 60 * 1000 && numInterval < 30 * 60 * 1000) {
option.xAxis.minInterval = 5 * 60 * 1000
} else if (numInterval >= 5 * 60 * 1000 && numInterval < 15 * 60 * 1000) {
option.xAxis.minInterval = 1 * 60 * 1000
} else {
option.xAxis.minInterval = 15 * 1000
}
} else {
option.xAxis.minInterval = 20 * 60 * 1000
}
} }
// params.series = dataArg; // params.series = dataArg;
if (chartSite === 'local') { // 本地显示 if (chartSite === 'local') { // 本地显示

View File

@@ -661,8 +661,9 @@ export default {
}) })
}) })
} }
const endTime = this.filterTime[1] const panelTime = localStorage.getItem('panelTime') ? JSON.parse(localStorage.getItem('panelTime')) : ['', '']
const startTime = this.filterTime[0] const endTime = panelTime[1] || this.filterTime[1]
const startTime = panelTime[0] || this.filterTime[0]
const step = bus.getStep(startTime, endTime) const step = bus.getStep(startTime, endTime)
data.pens && data.pens.forEach((item, index) => { data.pens && data.pens.forEach((item, index) => {
this.chartGetData.push({ id: item.id, res: [] }) this.chartGetData.push({ id: item.id, res: [] })

View File

@@ -128,8 +128,9 @@ export default {
} }
}) })
} else { } else {
const endTime = this.filter.end_time const panelTime = localStorage.getItem('panelTime') ? JSON.parse(localStorage.getItem('panelTime')) : ['', '']
const startTime = this.filter.start_time const endTime = panelTime[1] || bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss')
const startTime = panelTime[0] || bus.timeFormate(bus.getOffsetTimezoneData(-1), 'yyyy-MM-dd hh:mm:ss')
const step = bus.getStep(startTime, endTime) const step = bus.getStep(startTime, endTime)
this.$nextTick(() => { this.$nextTick(() => {
const axiosArr = chartItem.elements.map((ele) => { const axiosArr = chartItem.elements.map((ele) => {

View File

@@ -826,6 +826,13 @@ export default {
temp.search() temp.search()
}, 1000) }, 1000)
}, },
searchTime: {
immediate: true,
deep: true,
handler (n) {
localStorage.setItem('panelTime', JSON.stringify(n))
}
},
$route: { $route: {
immediate: true, immediate: true,
handler () { handler () {
@@ -852,6 +859,7 @@ export default {
if (this.scrollbarWrap) { if (this.scrollbarWrap) {
this.scrollbarWrap.removeEventListener('scroll', bus.debounce) this.scrollbarWrap.removeEventListener('scroll', bus.debounce)
}; };
localStorage.removeItem('panelTime')
} }
} }
</script> </script>