From 4462fe0a4d36febb3680f67b9ae870e98f127a9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mar=C3=ADa?=
Date: Fri, 22 Aug 2025 16:09:27 +0200
Subject: [PATCH] echarts added to estadisticas page
---
components/LineChart.vue | 117 +++++++++++++++++++++++++++++++++++
components/TrendStats.vue | 102 ++++++++++++++++++++----------
package-lock.json | 32 ++++++++++
package.json | 1 +
pages/admin/estadisticas.vue | 10 +--
stores/auth.ts | 2 +-
6 files changed, 227 insertions(+), 37 deletions(-)
create mode 100644 components/LineChart.vue
diff --git a/components/LineChart.vue b/components/LineChart.vue
new file mode 100644
index 0000000..5969567
--- /dev/null
+++ b/components/LineChart.vue
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/TrendStats.vue b/components/TrendStats.vue
index e4cb9bc..1c52f5d 100644
--- a/components/TrendStats.vue
+++ b/components/TrendStats.vue
@@ -5,20 +5,14 @@
-
-
{{ info.month }}
+
+ {{ info?.month }}
+ {{ info?.value }}
-
{{ info.value }}
-
+
@@ -32,6 +26,10 @@ export default {
type: String,
default: '',
},
+ chartId: {
+ type: String,
+ default: '',
+ },
values: {
type: Array,
default: () => [],
@@ -60,15 +58,41 @@ export default {
'Noviembre',
'Diciembre',
],
+ abrevMonths: [
+ 'Ene',
+ 'Feb',
+ 'Mar',
+ 'Abr',
+ 'May',
+ 'Jun',
+ 'Jul',
+ 'Ago',
+ 'Sep',
+ 'Oct',
+ 'Nov',
+ 'Dic',
+ ]
}
},
+
computed: {
dataset() {
return {
- data: this.values,
- showPoints: true,
- fill: true,
- smooth: true,
+ xAxis: {
+ type: 'category',
+ data: this.abrevMonths
+ },
+ yAxis: {
+ type: 'value'
+ },
+ series: [
+ {
+ data: this.yAxisValues,
+ type: 'line',
+ smooth: true,
+ color: this.color
+ }
+ ]
}
},
cssProps() {
@@ -77,26 +101,37 @@ export default {
}
},
info() {
- return {
- month: this.currentInfo ? this.currentInfo.month : 'Este mes',
- value: this.currentInfo
- ? this.currentInfo.value
- : this.values[11].value,
- }
+ const actualMonth = new Date().getMonth();
+ const currentMonthInfo = this.values.sort((a, b) => a.month - b.month)[actualMonth];
+ const res = {
+ month: currentMonthInfo?.month ? this.months[actualMonth] : 'Este mes',
+ value: currentMonthInfo?.value ? currentMonthInfo?.value : 0,
+ };
+ return res;
+ },
+ yAxisValues(){
+ const ArrValues = [...this.values]
+ const res = [];
+ ArrValues.sort((a, b) => a.month - b.month)
+ ArrValues.forEach(item => {
+ res.push(item.value)
+ })
+ return res
},
},
+
methods: {
- onMouseMove(params) {
- if (params) {
- this.currentInfo = {
- month: this.months[params.data[0].month - 1],
- value: params.data[0].value,
- }
- } else {
- this.currentInfo = null
- }
- },
- },
+ // onMouseMove(params) {
+ // if (params) {
+ // this.currentInfo = {
+ // month: this.months[params.data[0].month - 1],
+ // value: params.data[0].value,
+ // }
+ // } else {
+ // this.currentInfo = null
+ // }
+ // },
+},
}
@@ -111,11 +146,16 @@ export default {
justify-content: space-between;
align-items: center;
width: 100%;
+ .period {
+ display: flex;
+ flex-direction: column-reverse;
+ }
.value {
font-size: 30px;
}
.chart {
width: 40%;
+
}
}
.stroke {
diff --git a/package-lock.json b/package-lock.json
index dbc3f0d..a123584 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13,6 +13,7 @@
"@nuxtjs/sitemap": "^7.4.3",
"@pinia/nuxt": "^0.11.2",
"dompurify": "^3.2.6",
+ "echarts": "^6.0.0",
"eslint": "^9.32.0",
"js-cookie": "^3.0.5",
"nuxt": "^3.17.7",
@@ -7132,6 +7133,22 @@
"integrity": "sha512-GJRqdiy2h+EXy6a8E6R+ubmqUM08BK0FWNq41k24fup6045biQ8NXxoXimiwegMQvFFV3t1emADdGNL1TlS61A==",
"license": "MIT"
},
+ "node_modules/echarts": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/echarts/-/echarts-6.0.0.tgz",
+ "integrity": "sha512-Tte/grDQRiETQP4xz3iZWSvoHrkCQtwqd6hs+mifXcjrCuo2iKWbajFObuLJVBlDIJlOzgQPd1hsaKt/3+OMkQ==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "tslib": "2.3.0",
+ "zrender": "6.0.0"
+ }
+ },
+ "node_modules/echarts/node_modules/tslib": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz",
+ "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==",
+ "license": "0BSD"
+ },
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@@ -14656,6 +14673,21 @@
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
+ },
+ "node_modules/zrender": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/zrender/-/zrender-6.0.0.tgz",
+ "integrity": "sha512-41dFXEEXuJpNecuUQq6JlbybmnHaqqpGlbH1yxnA5V9MMP4SbohSVZsJIwz+zdjQXSSlR1Vc34EgH1zxyTDvhg==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "tslib": "2.3.0"
+ }
+ },
+ "node_modules/zrender/node_modules/tslib": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz",
+ "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==",
+ "license": "0BSD"
}
}
}
diff --git a/package.json b/package.json
index c1b8ac4..31b52e8 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"@nuxtjs/sitemap": "^7.4.3",
"@pinia/nuxt": "^0.11.2",
"dompurify": "^3.2.6",
+ "echarts": "^6.0.0",
"eslint": "^9.32.0",
"js-cookie": "^3.0.5",
"nuxt": "^3.17.7",
diff --git a/pages/admin/estadisticas.vue b/pages/admin/estadisticas.vue
index 16dd448..d0b9312 100644
--- a/pages/admin/estadisticas.vue
+++ b/pages/admin/estadisticas.vue
@@ -14,33 +14,33 @@
- {{ companiesTimeline }}
- {{ productsTimeline }}
- {{ usersTimeline }}
- {{ contactTimeline }}
- {{ shoppingTimeline }}
!!state.access,
isUser: (state) => state.role === 'SHOP_USER',