feat: npm event 支持刷新和改时间

This commit is contained in:
chenjinsong
2022-08-24 12:28:23 +08:00
parent 96901f0d56
commit c10b57c709
2 changed files with 61 additions and 26 deletions

View File

@@ -58,10 +58,19 @@ export default {
isNoData: false isNoData: false
} }
}, },
watch: {
timeFilter: {
deep: true,
handler (n) {
this.eventsByTypeData()
}
}
},
methods: { methods: {
init () { init () {
const _this = this const _this = this
const dom = document.getElementById('chart') const dom = document.getElementById('chart')
if (!this.myChart) {
this.myChart = echarts.init(dom) this.myChart = echarts.init(dom)
this.chartOption = pieChartOption3 this.chartOption = pieChartOption3
this.chartOption.series[0].data = this.chartData this.chartOption.series[0].data = this.chartData
@@ -88,8 +97,26 @@ export default {
_this.myChart.setOption(_this.chartOption) _this.myChart.setOption(_this.chartOption)
}) })
this.myChart.setOption(this.chartOption) this.myChart.setOption(this.chartOption)
} else {
this.chartOption.series[0].data = this.chartData
this.chartOption.series[0].label = {
show: true,
position: 'center',
fontFamily: 'NotoSansHans-Medium',
fontSize: 20,
fontWeight: 500,
formatter: function () {
let num = 0
_this.chartData.forEach(t => {
num += t.count
})
return num
}
}
this.myChart.setOption(this.chartOption)
}
}, },
eventsVyTypeData () { eventsByTypeData () {
const params = { const params = {
startTime: getSecond(this.timeFilter.startTime), startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime), endTime: getSecond(this.timeFilter.endTime),
@@ -136,7 +163,7 @@ export default {
}, },
mounted () { mounted () {
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.eventsVyTypeData() this.eventsByTypeData()
}, 100) }, 100)
window.addEventListener('resize', this.resize) window.addEventListener('resize', this.resize)
}, },

View File

@@ -62,6 +62,14 @@ export default {
isNoData: false isNoData: false
} }
}, },
watch: {
timeFilter: {
deep: true,
handler (n) {
this.recentEventsListData()
}
}
},
methods: { methods: {
recentEventsListData () { recentEventsListData () {
const params = { const params = {