This commit is contained in:
2022-07-14 23:21:55 +02:00
parent db6b0b9fe5
commit 22dfa72d87
3 changed files with 483 additions and 457 deletions

View File

@@ -5,7 +5,7 @@
</div>
</template>
<script>
import { ref, watch, toRefs, nextTick } from 'vue'
import { ref, watch, toRefs, nextTick, onMounted } from 'vue'
import Highcharts from 'highcharts'
import 'highcharts/css/highcharts.scss'
import Loader from '@/components/Loader.vue'
@@ -37,7 +37,6 @@ export default {
try {
const [start, end] = [window.value.getStart(), window.value.getEnd()]
const sample = Math.round((end - start) / 60 / 288) || 1
console.log(import.meta.env.MODE)
const host = import.meta.env.MODE === 'development' ? 'http://localhost:3000' : ''
const fetchUrl = `${host}/type/${typeApi[type.value]}/startDate/${start}/endDate/${end}/sample/${sample}`
const response = await fetch(fetchUrl)
@@ -87,8 +86,14 @@ export default {
fetchData()
}
})
watch(data, () => {
nextTick(() => renderChart())
onMounted(() => {
watch(
data,
() => {
if (data.value.length > 0) nextTick(() => renderChart())
},
{ immediate: true }
)
})
return {
loading,