Skip to content

Commit

Permalink
clean up and invert load values
Browse files Browse the repository at this point in the history
  • Loading branch information
chienleng committed Sep 7, 2023
1 parent 490dea2 commit 453c514
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions components/Energy/TimeOfDaySection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ export default {
data() {
return {
selectedDomain: null,
todayKey: null,
hoverDate: null,
highlightFuelTech: null,
Expand Down Expand Up @@ -234,24 +233,26 @@ export default {
},
timeDomains() {
const keys = Object.keys(this.dataset[0]).filter((key) => {
return key !== 'x' && key !== 'date' && key !== 'time'
})
const getLabel = (key) => {
if (key === '_average') return 'Average'
return key
}
const bucket = this.getDataBucket()
const keys = Object.keys(bucket[0]).filter((key) => {
return key !== 'x' && key !== 'date' && key !== 'time'
})
const datasetKeys = keys.map((key) => {
return {
domain: key,
id: key,
label: getLabel(key)
const getLabel = (key) => {
if (key === '_average') return 'Average'
return key
}
})
return datasetKeys
const datasetKeys = keys.map((key) => {
return {
domain: key,
id: key,
label: getLabel(key)
}
})
return datasetKeys
},
filteredTimeDomains() {
Expand All @@ -260,11 +261,11 @@ export default {
datasets() {
const datasets = this.allDomains.map(domain => {
const data = this.getTimeBucket(domain.id)
const data = this.getDataBucket(domain.id, domain.category)
return {
id: domain.id,
label: domain.label,
data: this.getTimeBucket(domain.id),
data,
yMin: this.getYMin(data),
yMax: this.getYMax(data)
}
Expand Down Expand Up @@ -334,10 +335,6 @@ export default {
return max
},
dataset() {
return this.getTimeBucket(this.selectedDomain)
},
tooltipValues() {
if (this.highlightFuelTech && this.hoverValues) {
const ft = this.currentDomainPowerEnergy.find(d => d.id === this.highlightFuelTech)
Expand Down Expand Up @@ -417,13 +414,12 @@ export default {
return max
},
getTimeBucket(domain) {
// console.log('currentDataset', this.currentDataset)
getDataBucket(domain, category) {
const dataset = this.currentDataset.map((d) => {
return {
date: d.date,
time: d.time,
value: d[domain],
value: category === 'load' ? -d[domain] : d[domain], // invert load values so it shows up as positive values
}
})
Expand Down

0 comments on commit 453c514

Please sign in to comment.