Skip to content

Commit

Permalink
feat(webui): support command chart, fix #252
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed May 2, 2021
1 parent 361ea7c commit 4d5d87a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/plugin-webui/client/views/home/command-chart.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<k-card class="frameless" title="指令调用频率">
<k-chart v-if="Object.keys(stats.commands).length" :option="option" autoresize/>
<p v-else>暂无数据。</p>
</k-card>
</template>

<script lang="ts" setup>
import { stats } from '~/client'
import { computed } from 'vue'
const option = computed(() => ({
tooltip: {
trigger: 'item',
formatter({ data }) {
const output = [data.name]
output.push(`日均调用:${data.value}`)
return output.join('<br>')
},
},
series: [{
type: 'pie',
data: Object.entries(stats.value.commands)
.sort((a, b) => b[1] - a[1])
.map(([name, value]) => ({ name, value })),
radius: ['35%', '65%'],
minShowLabelAngle: 3,
}],
}))
</script>
2 changes: 2 additions & 0 deletions packages/plugin-webui/client/views/home/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
<history-chart/>
<hour-chart/>
<group-chart/>
<command-chart/>
</div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { stats, profile, meta } from '~/client'
import CommandChart from './command-chart.vue'
import GroupChart from './group-chart.vue'
import HistoryChart from './history-chart.vue'
import HourChart from './hour-chart.vue'
Expand Down

0 comments on commit 4d5d87a

Please sign in to comment.