From e7350de10b46554a2dab78261f6f6b69537e40c4 Mon Sep 17 00:00:00 2001
From: Jan Michek <15363559+janmichek@users.noreply.github.com>
Date: Wed, 10 Jan 2024 10:11:03 +0100
Subject: [PATCH] feat: Names charts (#641)
---
src/components/LineChart.vue | 5 +--
src/components/NamesChartPanel.vue | 56 ++++++++++++++++++++++++++++++
src/pages/names/index.vue | 12 ++++++-
src/stores/names.js | 16 +++++++++
4 files changed, 86 insertions(+), 3 deletions(-)
create mode 100644 src/components/NamesChartPanel.vue
diff --git a/src/components/LineChart.vue b/src/components/LineChart.vue
index b622a3121..a9c29e6a6 100644
--- a/src/components/LineChart.vue
+++ b/src/components/LineChart.vue
@@ -46,10 +46,10 @@ function formatDate(label) {
const date = DateTime.fromISO(label)
if (props.selectedInterval === 'month') {
- return date.toFormat('yyyy-MM')
+ return date.toFormat('yyyy/MM')
}
- return date.toFormat('MM-dd')
+ return date.toFormat('MM/dd')
}
function formatNumberFractions(number) {
@@ -100,6 +100,7 @@ const chartOptions = {
display: false,
},
ticks: {
+ precision: 0,
callback: function(value) {
return formatNumberFractions(value)
},
diff --git a/src/components/NamesChartPanel.vue b/src/components/NamesChartPanel.vue
new file mode 100644
index 000000000..09d509db4
--- /dev/null
+++ b/src/components/NamesChartPanel.vue
@@ -0,0 +1,56 @@
+
+
+
+ NAMES ACTIVATED TREND
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/names/index.vue b/src/pages/names/index.vue
index f632d510d..8e47983ae 100644
--- a/src/pages/names/index.vue
+++ b/src/pages/names/index.vue
@@ -5,7 +5,6 @@
Names
-
{{ namesHints.name }}
+
@@ -82,3 +82,13 @@ if (process.client) {
fetchNamesDetails({ limit })
}
+
+
diff --git a/src/stores/names.js b/src/stores/names.js
index b6e0a26fc..10bebb6d2 100644
--- a/src/stores/names.js
+++ b/src/stores/names.js
@@ -13,6 +13,7 @@ export const useNamesStore = defineStore('names', () => {
const rawInAuctionNames = ref(null)
const rawExpiredNames = ref(null)
const rawRecentlyActivatedNames = ref(null)
+ const namesStatistics = ref(null)
const activeNames = computed(() => {
return rawActiveNames.value
@@ -73,6 +74,19 @@ export const useNamesStore = defineStore('names', () => {
rawRecentlyActivatedNames.value = data.data
}
+ async function fetchNamesStatistics(interval = 'day', limit = 7, range) {
+ namesStatistics.value = null
+
+ const slug = range
+ ? `?min_start_date=${range.minStart}&max_start_date=${range.maxStart}&limit=100`
+ : `?interval_by=${interval}&limit=${limit}`
+
+ const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/statistics/names${slug}`)
+
+ // remove last interval from the response not to show current interval that is being built
+ namesStatistics.value = range ? data.data.reverse() : data.data.slice(1).reverse()
+ }
+
return {
rawActiveNames,
rawInAuctionNames,
@@ -83,10 +97,12 @@ export const useNamesStore = defineStore('names', () => {
auctionsEndingSoon,
expiredNames,
recentlyActivatedNames,
+ namesStatistics,
fetchNamesDetails,
fetchActiveNames,
fetchInAuctionNames,
fetchExpiredNames,
fetchRecentlyActivatedNames,
+ fetchNamesStatistics,
}
})