From 59c08f129719838b2999ec43b25f027147563585 Mon Sep 17 00:00:00 2001 From: iriska-gri <79623434+iriska-gri@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:06:10 +0300 Subject: [PATCH] =?UTF-8?q?=D0=93=D1=80=D0=B0=D1=84=D0=B8=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/front/package-lock.json | 9 +++ src/front/package.json | 1 + .../src/components/UI/feedback/star-like.vue | 2 +- src/front/src/components/graph/line-graph.vue | 2 + src/front/src/views/AboutPortalPage.vue | 72 +++++++++++++++---- 5 files changed, 73 insertions(+), 13 deletions(-) diff --git a/src/front/package-lock.json b/src/front/package-lock.json index a4039d060..f2e596615 100644 --- a/src/front/package-lock.json +++ b/src/front/package-lock.json @@ -13,6 +13,7 @@ "@vuelidate/validators": "^2.0.3", "axios": "^1.4.0", "chart.js": "^4.4.1", + "chartjs-plugin-datalabels": "^2.2.0", "date-fns": "^2.30.0", "express-vue": "^5.12.0", "moment": "^2.29.4", @@ -7364,6 +7365,14 @@ "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": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", diff --git a/src/front/package.json b/src/front/package.json index 25b668fec..c453afd0f 100644 --- a/src/front/package.json +++ b/src/front/package.json @@ -15,6 +15,7 @@ "@vuelidate/validators": "^2.0.3", "axios": "^1.4.0", "chart.js": "^4.4.1", + "chartjs-plugin-datalabels": "^2.2.0", "date-fns": "^2.30.0", "express-vue": "^5.12.0", "moment": "^2.29.4", diff --git a/src/front/src/components/UI/feedback/star-like.vue b/src/front/src/components/UI/feedback/star-like.vue index ddc3a5a0b..b8e9c9906 100644 --- a/src/front/src/components/UI/feedback/star-like.vue +++ b/src/front/src/components/UI/feedback/star-like.vue @@ -64,7 +64,7 @@ export default { }, how: { - type: Text, + type: String, default: '' } }, diff --git a/src/front/src/components/graph/line-graph.vue b/src/front/src/components/graph/line-graph.vue index 3e2c3b178..9990d7cd4 100644 --- a/src/front/src/components/graph/line-graph.vue +++ b/src/front/src/components/graph/line-graph.vue @@ -17,8 +17,10 @@ import { } from 'chart.js' import { Line } from 'vue-chartjs' import * as chartConfig from './chartConfig.js' +import ChartDataLabels from 'chartjs-plugin-datalabels' ChartJS.register( + ChartDataLabels, CategoryScale, LinearScale, PointElement, diff --git a/src/front/src/views/AboutPortalPage.vue b/src/front/src/views/AboutPortalPage.vue index 4646ee8e1..b0160b58b 100644 --- a/src/front/src/views/AboutPortalPage.vue +++ b/src/front/src/views/AboutPortalPage.vue @@ -139,12 +139,7 @@ {{ modelrating?val.week[0].size:val.week[1] }} {{ modelrating?val.year[0].size:val.year[1] }} - - {{key}} - {{ modelrating?val.now[0].size:val.now[1] }} - {{ modelrating?val.week[0].size:val.week[1] }} - {{ modelrating?val.year[0].size:val.year[1] }} - + @@ -219,12 +214,20 @@ setup(){ datasets: [ { label: 'Посещений всего', - backgroundColor: '#f87979', - data: [] + backgroundColor: 'crimson', + borderColor: 'crimson', + borderWidth: 3, + cubicInterpolationMode: 'monotone', + data: [], + hidden: true + }, { label: 'Уникальные посещения', - backgroundColor: '#f87975', + backgroundColor: 'teal', + borderColor: 'teal', + borderWidth: 3, + cubicInterpolationMode: 'monotone', data: [] } ] @@ -235,6 +238,52 @@ setup(){ }) 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, maintainAspectRatio: false } @@ -262,16 +311,15 @@ setup(){ return acc }, {}) for (let key in datas) { - - arrlines.value.datasets[0].data.push(datas[key].count) 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) }