График

This commit is contained in:
iriska-gri committed 2024-01-22 12:06:10 +03:00
1 parent 78b5fbe7a6
commit 59c08f1297
5 files changed
+73 -13

No files matched your search

+9
View File
@@ -13,6 +13,7 @@
"@vuelidate/validators": "^2.0.3", "@vuelidate/validators": "^2.0.3",
"axios": "^1.4.0", "axios": "^1.4.0",
"chart.js": "^4.4.1", "chart.js": "^4.4.1",
"chartjs-plugin-datalabels": "^2.2.0",
"date-fns": "^2.30.0", "date-fns": "^2.30.0",
"express-vue": "^5.12.0", "express-vue": "^5.12.0",
"moment": "^2.29.4", "moment": "^2.29.4",
@@ -7364,6 +7365,14 @@
"pnpm": ">=7" "pnpm": ">=7"
} }
}, },
"node_modules/chartjs-plugin-datalabels": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/chartjs-plugin-datalabels/-/chartjs-plugin-datalabels-2.2.0.tgz",
"integrity": "sha512-14ZU30lH7n89oq+A4bWaJPnAG8a7ZTk7dKf48YAzMvJjQtjrgg5Dpk9f+LbjCF6bpx3RAGTeL13IXpKQYyRvlw==",
"peerDependencies": {
"chart.js": ">=3.0.0"
}
},
"node_modules/chokidar": { "node_modules/chokidar": {
"version": "3.5.3", "version": "3.5.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
+1
View File
@@ -15,6 +15,7 @@
"@vuelidate/validators": "^2.0.3", "@vuelidate/validators": "^2.0.3",
"axios": "^1.4.0", "axios": "^1.4.0",
"chart.js": "^4.4.1", "chart.js": "^4.4.1",
"chartjs-plugin-datalabels": "^2.2.0",
"date-fns": "^2.30.0", "date-fns": "^2.30.0",
"express-vue": "^5.12.0", "express-vue": "^5.12.0",
"moment": "^2.29.4", "moment": "^2.29.4",
@@ -64,7 +64,7 @@ export default {
}, },
how: { how: {
type: Text, type: String,
default: '' default: ''
} }
}, },
@@ -17,8 +17,10 @@ import {
} from 'chart.js' } from 'chart.js'
import { Line } from 'vue-chartjs' import { Line } from 'vue-chartjs'
import * as chartConfig from './chartConfig.js' import * as chartConfig from './chartConfig.js'
import ChartDataLabels from 'chartjs-plugin-datalabels'
ChartJS.register( ChartJS.register(
ChartDataLabels,
CategoryScale, CategoryScale,
LinearScale, LinearScale,
PointElement, PointElement,
+60 -12
View File
@@ -139,12 +139,7 @@
<td class="text-center">{{ modelrating?val.week[0].size:val.week[1] }}</td> <td class="text-center">{{ modelrating?val.week[0].size:val.week[1] }}</td>
<td class="text-center">{{ modelrating?val.year[0].size:val.year[1] }}</td> <td class="text-center">{{ modelrating?val.year[0].size:val.year[1] }}</td>
</tr> </tr>
<tr v-for="(val, key) in countgrupp()" :key = key>
<td class="text-left">{{key}}</td>
<td class="text-center">{{ modelrating?val.now[0].size:val.now[1] }} </td>
<td class="text-center">{{ modelrating?val.week[0].size:val.week[1] }}</td>
<td class="text-center">{{ modelrating?val.year[0].size:val.year[1] }}</td>
</tr>
</tbody> </tbody>
</v-table> </v-table>
</v-col> </v-col>
@@ -219,12 +214,20 @@ setup(){
datasets: [ datasets: [
{ {
label: 'Посещений всего', label: 'Посещений всего',
backgroundColor: '#f87979', backgroundColor: 'crimson',
data: [] borderColor: 'crimson',
borderWidth: 3,
cubicInterpolationMode: 'monotone',
data: [],
hidden: true
}, },
{ {
label: 'Уникальные посещения', label: 'Уникальные посещения',
backgroundColor: '#f87975', backgroundColor: 'teal',
borderColor: 'teal',
borderWidth: 3,
cubicInterpolationMode: 'monotone',
data: [] data: []
} }
] ]
@@ -235,6 +238,52 @@ setup(){
}) })
const options = { const options = {
plugins: {
// Change options for ALL labels of THIS CHART
datalabels: {
color: 'grey',
align: 'top',
display: 'auto'
},
legend: {
labels: {
color: 'grey',
}
}},
scales: {
x: {
grid: {
color: 'white',
}
},
y: {
ticks: {
stepSize: 10
},
offset: true,
grid: {
color: 'white',
}
}
},
responsive: true, responsive: true,
maintainAspectRatio: false maintainAspectRatio: false
} }
@@ -262,16 +311,15 @@ setup(){
return acc return acc
}, {}) }, {})
for (let key in datas) { for (let key in datas) {
arrlines.value.datasets[0].data.push(datas[key].count) arrlines.value.datasets[0].data.push(datas[key].count)
arrlines.value.datasets[1].data.push(datas[key]['unic'].length) arrlines.value.datasets[1].data.push(datas[key]['unic'].length)
arrlines.value.labels.push(format1(key))
} }
arrlines.value.labels = Object.keys(datas) // arrlines.value.labels = Object.keys(datas)
} }