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