2023-07-27 14:31:52 +09:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-02-18 19:31:11 +09:00
|
|
|
<template>
|
2023-05-14 10:21:56 +09:00
|
|
|
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`" :class="$style.root" @mousedown.prevent="onMousedown">
|
2020-02-18 19:31:11 +09:00
|
|
|
<polyline
|
|
|
|
:points="pointsNote"
|
|
|
|
fill="none"
|
|
|
|
stroke-width="1"
|
2023-05-14 10:21:56 +09:00
|
|
|
stroke="#41ddde"
|
|
|
|
/>
|
2020-02-18 19:31:11 +09:00
|
|
|
<polyline
|
|
|
|
:points="pointsReply"
|
|
|
|
fill="none"
|
|
|
|
stroke-width="1"
|
2023-05-14 10:21:56 +09:00
|
|
|
stroke="#f7796c"
|
|
|
|
/>
|
2020-02-18 19:31:11 +09:00
|
|
|
<polyline
|
|
|
|
:points="pointsRenote"
|
|
|
|
fill="none"
|
|
|
|
stroke-width="1"
|
2023-05-14 10:21:56 +09:00
|
|
|
stroke="#a1de41"
|
|
|
|
/>
|
2020-02-18 19:31:11 +09:00
|
|
|
<polyline
|
|
|
|
:points="pointsTotal"
|
|
|
|
fill="none"
|
|
|
|
stroke-width="1"
|
|
|
|
stroke="#555"
|
2023-05-14 10:21:56 +09:00
|
|
|
stroke-dasharray="2 2"
|
|
|
|
/>
|
2020-02-18 19:31:11 +09:00
|
|
|
</svg>
|
|
|
|
</template>
|
|
|
|
|
2022-05-25 16:43:12 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
const props = defineProps<{
|
|
|
|
activity: any[]
|
|
|
|
}>();
|
|
|
|
|
|
|
|
let viewBoxX: number = $ref(147);
|
|
|
|
let viewBoxY: number = $ref(60);
|
|
|
|
let zoom: number = $ref(1);
|
|
|
|
let pos: number = $ref(0);
|
|
|
|
let pointsNote: any = $ref(null);
|
|
|
|
let pointsReply: any = $ref(null);
|
|
|
|
let pointsRenote: any = $ref(null);
|
|
|
|
let pointsTotal: any = $ref(null);
|
2020-02-18 19:31:11 +09:00
|
|
|
|
|
|
|
function dragListen(fn) {
|
2022-07-10 19:47:29 +09:00
|
|
|
window.addEventListener('mousemove', fn);
|
2020-02-18 19:31:11 +09:00
|
|
|
window.addEventListener('mouseleave', dragClear.bind(null, fn));
|
2022-07-10 19:47:29 +09:00
|
|
|
window.addEventListener('mouseup', dragClear.bind(null, fn));
|
2020-02-18 19:31:11 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function dragClear(fn) {
|
2022-07-10 19:47:29 +09:00
|
|
|
window.removeEventListener('mousemove', fn);
|
2020-02-18 19:31:11 +09:00
|
|
|
window.removeEventListener('mouseleave', dragClear);
|
2022-07-10 19:47:29 +09:00
|
|
|
window.removeEventListener('mouseup', dragClear);
|
2020-02-18 19:31:11 +09:00
|
|
|
}
|
|
|
|
|
2022-05-25 16:43:12 +09:00
|
|
|
function onMousedown(ev) {
|
|
|
|
const clickX = ev.clientX;
|
|
|
|
const clickY = ev.clientY;
|
|
|
|
const baseZoom = zoom;
|
|
|
|
const basePos = pos;
|
2020-02-18 19:31:11 +09:00
|
|
|
|
2022-05-25 16:43:12 +09:00
|
|
|
// 動かした時
|
|
|
|
dragListen(me => {
|
|
|
|
let moveLeft = me.clientX - clickX;
|
|
|
|
let moveTop = me.clientY - clickY;
|
2020-02-18 19:31:11 +09:00
|
|
|
|
2022-05-25 16:43:12 +09:00
|
|
|
zoom = Math.max(1, baseZoom + (-moveTop / 20));
|
|
|
|
pos = Math.min(0, basePos + moveLeft);
|
|
|
|
if (pos < -(((props.activity.length - 1) * zoom) - viewBoxX)) pos = -(((props.activity.length - 1) * zoom) - viewBoxX);
|
2020-02-18 19:31:11 +09:00
|
|
|
|
2022-05-25 16:43:12 +09:00
|
|
|
render();
|
|
|
|
});
|
|
|
|
}
|
2020-02-18 19:31:11 +09:00
|
|
|
|
2022-05-25 16:43:12 +09:00
|
|
|
function render() {
|
|
|
|
const peak = Math.max(...props.activity.map(d => d.total));
|
|
|
|
if (peak !== 0) {
|
|
|
|
const activity = props.activity.slice().reverse();
|
|
|
|
pointsNote = activity.map((d, i) => `${(i * zoom) + pos},${(1 - (d.notes / peak)) * viewBoxY}`).join(' ');
|
|
|
|
pointsReply = activity.map((d, i) => `${(i * zoom) + pos},${(1 - (d.replies / peak)) * viewBoxY}`).join(' ');
|
|
|
|
pointsRenote = activity.map((d, i) => `${(i * zoom) + pos},${(1 - (d.renotes / peak)) * viewBoxY}`).join(' ');
|
|
|
|
pointsTotal = activity.map((d, i) => `${(i * zoom) + pos},${(1 - (d.total / peak)) * viewBoxY}`).join(' ');
|
2020-02-18 19:31:11 +09:00
|
|
|
}
|
2022-05-25 16:43:12 +09:00
|
|
|
}
|
2020-02-18 19:31:11 +09:00
|
|
|
</script>
|
|
|
|
|
2023-05-14 10:21:56 +09:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2020-02-18 19:31:11 +09:00
|
|
|
display: block;
|
|
|
|
padding: 16px;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
cursor: all-scroll;
|
|
|
|
}
|
|
|
|
</style>
|