add block chart

This commit is contained in:
liangping 2024-03-31 19:39:40 +08:00
parent 87197797a9
commit 5ffa213b14
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,44 @@
<script lang="ts" setup>
import ApexCharts from 'vue3-apexcharts';
import { computed, ref } from '@vue/reactivity';
import { useBaseStore } from '@/stores';
const baseStore = useBaseStore();
const options = computed(() => {
return {
chart: {
type: 'bar',
height: 150
},
plotOptions: {
bar: {
// borderRadius: 4,
horizontal: false,
}
},
dataLabels: {
enabled: false
},
colors: ['#5A67D8'],
xaxis: {
labels: {
show: false,
rotate: -45
},
show: false,
categories: baseStore.recents.map((x) => x.block.header.height).concat(Array(50-baseStore.recents.length).fill('')),
}
};
});
const series = computed(() => {
return [{
name: 'Txs',
data: baseStore.recents?.map((x) => x.block.data.txs.length) || []
}]
});
</script>
<template>
<ApexCharts type="bar" height="150" :options="options" :series="series" />
</template>

View File

@ -1,6 +1,8 @@
<script lang="ts" setup>
import { computed, ref } from '@vue/reactivity';
import { useBaseStore, useFormatter } from '@/stores';
import TxsInBlocksChart from '@/components/charts/TxsInBlocksChart.vue';
const props = defineProps(['chain']);
const tab = ref('blocks');
@ -25,8 +27,11 @@ const list = computed(() => {
>{{ $t('block.future') }}</RouterLink>
</div>
<div v-show="tab === 'blocks'" class="grid xl:!grid-cols-6 md:!grid-cols-4 grid-cols-1 gap-3">
<div v-show="tab === 'blocks'">
<TxsInBlocksChart />
<div class="grid xl:!grid-cols-6 md:!grid-cols-4 grid-cols-1 gap-3">
<RouterLink v-for="item in list"
class="flex flex-col justify-between rounded p-4 shadow bg-base-100"
:to="`/${chain}/block/${item.block.header.height}`">
@ -47,6 +52,7 @@ const list = computed(() => {
</RouterLink>
</div>
</div>
</div>
</template>
<route>