display chart only when simulations finished
This commit is contained in:
@@ -1,53 +1,61 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useSimulationStore } from '@/modules/simulation/simulation-store'
|
import { useSimulationStore } from '@/modules/simulation/simulation-store'
|
||||||
|
import { popNElement } from '@/utils'
|
||||||
import chartXkcd from 'chart.xkcd'
|
import chartXkcd from 'chart.xkcd'
|
||||||
import { onMounted } from 'vue'
|
import { onMounted, ref, watch } from 'vue'
|
||||||
|
|
||||||
const simulationStore = useSimulationStore()
|
const simulationStore = useSimulationStore()
|
||||||
|
const SAMPLE = 15
|
||||||
|
const isChartInit = ref(false)
|
||||||
|
|
||||||
const reloadGraph = () => {
|
const reloadGraph = () => {
|
||||||
if (
|
if (simulationStore.dashboards.length === 0) {
|
||||||
simulationStore.dashboards.length === 0 ||
|
|
||||||
simulationStore.dashboards.length > 15
|
|
||||||
) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
isChartInit.value = true
|
||||||
|
|
||||||
const svg = document.querySelector('.chart')
|
const samples = popNElement(
|
||||||
|
[...simulationStore.dashboards],
|
||||||
|
SAMPLE
|
||||||
|
).toReversed()
|
||||||
|
|
||||||
|
const svg = document.querySelector('svg.chart')
|
||||||
const config = {
|
const config = {
|
||||||
title: 'Features done per day',
|
title: `${SAMPLE} simulations`,
|
||||||
xLabel: 'days',
|
xLabel: 'days',
|
||||||
yLabel: 'features done',
|
yLabel: 'features done',
|
||||||
data: {
|
data: {
|
||||||
labels: Array.from(
|
labels: Array.from(
|
||||||
{
|
{
|
||||||
length: Math.max(
|
length: Math.max(
|
||||||
...simulationStore.dashboards.map(
|
...samples.map((dashboard) => dashboard.meta.totalDays)
|
||||||
(dashboard) => dashboard.meta.totalDays
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
(_, index) => index + 1
|
(_, index) => index + 1
|
||||||
),
|
),
|
||||||
datasets: simulationStore.dashboards.map((dashboard, index) => ({
|
datasets: samples.map((dashboard, index) => ({
|
||||||
label: `${dashboard.analysis.strategy} ${index + 1}`,
|
label: `${dashboard.analysis.strategy} ${index + 1}`,
|
||||||
data: dashboard.meta.featuresDonePerDay
|
data: dashboard.meta.featuresDonePerDay
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
showLegend: false
|
showLegend: false,
|
||||||
|
fontFamily: 'Noto Serif'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new chartXkcd.Line(svg, config)
|
new chartXkcd.Line(svg, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// watch(simulationStore.dashboards, reloadGraph)
|
watch(() => simulationStore.hasSimulationFinished, reloadGraph)
|
||||||
onMounted(reloadGraph)
|
onMounted(reloadGraph)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="simulation-chart">
|
<div class="simulation-chart">
|
||||||
<svg class="chart"></svg>
|
<svg class="chart"></svg>
|
||||||
|
<div v-if="!isChartInit" class="chart no-init">
|
||||||
|
Chart appears once every simulations resume
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -56,4 +64,12 @@ onMounted(reloadGraph)
|
|||||||
width: 80vw;
|
width: 80vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.no-init {
|
||||||
|
position: relative;
|
||||||
|
top: -100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { Strategy } from '@/modules/lean/strategy'
|
import { Strategy } from '@/modules/lean/strategy'
|
||||||
import { useSimulationStore } from '@/modules/simulation/simulation-store'
|
import { useSimulationStore } from '@/modules/simulation/simulation-store'
|
||||||
const simulationStore = useSimulationStore()
|
const simulationStore = useSimulationStore()
|
||||||
const NUMBER_OF_SIMULATION = 400
|
const NUMBER_OF_SIMULATION = 200
|
||||||
|
|
||||||
const strategies: Strategy[] = ['push', 'pull', 'push-dps', 'pull-dps']
|
const strategies: Strategy[] = ['push', 'pull', 'push-dps', 'pull-dps']
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,9 @@ export const useSimulationStore = defineStore('dashboard', {
|
|||||||
getRound(
|
getRound(
|
||||||
state.mean[strategy].totalDaysSum,
|
state.mean[strategy].totalDaysSum,
|
||||||
state.mean[strategy].simulations
|
state.mean[strategy].simulations
|
||||||
)
|
),
|
||||||
|
hasSimulationFinished: (state) =>
|
||||||
|
state.requestedSimulation > 0 &&
|
||||||
|
state.requestedSimulation === state.simulationsDone
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user