2023-01-30 12:48:37 -03:00
|
|
|
<script setup>
|
2023-01-31 23:09:14 -03:00
|
|
|
import { ref, watch, onMounted } from 'vue';
|
2023-01-30 12:48:37 -03:00
|
|
|
import { useLayout } from '@/layout/composables/layout';
|
2023-02-01 23:51:02 -03:00
|
|
|
import auth from '../utils/Auth';
|
2023-02-12 16:34:03 -03:00
|
|
|
import { useToast } from 'primevue/usetoast';
|
|
|
|
import axios from 'axios';
|
2023-01-30 12:48:37 -03:00
|
|
|
|
|
|
|
const { layoutConfig } = useLayout();
|
2023-02-12 16:34:03 -03:00
|
|
|
const toast = useToast();
|
2023-01-30 12:48:37 -03:00
|
|
|
let documentStyle = getComputedStyle(document.documentElement);
|
|
|
|
let textColor = documentStyle.getPropertyValue('--text-color');
|
|
|
|
let textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary');
|
|
|
|
let surfaceBorder = documentStyle.getPropertyValue('--surface-border');
|
2023-02-12 16:34:03 -03:00
|
|
|
const time_elapsed = ref([]);
|
2023-01-30 12:48:37 -03:00
|
|
|
|
|
|
|
const lineData = ref(null);
|
|
|
|
const lineOptions = ref(null);
|
|
|
|
|
|
|
|
const setColorOptions = () => {
|
|
|
|
documentStyle = getComputedStyle(document.documentElement);
|
|
|
|
textColor = documentStyle.getPropertyValue('--text-color');
|
|
|
|
textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary');
|
|
|
|
surfaceBorder = documentStyle.getPropertyValue('--surface-border');
|
|
|
|
};
|
2023-02-12 16:34:03 -03:00
|
|
|
async function setChart() {
|
|
|
|
try {
|
|
|
|
const response = await axios.get(`http://localhost:3001/frame?limit=5000&game_id=4`);
|
|
|
|
//console.log(response.data);
|
|
|
|
time_elapsed.value = response.data;
|
|
|
|
time_elapsed.value = time_elapsed.value.filter(x => x = 1);
|
|
|
|
console.log(time_elapsed.value);
|
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////
|
2023-01-30 12:48:37 -03:00
|
|
|
lineData.value = {
|
2023-02-12 16:34:03 -03:00
|
|
|
labels: [0],
|
2023-01-30 12:48:37 -03:00
|
|
|
datasets: [
|
|
|
|
{
|
|
|
|
label: 'First Dataset',
|
|
|
|
data: [65, 59, 80, 81, 56, 55, 40],
|
|
|
|
fill: false,
|
|
|
|
backgroundColor: documentStyle.getPropertyValue('--primary-500'),
|
|
|
|
borderColor: documentStyle.getPropertyValue('--primary-500'),
|
|
|
|
tension: 0.4
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Second Dataset',
|
|
|
|
data: [28, 48, 40, 19, 86, 27, 90],
|
|
|
|
fill: false,
|
|
|
|
backgroundColor: documentStyle.getPropertyValue('--primary-200'),
|
|
|
|
borderColor: documentStyle.getPropertyValue('--primary-200'),
|
|
|
|
tension: 0.4
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
lineOptions.value = {
|
|
|
|
plugins: {
|
|
|
|
legend: {
|
|
|
|
labels: {
|
|
|
|
fontColor: textColor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scales: {
|
|
|
|
x: {
|
|
|
|
ticks: {
|
|
|
|
color: textColorSecondary
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
color: surfaceBorder,
|
|
|
|
drawBorder: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
y: {
|
|
|
|
ticks: {
|
|
|
|
color: textColorSecondary
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
color: surfaceBorder,
|
|
|
|
drawBorder: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
watch(
|
|
|
|
layoutConfig.theme,
|
|
|
|
() => {
|
|
|
|
setColorOptions();
|
2023-02-12 16:34:03 -03:00
|
|
|
//setChart();
|
2023-01-30 12:48:37 -03:00
|
|
|
},
|
|
|
|
{ immediate: true }
|
|
|
|
);
|
|
|
|
|
2023-01-31 23:09:14 -03:00
|
|
|
onMounted(() => {
|
|
|
|
checkAuth();
|
|
|
|
})
|
|
|
|
|
|
|
|
const checkAuth = () => {
|
|
|
|
auth.checkToken(true);
|
|
|
|
};
|
2023-01-30 12:48:37 -03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="card">
|
|
|
|
<div class="grid p-fluid">
|
|
|
|
<div class="col-12 xl:col-2">
|
|
|
|
<span class="p-float-label">
|
2023-02-12 16:34:03 -03:00
|
|
|
<!-- <Dropdown id="dropdown" :options="cities" v-model="value8" optionLabel="name"></Dropdown>
|
|
|
|
<label for="dropdown">Dropdown</label> -->
|
2023-01-30 12:48:37 -03:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card">
|
|
|
|
<div class="grid p-fluid">
|
|
|
|
<div class="col-12 xl:col-6">
|
|
|
|
<div class="card">
|
|
|
|
<h5>Linear Chart</h5>
|
2023-02-12 16:34:03 -03:00
|
|
|
<button @click="setChart">hola</button>
|
2023-01-30 12:48:37 -03:00
|
|
|
<Chart type="line" :data="lineData" :options="lineOptions"></Chart>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|