Skip to content

Commit

Permalink
fix: charts should show only upto the selected date
Browse files Browse the repository at this point in the history
  • Loading branch information
SayakMukhopadhyay committed Mar 27, 2023
1 parent 27acd1e commit 123dd3f
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion frontend/src/components/charts/FactionAPRStateChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default {
type: {
type: String,
default: ''
},
endDate: {
type: String,
default: ''
}
},
created() {
Expand Down Expand Up @@ -193,7 +197,7 @@ export default {
if (state) {
data[state].push({
x: tempBegin[previousStateIndex],
x2: Date.now(),
x2: this.endDate === '' ? Date.now() : new Date(this.endDate).getTime() + 86400000, // End day is set to the start of the next day
y: _sum(maxStatesConcurrent.slice(0, index)) + previousStateIndex,
system: system
})
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/charts/FactionHappinessChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default {
default() {
return null
}
},
endDate: {
type: String,
default: ''
}
},
created() {
Expand Down Expand Up @@ -97,7 +101,7 @@ export default {
if (previousHappiness === happiness[0]) {
data.push({
x: timeBegin,
x2: Date.now(),
x2: this.endDate === '' ? Date.now() : new Date(this.endDate).getTime() + 86400000, // End day is set to the start of the next day
y: index
})
}
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/charts/FactionInfluenceChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default {
default() {
return null
}
},
endToday: {
type: Boolean,
default: true
}
},
created() {
Expand Down Expand Up @@ -84,7 +88,7 @@ export default {
const latestUpdate = this.factionData.faction_presence.find((findSystem) => {
return findSystem.system_name === system
})
if (latestUpdate) {
if (latestUpdate && this.endToday) {
data.push([Date.parse(latestUpdate.updated_at), Number.parseFloat((lastElement.influence * 100).toFixed(2))])
}
series.push({
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/charts/FactionStateChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default {
default() {
return null
}
},
endDate: {
type: String,
default: ''
}
},
created() {
Expand Down Expand Up @@ -101,7 +105,7 @@ export default {
if (previousState === state[0]) {
data.push({
x: timeBegin,
x2: Date.now(),
x2: this.endDate === '' ? Date.now() : new Date(this.endDate).getTime() + 86400000, // End day is set to the start of the next day
y: index
})
}
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/charts/SystemAPRStateChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default {
type: {
type: String,
default: ''
},
endDate: {
type: String,
default: ''
}
},
created() {
Expand Down Expand Up @@ -193,7 +197,7 @@ export default {
if (state) {
data[state].push({
x: tempBegin[previousStateIndex],
x2: Date.now(),
x2: this.endDate === '' ? Date.now() : new Date(this.endDate).getTime() + 86400000, // End day is set to the start of the next day
y: _sum(maxStatesConcurrent.slice(0, index)) + previousStateIndex,
faction: faction
})
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/charts/SystemHappinessChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default {
default() {
return null
}
},
endDate: {
type: String,
default: ''
}
},
created() {
Expand Down Expand Up @@ -97,7 +101,7 @@ export default {
if (previousHappiness === happiness[0]) {
data.push({
x: timeBegin,
x2: Date.now(),
x2: this.endDate === '' ? Date.now() : new Date(this.endDate).getTime() + 86400000, // End day is set to the start of the next day
y: index
})
}
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/charts/SystemInfluenceChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default {
default() {
return null
}
},
endToday: {
type: Boolean,
default: true
}
},
created() {
Expand Down Expand Up @@ -87,7 +91,7 @@ export default {
const latestUpdate = this.systemData.factions.find((findFaction) => {
return findFaction.name === faction
})
if (latestUpdate) {
if (latestUpdate && this.endToday) {
data.push([
Date.parse(latestUpdate.faction_details.faction_presence.updated_at),
Number.parseFloat((lastRecord.influence * 100).toFixed(2))
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/charts/SystemStateChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default {
default() {
return null
}
},
endDate: {
type: String,
default: ''
}
},
created() {
Expand Down Expand Up @@ -101,7 +105,7 @@ export default {
if (previousState === state[0]) {
data.push({
x: timeBegin,
x2: Date.now(),
x2: this.endDate === '' ? Date.now() : new Date(this.endDate).getTime() + 86400000, // End day is set to the start of the next day
y: index
})
}
Expand Down
15 changes: 9 additions & 6 deletions frontend/src/components/main/factions/FactionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,37 +89,37 @@
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> Influences </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<faction-influence-chart :faction-data="faction" />
<faction-influence-chart :faction-data="faction" :end-today="changedFilterDates[1] === currentUtcDate" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> State Periods </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<faction-state-chart :faction-data="faction" />
<faction-state-chart :faction-data="faction" :end-date="endDate" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> Active State Periods </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<faction-state-apr-chart :faction-data="faction" type="active" />
<faction-state-apr-chart :faction-data="faction" type="active" :end-date="endDate" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> Pending State Periods </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<faction-state-apr-chart :faction-data="faction" type="pending" />
<faction-state-apr-chart :faction-data="faction" type="pending" :end-date="endDate" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> Recovering State Periods </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<faction-state-apr-chart :faction-data="faction" type="recovering" />
<faction-state-apr-chart :faction-data="faction" type="recovering" :end-date="endDate" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> Happiness Periods </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<faction-happiness-chart :faction-data="faction" />
<faction-happiness-chart :faction-data="faction" :end-date="endDate" />
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
Expand Down Expand Up @@ -222,6 +222,9 @@ export default {
},
datePickerDisplay() {
return `${this.filterDates[0]} - ${this.filterDates[1]}`
},
endDate() {
return this.changedFilterDates[1] !== this.currentUtcDate ? this.changedFilterDates[1] : ''
}
},
methods: {
Expand Down
15 changes: 9 additions & 6 deletions frontend/src/components/main/systems/SystemView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,37 +119,37 @@
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> Influences </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<system-influence-chart :system-data="system"></system-influence-chart>
<system-influence-chart :system-data="system" :end-today="changedFilterDates[1] === currentUtcDate" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> State Periods </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<system-state-chart :system-data="system"></system-state-chart>
<system-state-chart :system-data="system" :end-date="endDate" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> Active State Periods </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<system-state-apr-chart :system-data="system" type="active"></system-state-apr-chart>
<system-state-apr-chart :system-data="system" type="active" :end-date="endDate" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> Pending State Periods </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<system-state-apr-chart :system-data="system" type="pending"></system-state-apr-chart>
<system-state-apr-chart :system-data="system" type="pending" :end-date="endDate" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> Recovering State Periods </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<system-state-apr-chart :system-data="system" type="recovering"></system-state-apr-chart>
<system-state-apr-chart :system-data="system" type="recovering" :end-date="endDate" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header class="py-0"> Happiness Periods </v-expansion-panel-header>
<v-expansion-panel-content class="custom-padding">
<system-happiness-chart :system-data="system"></system-happiness-chart>
<system-happiness-chart :system-data="system" :end-date="endDate" />
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
Expand Down Expand Up @@ -223,6 +223,9 @@ export default {
},
datePickerDisplay() {
return `${this.filterDates[0]} - ${this.filterDates[1]}`
},
endDate() {
return this.changedFilterDates[1] !== this.currentUtcDate ? this.changedFilterDates[1] : ''
}
},
methods: {
Expand Down

0 comments on commit 123dd3f

Please sign in to comment.