summaryrefslogtreecommitdiff
path: root/src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-08-23 16:36:23 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-08-23 16:36:23 +0900
commit71a5662195b4b6a8d4d2c2fc357752b9da350b6f (patch)
tree1b6c4778bc1661bb32ba99a759b5300cb9c52f0d /src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue
parent1時間単位での集計を追加 (diff)
downloadmisskey-71a5662195b4b6a8d4d2c2fc357752b9da350b6f.tar.gz
misskey-71a5662195b4b6a8d4d2c2fc357752b9da350b6f.tar.bz2
misskey-71a5662195b4b6a8d4d2c2fc357752b9da350b6f.zip
一時間ごとのグラフも見れるように
Diffstat (limited to 'src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue')
-rw-r--r--src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue57
1 files changed, 40 insertions, 17 deletions
diff --git a/src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue b/src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue
index c2ab4a78e3..45ecc13929 100644
--- a/src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue
+++ b/src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue
@@ -1,11 +1,14 @@
<template>
-<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
- <polyline
- :points="points"
- fill="none"
- stroke-width="1"
- stroke="#555"/>
-</svg>
+<div>
+ <a @click="span = 'day'">Per day</a> | <a @click="span = 'hour'">Per hour</a>
+ <svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
+ <polyline
+ :points="points"
+ fill="none"
+ stroke-width="0.3"
+ stroke="#555"/>
+ </svg>
+</div>
</template>
<script lang="ts">
@@ -23,20 +26,40 @@ export default Vue.extend({
},
data() {
return {
- viewBoxX: 365,
- viewBoxY: 70,
- points: null
+ viewBoxX: 100,
+ viewBoxY: 30,
+ points: null,
+ span: 'day'
};
},
- created() {
- const peak = Math.max.apply(null, this.chart.map(d => this.type == 'local' ? d.users.local.diff : d.users.remote.diff));
+ computed: {
+ stats(): any[] {
+ return (
+ this.span == 'day' ? this.chart.perDay :
+ this.span == 'hour' ? this.chart.perHour :
+ null
+ );
+ }
+ },
+ watch: {
+ stats() {
+ this.render();
+ }
+ },
+ mounted() {
+ this.render();
+ },
+ methods: {
+ render() {
+ const peak = Math.max.apply(null, this.stats.map(d => this.type == 'local' ? d.users.local.diff : d.users.remote.diff));
- if (peak != 0) {
- const data = this.chart.slice().reverse().map(x => ({
- count: this.type == 'local' ? x.users.local.diff : x.users.remote.diff
- }));
+ if (peak != 0) {
+ const data = this.stats.slice().reverse().map(x => ({
+ count: this.type == 'local' ? x.users.local.diff : x.users.remote.diff
+ }));
- this.points = data.map((d, i) => `${i},${(1 - (d.count / peak)) * this.viewBoxY}`).join(' ');
+ this.points = data.map((d, i) => `${(this.viewBoxX / data.length) * i},${(1 - (d.count / peak)) * this.viewBoxY}`).join(' ');
+ }
}
}
});