From e88f7ca7b2c06cac067c54dd18695ab27f303fab Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 3 Nov 2018 16:44:05 +0900 Subject: [PATCH] [Client] Fix some charts --- .../views/components/activity.calendar.vue | 14 ++- .../app/desktop/views/components/activity.vue | 12 +- .../app/mobile/views/components/activity.vue | 111 +++++++++++++----- 3 files changed, 101 insertions(+), 36 deletions(-) diff --git a/src/client/app/desktop/views/components/activity.calendar.vue b/src/client/app/desktop/views/components/activity.calendar.vue index 1a88d1a99..4306aa928 100644 --- a/src/client/app/desktop/views/components/activity.calendar.vue +++ b/src/client/app/desktop/views/components/activity.calendar.vue @@ -32,9 +32,21 @@ export default Vue.extend({ this.data.forEach(d => d.total = d.notes + d.replies + d.renotes); const peak = Math.max.apply(null, this.data.map(d => d.total)); + const now = new Date(); + const year = now.getFullYear(); + const month = now.getMonth(); + const day = now.getDate(); + let x = 0; - this.data.slice().reverse().forEach(d => { + this.data.slice().reverse().forEach((d, i) => { d.x = x; + + const date = new Date(year, month, day - i); + d.date = { + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }; d.date.weekday = (new Date(d.date.year, d.date.month - 1, d.date.day)).getDay(); d.v = peak == 0 ? 0 : d.total / (peak / 2); diff --git a/src/client/app/desktop/views/components/activity.vue b/src/client/app/desktop/views/components/activity.vue index bd952c39d..e9ed532a3 100644 --- a/src/client/app/desktop/views/components/activity.vue +++ b/src/client/app/desktop/views/components/activity.vue @@ -43,11 +43,17 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('aggregation/users/activity', { + (this as any).api('charts/user/notes', { userId: this.user.id, - limit: 20 * 7 + span: 'day', + limit: 7 * 20 }).then(activity => { - this.activity = activity; + this.activity = activity.diffs.normal.map((_, i) => ({ + total: activity.diffs.normal[i] + activity.diffs.reply[i] + activity.diffs.renote[i], + notes: activity.diffs.normal[i], + replies: activity.diffs.reply[i], + renotes: activity.diffs.renote[i] + })); this.fetching = false; }); }, diff --git a/src/client/app/mobile/views/components/activity.vue b/src/client/app/mobile/views/components/activity.vue index dcd319cb6..627bebbd3 100644 --- a/src/client/app/mobile/views/components/activity.vue +++ b/src/client/app/mobile/views/components/activity.vue @@ -1,23 +1,13 @@