Commit 28ff8265 authored by chenqikuai's avatar chenqikuai

fix:修复链上交易数量展示

parent 05abf2ed
......@@ -28,7 +28,7 @@ import {
} from 'echarts/components'
import { LabelLayout, UniversalTransition } from 'echarts/features'
import { CanvasRenderer } from 'echarts/renderers'
import { statSearch } from '@/service/api'
import { numOfOnChainTx, statSearch } from '@/service/api'
import moment from 'moment'
// 通过 ComposeOption 来组合出一个只有必须组件和图表的 Option 类型
type ECOption = echarts.ComposeOption<
......@@ -69,10 +69,17 @@ export default Vue.extend({
generateD1() {
const list = []
for (let i = 0; i < 7; ++i) {
const m = moment().hour(0).minute(0).second(0).add(-i, 'days')
const m = moment().startOf('days').add(-i, 'days')
list.push(m)
}
return list.map((i) => i.unix())
return list.map((i) => {
return {
start: i.unix(),
format: i.format('YYYY.MM.DD'),
end: i.endOf('days').unix(),
}
})
},
generateW1() {
const list = []
......@@ -84,15 +91,30 @@ export default Vue.extend({
.add(-i * 7, 'days')
list.push(m)
}
return list.map((i) => i.unix())
return list.map((i) => {
return {
start: moment(i).add(-1, 'weeks').unix(),
end: moment(i).unix(),
format: `${moment(i).add(-1, 'weeks').format('MMM DD')} - ${moment(
i,
).format('MMM DD')}`,
}
})
},
generateM1() {
const list = []
for (let i = 0; i < 7; ++i) {
const m = moment().hour(0).minute(0).second(0).add(-i, 'month')
const m = moment().startOf('month').add(-i, 'month')
list.push(m)
}
return list.map((i) => i.unix())
return list.map((i) => {
return {
start: moment(i).unix(),
end: moment(i).endOf('month').unix(),
format: `${moment(i).format('MMM')}`,
}
})
},
generateY1() {
const list = []
......@@ -100,7 +122,13 @@ export default Vue.extend({
const m = moment().hour(0).minute(0).second(0).add(-i, 'year')
list.push(m)
}
return list.map((i) => i.unix())
return list.map((i) => {
return {
start: i.startOf('year').unix(),
end: i.endOf('year').unix(),
format: `${i.format('YYYY')}`,
}
})
},
generate() {
switch (this.scale) {
......@@ -119,7 +147,7 @@ export default Vue.extend({
// filters: ['D1', 'W1', 'M1', 'Y1'],
const times = this.generate()
times &&
statSearch(times).then((ret) => {
numOfOnChainTx(times).then((ret) => {
if (ret.error == null) {
this.xData = ret.result
var myChart = echarts.init(this.$refs.charts as HTMLElement)
......@@ -132,7 +160,7 @@ export default Vue.extend({
boundaryGap: false,
data: times
?.map((i) => {
return moment.unix(i).format('YYYY-MM-DD')
return i.format
})
.reverse(),
},
......@@ -141,9 +169,7 @@ export default Vue.extend({
},
series: [
{
data: this.xData
.map((i: any) => (i && i[0] && i[0].tx_count) || 0)
.reverse(),
data: this.xData.map((i: any) => i || 0).reverse(),
type: 'line',
areaStyle: {},
},
......
......@@ -50,13 +50,13 @@ export default Vue.extend({
}
});
this.timer = window.setInterval(() => {
this.fetchAllPos33TicketCountData();
this.fetchAccountCountData();
this.fetchTpsData();
this.init();
this.fetchLatestTxListData();
}, 15 * 1000);
// this.timer = window.setInterval(() => {
// this.fetchAllPos33TicketCountData();
// this.fetchAccountCountData();
// this.fetchTpsData();
// this.init();
// this.fetchLatestTxListData();
// }, 15 * 1000);
},
beforeDestroy() {
window.clearInterval(this.timer);
......
......@@ -353,3 +353,26 @@ export function getVoterAddr(addr: string, number: number, size: number) {
},
});
}
export function numOfOnChainTx(times: { start: number; end: number }[]) {
return axios(expandApi, {
method: "post",
params: {
id: 1,
method: "Tx.TxCounts",
params: [
[
...times.map((i) => ({
range: [
{
start: i.start,
end: i.end,
key: "block_time",
},
],
})),
],
],
},
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment