2018-02-15 09:33:34 +00:00
|
|
|
<template>
|
2020-11-25 12:31:34 +00:00
|
|
|
<MkContainer>
|
2020-12-26 01:47:36 +00:00
|
|
|
<template #header><Fa :icon="faChartBar" style="margin-right: 0.5em;"/>{{ $ts.activity }}</template>
|
2020-11-25 12:31:34 +00:00
|
|
|
|
|
|
|
<div style="padding: 8px;">
|
|
|
|
<div ref="chart"></div>
|
|
|
|
</div>
|
|
|
|
</MkContainer>
|
2018-02-15 09:33:34 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2019-02-04 00:37:15 +00:00
|
|
|
import ApexCharts from 'apexcharts';
|
2020-11-25 12:31:34 +00:00
|
|
|
import { faChartBar } from '@fortawesome/free-solid-svg-icons';
|
2020-10-17 11:12:00 +00:00
|
|
|
import * as os from '@/os';
|
2020-11-25 12:31:34 +00:00
|
|
|
import MkContainer from '@/components/ui/container.vue';
|
2018-11-03 07:44:05 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-11-25 12:31:34 +00:00
|
|
|
components: {
|
|
|
|
MkContainer,
|
|
|
|
},
|
2019-02-14 20:08:59 +00:00
|
|
|
props: {
|
|
|
|
user: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
limit: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
2020-01-29 19:37:25 +00:00
|
|
|
default: 40
|
2019-02-14 20:08:59 +00:00
|
|
|
}
|
|
|
|
},
|
2018-02-15 09:33:34 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
|
|
|
data: [],
|
2020-11-25 12:31:34 +00:00
|
|
|
peak: null,
|
|
|
|
faChartBar,
|
2018-02-15 09:33:34 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('charts/user/notes', {
|
2018-03-29 05:48:47 +00:00
|
|
|
userId: this.user.id,
|
2018-11-03 07:44:05 +00:00
|
|
|
span: 'day',
|
2019-02-14 20:08:59 +00:00
|
|
|
limit: this.limit
|
2018-11-03 07:44:05 +00:00
|
|
|
}).then(stats => {
|
|
|
|
const normal = [];
|
|
|
|
const reply = [];
|
|
|
|
const renote = [];
|
|
|
|
|
|
|
|
const now = new Date();
|
|
|
|
const y = now.getFullYear();
|
|
|
|
const m = now.getMonth();
|
|
|
|
const d = now.getDate();
|
|
|
|
|
2019-02-14 20:08:59 +00:00
|
|
|
for (let i = 0; i < this.limit; i++) {
|
2018-11-03 07:44:05 +00:00
|
|
|
const x = new Date(y, m, d - i);
|
|
|
|
normal.push([
|
|
|
|
x,
|
|
|
|
stats.diffs.normal[i]
|
|
|
|
]);
|
|
|
|
reply.push([
|
|
|
|
x,
|
|
|
|
stats.diffs.reply[i]
|
|
|
|
]);
|
|
|
|
renote.push([
|
|
|
|
x,
|
|
|
|
stats.diffs.renote[i]
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
const chart = new ApexCharts(this.$refs.chart, {
|
|
|
|
chart: {
|
|
|
|
type: 'bar',
|
|
|
|
stacked: true,
|
|
|
|
height: 100,
|
|
|
|
sparkline: {
|
|
|
|
enabled: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
plotOptions: {
|
|
|
|
bar: {
|
2020-01-29 19:37:25 +00:00
|
|
|
columnWidth: '40%'
|
2018-11-03 07:44:05 +00:00
|
|
|
}
|
|
|
|
},
|
2019-07-05 12:13:52 +00:00
|
|
|
dataLabels: {
|
|
|
|
enabled: false
|
|
|
|
},
|
2018-11-03 07:44:05 +00:00
|
|
|
grid: {
|
|
|
|
clipMarkers: false,
|
|
|
|
padding: {
|
|
|
|
top: 0,
|
|
|
|
right: 8,
|
|
|
|
bottom: 0,
|
|
|
|
left: 8
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tooltip: {
|
|
|
|
shared: true,
|
2021-01-23 09:16:26 +00:00
|
|
|
intersect: false,
|
|
|
|
theme: this.$store.state.darkMode ? 'dark' : 'light',
|
2018-11-03 07:44:05 +00:00
|
|
|
},
|
|
|
|
series: [{
|
|
|
|
name: 'Normal',
|
|
|
|
data: normal
|
|
|
|
}, {
|
|
|
|
name: 'Reply',
|
|
|
|
data: reply
|
|
|
|
}, {
|
|
|
|
name: 'Renote',
|
|
|
|
data: renote
|
|
|
|
}],
|
|
|
|
xaxis: {
|
|
|
|
type: 'datetime',
|
|
|
|
crosshairs: {
|
|
|
|
width: 1,
|
|
|
|
opacity: 1
|
|
|
|
}
|
|
|
|
}
|
2018-02-15 09:33:34 +00:00
|
|
|
});
|
2018-11-03 07:44:05 +00:00
|
|
|
|
|
|
|
chart.render();
|
2018-02-15 09:33:34 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|