Верстка

This commit is contained in:
iriska-gri committed 2024-01-31 13:00:21 +03:00
1 parent 61bd1cd362
commit 0503cd6cf7
3 files changed
+80 -57

No files matched your search

@@ -1,9 +1,6 @@
<template>
<v-card
class="d-flex flex-column text-center"
height="200px"
>
<line-graph :data="data" :options="options"/>
<v-card class="h-100">
<line-graph :data="data" :options="options"/>
</v-card>
</template>
@@ -18,9 +15,9 @@ export default {
},
props: {
visiting: {
type: Array,
default: () => []
dataLineChart: {
type: Object,
default: () => {}
}
},
@@ -34,7 +31,7 @@ export default {
labels: [],
datasets: [
{
label: 'Посещений всего',
label: 'Открыто страниц',
backgroundColor: 'crimson',
borderColor: 'crimson',
borderWidth: 3,
@@ -45,7 +42,7 @@ export default {
},
{
label: 'Уникальные посещения',
label: 'Активные пользователи',
backgroundColor: 'teal',
borderColor: 'teal',
borderWidth: 3,
@@ -112,26 +109,26 @@ export default {
}
const arrforline=() => {
let datas =
props.visiting.reduce((acc, item) => {
if (!acc[item.visitdate]) {
acc[item.visitdate] = {unic: [], count: 0}
}
acc[item.visitdate]['count'] += item.count
if (!acc[item.visitdate]['unic'].includes(splitname(item.author)))
{
acc[item.visitdate]['unic'].push(splitname(item.author))
// let datas =
// props.visiting.reduce((acc, item) => {
// if (!acc[item.visitdate]) {
// acc[item.visitdate] = {unic: [], count: 0}
// }
// acc[item.visitdate]['count'] += item.count
// if (!acc[item.visitdate]['unic'].includes(splitname(item.author)))
// {
// acc[item.visitdate]['unic'].push(splitname(item.author))
}
return acc
}, {})
// }
// return acc
// }, {})
Object.entries(datas).forEach(e => {
Object.entries(props.dataLineChart).forEach(e => {
const [key, value] = e
arrlines.value.datasets[0].data.push(datas[key].count)
arrlines.value.datasets[1].data.push(datas[key]['unic'].length)
arrlines.value.datasets[0].data.push(value.count)
arrlines.value.datasets[1].data.push(value.unic.length)
arrlines.value.labels.push(format1(key))
arrlines.value.datasets[1].customlabel.push(datas[key].unic)
arrlines.value.datasets[1].customlabel.push(props.dataLineChart[key].unic)
})
}
@@ -145,4 +142,7 @@ export default {
<style>
canvas {
flex: 1!important
}
</style>
+2 -2
View File
@@ -46,12 +46,12 @@
<script>
import { ref } from 'vue'
import {format1, format2} from '@/utils/universal_functions'
import {format1} from '@/utils/universal_functions'
export default {
props: {
datedefault: {
type: String,
type: Date,
default: ''
}
},
+52 -29
View File
@@ -1,16 +1,39 @@
<template>
<v-row no-gutters class="flex-column">
<toolbar-filter
@returnend="returnend"
/>
<v-col lg=1 class="w100 bg-red">
<toolbar-filter/>
<v-col lg=2 class="bg-yellow w100">
<v-row no-gutters class=" h-100">
<v-col lg=3 class="bg-blue">1</v-col>
<v-col class="bg-yellow ">
<line-chart :dataLineChart="dataLineChart"/>
</v-col>
</v-row>
<!-- <v-row class="flex-grow-0">
<v-col lg=3>
visiting- (все данные)
</v-col> -->
<!-- <v-col > <my-helper :pretext="visiting"/> </v-col> -->
<!-- </v-row> -->
<!-- -->
</v-col>
<v-col class="bg-green">2</v-col>
<v-col lg=6 class="bg-green w100">3</v-col>
<v-col class="bg-red w100">4</v-col>
<!-- <v-row class="flex-grow-0">
<v-col lg=3>
dataLineChart (данные для графика)-
</v-col>
<v-col> <my-helper :pretext="dataLineChart"/> </v-col>
</v-row> -->
<!-- <v-col class="d-flex flex-column gap">
{{visitionreduce()}}
<v-row no-gutters class="flex-grow-0">
<v-col>
<v-toolbar
@@ -154,12 +177,14 @@
</template>
<script>
import { ref, computed } from 'vue'
import { ref, watch } from 'vue'
import {pagecounter, splitname, format1, format2} from '@/utils/universal_functions'
import moment from 'moment'
import { axiosApiInstance } from '@/utils/axios-api'
import { usePortalFilterStore } from '@/store/AboutPortalFilter'
import Feedmodul from '@/components/UI/aboutportal/feedmodul.vue'
import DateSelect from '@/components/UI/date-select.vue'
import TopUser from '@/components/UI/aboutportal/top-user.vue'
@@ -180,11 +205,10 @@ export default {
setup(){
const filterStore = usePortalFilterStore()
const visiting = ref([])
const feedback = ref([])
const staff = ref(0)
const startdate =ref(format2(new Date(new Date().getFullYear(), 0, 1)))
const enddate =ref(format2(new Date()))
const dataLineChart = ref({})
pagecounter()
@@ -194,40 +218,39 @@ setup(){
staff.value = result.data.staff
visiting.value = result.data.result
feedback.value = result.data.feedback
visitionreduce()
})}
visition()
const returnstart = (dates) => {
startdate.value = dates
visition()
}
const returnend = (dates) => {
enddate.value = dates
visition()
}
const visitionreduce = () => {
let lineCharts = {}
const groupedData = visiting.value.reduce((acc, item) => {
// Данные для графика по фильтру
if (item.visitdate >= format2(startdate.value) && item.visitdate <= format2(enddate.value)){
if (item.visitdate >= format2(filterStore.date_period.startdate) && item.visitdate <= format2(filterStore.date_period.enddate)){
if (!lineCharts[item.visitdate]) {
lineCharts[item.visitdate] = {count: 0, unic: new Set()}
lineCharts[item.visitdate] = {count: 0, unic: []}
}
lineCharts[item.visitdate]['count'] +=item.count
lineCharts[item.visitdate]['unic'].add(splitname(item.author))
if (!lineCharts[item.visitdate]['unic'].includes(splitname(item.author)))
{
lineCharts[item.visitdate]['unic'].push(splitname(item.author))
}
}
dataLineChart.value = lineCharts
return acc
}, {})
watch(()=>filterStore.date_period,(newValue,oldValue)=>{
if(newValue){
visitionreduce()
}
}, {deep:true})
return groupedData
@@ -235,14 +258,14 @@ setup(){
return {
visiting,
enddate,
startdate,
returnstart,
returnend,
visitionreduce,
dataLineChart
// countgrupp,