Skip to content

Commit

Permalink
fix issue where selected tod charts are not updated after interval ch…
Browse files Browse the repository at this point in the history
…anged
  • Loading branch information
chienleng committed Sep 26, 2023
1 parent 3ea87dc commit 1ece451
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions components/Charts/TimeOfDay/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ export default {
this.timeDomains = timeDomains
}
},
interval(val) {
this.reassignSelectedToDs()
}
},
Expand All @@ -306,21 +310,7 @@ export default {
this.tickFormat = (d) => getTimeLabel(d)
this.secondTickFormat = () => ''
const updatedSelectedToDs = []
this.datasetsWithPositiveLoads.forEach(ds => {
const isPrice = ds.type === 'price'
const hasFuelTech = ds.fuelTech ? true : false
const find = hasFuelTech
? this.selectedToDs.find(d => d.fuelTech === ds.fuelTech)
: isPrice
? this.selectedToDs.find(d => d.type === 'price')
: this.selectedToDs.find(d => d.id === ds.id)
if (find) {
updatedSelectedToDs.push(ds)
}
})
this.setSelectedToDs(updatedSelectedToDs)
this.reassignSelectedToDs()
},
mounted() {
Expand All @@ -334,6 +324,24 @@ export default {
setSelectedToDs: 'timeOfDay/selectedToDs'
}),
reassignSelectedToDs() {
const updatedSelectedToDs = []
this.datasetsWithPositiveLoads.forEach(ds => {
const isPrice = ds.type === 'price'
const hasFuelTech = ds.fuelTech ? true : false
const find = hasFuelTech
? this.selectedToDs.find(d => d.fuelTech === ds.fuelTech)
: isPrice
? this.selectedToDs.find(d => d.type === 'price')
: this.selectedToDs.find(d => d.id === ds.id)
if (find) {
updatedSelectedToDs.push(ds)
}
})
this.setSelectedToDs(updatedSelectedToDs)
},
handleDateHover(date) {
this.hoverDate = DateDisplay.getClosestDateByInterval(
date,
Expand Down

0 comments on commit 1ece451

Please sign in to comment.