forked from cerc-io/cosmos-explorer
add block chart
This commit is contained in:
parent
87197797a9
commit
5ffa213b14
44
src/components/charts/TxsInBlocksChart.vue
Normal file
44
src/components/charts/TxsInBlocksChart.vue
Normal 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>
|
@ -1,6 +1,8 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from '@vue/reactivity';
|
import { computed, ref } from '@vue/reactivity';
|
||||||
import { useBaseStore, useFormatter } from '@/stores';
|
import { useBaseStore, useFormatter } from '@/stores';
|
||||||
|
import TxsInBlocksChart from '@/components/charts/TxsInBlocksChart.vue';
|
||||||
|
|
||||||
const props = defineProps(['chain']);
|
const props = defineProps(['chain']);
|
||||||
|
|
||||||
const tab = ref('blocks');
|
const tab = ref('blocks');
|
||||||
@ -25,8 +27,11 @@ const list = computed(() => {
|
|||||||
>{{ $t('block.future') }}</RouterLink>
|
>{{ $t('block.future') }}</RouterLink>
|
||||||
</div>
|
</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"
|
<RouterLink v-for="item in list"
|
||||||
class="flex flex-col justify-between rounded p-4 shadow bg-base-100"
|
class="flex flex-col justify-between rounded p-4 shadow bg-base-100"
|
||||||
:to="`/${chain}/block/${item.block.header.height}`">
|
:to="`/${chain}/block/${item.block.header.height}`">
|
||||||
@ -45,6 +50,7 @@ const list = computed(() => {
|
|||||||
<span class="text-right mt-1 whitespace-nowrap"> {{ item.block?.data?.txs.length }} txs </span>
|
<span class="text-right mt-1 whitespace-nowrap"> {{ item.block?.data?.txs.length }} txs </span>
|
||||||
</div>
|
</div>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
Reference in New Issue
Block a user