2018-02-15 01:33:34 -08:00
|
|
|
<template>
|
2019-02-14 12:08:59 -08:00
|
|
|
<div>
|
2018-11-03 00:44:05 -07:00
|
|
|
<div ref="chart"></div>
|
2018-02-15 01:33:34 -08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2019-02-03 16:37:15 -08:00
|
|
|
import ApexCharts from 'apexcharts';
|
2018-11-03 00:44:05 -07:00
|
|
|
|
2018-02-15 01:33:34 -08:00
|
|
|
export default Vue.extend({
|
2019-02-14 12:08:59 -08:00
|
|
|
props: {
|
|
|
|
user: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
limit: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 21
|
|
|
|
}
|
|
|
|
},
|
2018-02-15 01:33:34 -08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
|
|
|
data: [],
|
|
|
|
peak: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2018-11-08 15:13:34 -08:00
|
|
|
this.$root.api('charts/user/notes', {
|
2018-03-28 22:48:47 -07:00
|
|
|
userId: this.user.id,
|
2018-11-03 00:44:05 -07:00
|
|
|
span: 'day',
|
2019-02-14 12:08:59 -08:00
|
|
|
limit: this.limit
|
2018-11-03 00:44:05 -07: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 12:08:59 -08:00
|
|
|
for (let i = 0; i < this.limit; i++) {
|
2018-11-03 00:44:05 -07: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: {
|
2019-03-14 09:43:11 -07:00
|
|
|
columnWidth: '80%'
|
2018-11-03 00:44:05 -07:00
|
|
|
}
|
|
|
|
},
|
2019-07-05 05:13:52 -07:00
|
|
|
dataLabels: {
|
|
|
|
enabled: false
|
|
|
|
},
|
2018-11-03 00:44:05 -07:00
|
|
|
grid: {
|
|
|
|
clipMarkers: false,
|
|
|
|
padding: {
|
|
|
|
top: 0,
|
|
|
|
right: 8,
|
|
|
|
bottom: 0,
|
|
|
|
left: 8
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tooltip: {
|
|
|
|
shared: true,
|
|
|
|
intersect: false
|
|
|
|
},
|
|
|
|
series: [{
|
|
|
|
name: 'Normal',
|
|
|
|
data: normal
|
|
|
|
}, {
|
|
|
|
name: 'Reply',
|
|
|
|
data: reply
|
|
|
|
}, {
|
|
|
|
name: 'Renote',
|
|
|
|
data: renote
|
|
|
|
}],
|
|
|
|
xaxis: {
|
|
|
|
type: 'datetime',
|
|
|
|
crosshairs: {
|
|
|
|
width: 1,
|
|
|
|
opacity: 1
|
|
|
|
}
|
|
|
|
}
|
2018-02-15 01:33:34 -08:00
|
|
|
});
|
2018-11-03 00:44:05 -07:00
|
|
|
|
|
|
|
chart.render();
|
2018-02-15 01:33:34 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|