From cd682e9313e3b0c0da8188de1830526dc59594a7 Mon Sep 17 00:00:00 2001 From: gsd Date: Mon, 27 May 2024 00:26:33 +0300 Subject: [PATCH] hype minutes --- .../ActionDialogs/Tables/PlayersGraph.vue | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/components/ActionDialogs/Tables/PlayersGraph.vue b/src/components/ActionDialogs/Tables/PlayersGraph.vue index ad03875..ebdb52f 100644 --- a/src/components/ActionDialogs/Tables/PlayersGraph.vue +++ b/src/components/ActionDialogs/Tables/PlayersGraph.vue @@ -4,8 +4,21 @@

Загрузка

- +
+ + + + По дням + По минутам + + + + + + Каждые {{minutes}} минут + + @@ -16,7 +29,7 @@ - {{days}} дней + {{days}} дней Закрыть @@ -39,11 +52,14 @@ export default { loading: false, chartData: {"labels":[], "datasets":[]}, srv: "", - limit: 7 + limit: 7, + request: "api/stats/graph/peak/of/days", + request_minutes: "&minutes=5" }), components: { LineChartGenerator }, methods: { showMe(action) { + this.srv = "" this.show = action === undefined ? !this.show : action; if (action === true) { this.$API.create_server_websocket(); @@ -52,16 +68,19 @@ export default { }, onLoad() { this.loading = true; - axios.get(`api/stats/graph/peak/of/days?limit=${this.limit}&server_id=${this.srv}` + Random.getRndWebAppend()).then( + axios.get(`${this.request}?limit=${this.limit}&server_id=${this.srv}` + this.request_minutes + Random.getRndWebAppend()).then( response => { //console.log(response.data); - const data = response.data.reverse(); + const data = response.data.length > 0 && 'date' in response.data[0]?response.data.reverse():response.data; this.chartData = {"labels":[], "datasets":[]}; for (const i in data) { - this.chartData.labels.push(data[i].date); + this.chartData.labels.push("date" in data[i]?data[i].date:data[i].timestamp); } - this.chartData.datasets.push({"label":"Пик игроков", backgroundColor: '#ff0000', data: data.map(d => d['max'])}) - this.chartData.datasets.push({"label":"Среднее количество игроков", backgroundColor: '#fff900', data: data.map(d => d['avg'])}) + if (data.length > 0 && 'max' in data[0]) + this.chartData.datasets.push({"label":"Пик игроков", backgroundColor: '#ff0000', data: data.map(d => d['max'])}) + + if (data.length > 0 && 'avg' in data[0]) + this.chartData.datasets.push({"label":"Среднее количество игроков", backgroundColor: '#fff900', data: data.map(d => d['avg'])}) //console.log(this.chartData); } ).catch().finally(() => this.loading = false)