Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ycc-website
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Website
ycc-website
Commits
28ff8265
Commit
28ff8265
authored
Mar 01, 2022
by
chenqikuai
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修复链上交易数量展示
parent
05abf2ed
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
19 deletions
+68
-19
charts.vue
src/components/charts.vue
+38
-12
blockChainBrowser.ts
src/mixin/blockChainBrowser.ts
+7
-7
api.ts
src/service/api.ts
+23
-0
No files found.
src/components/charts.vue
View file @
28ff8265
...
...
@@ -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
:
{},
},
...
...
src/mixin/blockChainBrowser.ts
View file @
28ff8265
...
...
@@ -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
);
...
...
src/service/api.ts
View file @
28ff8265
...
...
@@ -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"
,
},
],
})),
],
],
},
});
}
chenqikuai
@chenqikuai
mentioned in commit
748f7ae1
·
Mar 03, 2022
mentioned in commit
748f7ae1
mentioned in commit 748f7ae18ac2f8eb14ee7c2865eaea786342a520
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment