Skip to content

Commit

Permalink
fix(analytics): fix empty chart when receiving without sending
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 4, 2024
1 parent b593572 commit dad36b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion plugins/analytics/client/charts/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default (ctx: Context) => {
fields: ['analytics'],
showTab: true,
options({ analytics }, tab) {
if (!Object.keys(analytics.messageByBot).length) return
const data = Object
.entries(analytics.messageByBot)
.map(([key, value]) => ({
Expand All @@ -21,6 +20,10 @@ export default (ctx: Context) => {
value: value[tab],
})),
}))
const total = data.reduce((sum, { children }) => {
return sum + children.reduce((sum, { value }) => sum + value, 0)
}, 0)
if (!total) return

return {
tooltip: Tooltip.item(({ data }) => {
Expand Down
1 change: 0 additions & 1 deletion plugins/analytics/client/charts/hour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default (ctx: Context) => {
type: 'value',
},
series: [{
name: '其他',
data: analytics.messageByHour.map((val, index) => [index + 0.5, val[tab] || 0]),
type: 'bar',
stack: '1',
Expand Down

0 comments on commit dad36b6

Please sign in to comment.