График практически готов

This commit is contained in:
iriska-gri committed 2023-12-28 17:02:02 +03:00
1 parent f7631694ba
commit cb48059255
1 file changed
+82 -84
+82 -84
View File
@@ -43,8 +43,8 @@
</v-col>
<v-col class="d-flex flex-column ">
<v-row class="flex-grow-0">
<v-col class="bg-blue">
<Line :data="data" :options="options" />
<v-col >
<line-graph :data="data" :options="options"/>
</v-col>
</v-row>
<v-row>
@@ -53,12 +53,8 @@
<v-col
lg=8
>
<!-- <v-card class="text-center" title="Рейтинг посещаемости страниц портала">
<div v-for="(val, key) in countgrupp()" :key = key>
{{key}} : {{ val.now }} {{ val.week }} {{ val.year }}
</div>
</v-card> -->
<v-card class="pt-3 text-center" title="Рейтинг посещаемости страниц портала">
<v-table class="pt-3 ma-0">
<thead>
@@ -102,75 +98,84 @@
</template>
<script>
import { ref, computed } from 'vue'
import { ref, reactive, computed } from 'vue'
import {getfromserver, pagecounter, splitname} from '@/utils/universal_functions'
import moment from 'moment'
import lineGraph from '@/components/graph/line-graph.vue'
import { axiosApiInstance } from '@/utils/axios-api'
// import {
// Chart as ChartJS,
// CategoryScale,
// LinearScale,
// PointElement,
// LineElement,
// Title,
// Tooltip,
// Legend
// } from 'chart.js'
// import { Line } from 'vue-chartjs'
// import * as chartConfig from './chartConfig.js'
// ChartJS.register(
// CategoryScale,
// LinearScale,
// PointElement,
// LineElement,
// Title,
// Tooltip,
// Legend
// )
export default {
components: { lineGraph },
// components: {
// Line
// },
setup(){
const data = {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 39, 10, 40, 39, 80, 40]
}
]
}
const visiting = ref([])
const arrlines = {}
const data = computed({
get() {
arrlines.value = {
labels: [],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 39, 10, 40, 39, 80]
},
{
label: 'Data One',
backgroundColor: '#f87979',
data: [1, 29, 10, 40, 39, 80]
}
]
}
arrforline()
return arrlines.value
}
})
const options = {
responsive: true,
maintainAspectRatio: false
}
// const data = {
// labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
// datasets: [
// {
// label: 'Data One',
// backgroundColor: '#f87979',
// data: [40, 39, 10, 40, 39, 80, 40]
// }
// ]
// }
// const options = {
// responsive: true,
// maintainAspectRatio: false
// }
const visiting = ref([])
const arrforline=() => {
console.log(visiting.value, 'visiting.value');
let un = []
visiting.value.map(e => un.push(e.author.id) )
console.log(new Set(un), 'eeeeeeeeeeeee------------------')
let datas =
visiting.value.reduce((acc, item) => {
//
if (!acc[item.visitdate]) {
acc[item.visitdate] = {unic: 0, count: 0}
}
acc[item.visitdate]['count'] += item.count
//
return acc
}, {})
console.log(datas, 'visiting.value');
// for (let x in visiting.value) {
// arrlines.value.labels.push(visiting.value[x].visitdate)
// }
}
const previousWeekStart = moment().subtract(1, 'weeks').startOf('week'); // начало предыдущей недели
const previousWeekEnd = moment().subtract(1, 'weeks').endOf('week'); // конец предыдущей недели
@@ -181,8 +186,19 @@ setup(){
}),
),
);
const visition = () => {
axiosApiInstance.get(`api/watcher/counter/`).then(result => {
visiting.value = result.data
getfromserver(`api/watcher/counter/`, visiting)
console.log( visiting.value, '--------aaaaa-------');
})}
//
pagecounter()
const countvis = () => {
@@ -242,8 +258,6 @@ setup(){
const groupedData =
visiting.value.reduce((acc, item) => {
console.log(Object.keys(acc).length, 'item------------');
if (Object.keys(acc).length <4) {
@@ -274,38 +288,22 @@ setup(){
)
// .reduce((acc, item) => ({
// ...acc, [item]: groupedData[item]
// }), {})
// Object.values(groupedData).sort(function(a, b) {
// console.log(a, b);
// return parseFloat(a.splitname(item.author)) - parseFloat(b.splitname(item.author));
// });
// groupedData.sort(function(a, b) { console.log(a,b, 'groupedData')})
// groupedData.sort((a, b) => parseFloat(b.price) - parseFloat(a.price));
console.log(sorted, 'groupedDatsorteda');
// const sortedValues = Object.values(groupedData).sort((a,b)=>b[1]-a[1])
// topUser.value = sortedValues.slice(0, 1)
// console.log(topUser.value, 'groupedData');
return sorted
}
visition()
return {
visiting,
countvis,
countgrupp,
activuser,
data,
options
// chartConfig,
// data,
// options
options
}
}