2021-10-21 22:36:48 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="cbbedffa">
|
|
|
|
<canvas ref="chartEl"></canvas>
|
|
|
|
<div v-if="fetching" class="fetching">
|
|
|
|
<MkLoading />
|
|
|
|
</div>
|
2021-10-23 04:34:41 +02:00
|
|
|
</div>
|
2021-10-21 22:36:48 +02:00
|
|
|
</template>
|
|
|
|
|
2022-05-14 14:20:41 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { onMounted, ref, watch, PropType, onUnmounted } from "vue";
|
2021-10-21 22:36:48 +02:00
|
|
|
import {
|
|
|
|
Chart,
|
|
|
|
ArcElement,
|
|
|
|
LineElement,
|
|
|
|
BarElement,
|
|
|
|
PointElement,
|
|
|
|
BarController,
|
|
|
|
LineController,
|
|
|
|
CategoryScale,
|
|
|
|
LinearScale,
|
|
|
|
TimeScale,
|
|
|
|
Legend,
|
|
|
|
Title,
|
|
|
|
Tooltip,
|
|
|
|
SubTitle,
|
|
|
|
Filler,
|
2023-04-08 02:01:42 +02:00
|
|
|
} from "chart.js";
|
|
|
|
import "chartjs-adapter-date-fns";
|
|
|
|
import { enUS } from "date-fns/locale";
|
|
|
|
import zoomPlugin from "chartjs-plugin-zoom";
|
2022-05-01 15:51:07 +02:00
|
|
|
// https://github.com/misskey-dev/misskey/pull/8575#issuecomment-1114242002
|
|
|
|
// We can't use gradient because Vite throws a error.
|
|
|
|
//import gradient from 'chartjs-plugin-gradient';
|
2023-04-08 02:01:42 +02:00
|
|
|
import * as os from "@/os";
|
|
|
|
import { defaultStore } from "@/store";
|
|
|
|
import { useChartTooltip } from "@/scripts/use-chart-tooltip";
|
2021-10-21 22:36:48 +02:00
|
|
|
|
2022-05-14 14:20:41 +02:00
|
|
|
const props = defineProps({
|
|
|
|
src: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
args: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
limit: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
2022-06-20 10:38:49 +02:00
|
|
|
default: 90,
|
2022-05-14 14:20:41 +02:00
|
|
|
},
|
|
|
|
span: {
|
2023-04-08 02:01:42 +02:00
|
|
|
type: String as PropType<"hour" | "day">,
|
2022-05-14 14:20:41 +02:00
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
detailed: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2022-06-20 10:38:49 +02:00
|
|
|
default: false,
|
2022-05-14 14:20:41 +02:00
|
|
|
},
|
|
|
|
stacked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2022-06-20 10:38:49 +02:00
|
|
|
default: false,
|
2022-05-14 14:20:41 +02:00
|
|
|
},
|
|
|
|
bar: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2022-06-20 10:38:49 +02:00
|
|
|
default: false,
|
2022-05-14 14:20:41 +02:00
|
|
|
},
|
|
|
|
aspectRatio: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
2022-06-20 10:38:49 +02:00
|
|
|
default: null,
|
2022-05-14 14:20:41 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-10-21 22:36:48 +02:00
|
|
|
Chart.register(
|
|
|
|
ArcElement,
|
|
|
|
LineElement,
|
|
|
|
BarElement,
|
|
|
|
PointElement,
|
|
|
|
BarController,
|
|
|
|
LineController,
|
|
|
|
CategoryScale,
|
|
|
|
LinearScale,
|
|
|
|
TimeScale,
|
|
|
|
Legend,
|
|
|
|
Title,
|
|
|
|
Tooltip,
|
|
|
|
SubTitle,
|
|
|
|
Filler,
|
2023-07-06 03:28:27 +02:00
|
|
|
zoomPlugin,
|
2022-05-01 15:51:07 +02:00
|
|
|
//gradient,
|
2021-10-21 22:36:48 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
const sum = (...arr) => arr.reduce((r, a) => r.map((b, i) => a[i] + b));
|
2023-04-08 02:01:42 +02:00
|
|
|
const negate = (arr) => arr.map((x) => -x);
|
2021-10-21 22:36:48 +02:00
|
|
|
const alpha = (hex, a) => {
|
|
|
|
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!;
|
|
|
|
const r = parseInt(result[1], 16);
|
|
|
|
const g = parseInt(result[2], 16);
|
|
|
|
const b = parseInt(result[3], 16);
|
|
|
|
return `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
|
|
};
|
|
|
|
|
2022-02-08 15:12:37 +01:00
|
|
|
const colors = {
|
2023-04-08 02:01:42 +02:00
|
|
|
blue: "#31748f",
|
|
|
|
green: "#9ccfd8",
|
|
|
|
yellow: "#f6c177",
|
|
|
|
red: "#eb6f92",
|
|
|
|
purple: "#c4a7e7",
|
|
|
|
orange: "#ebbcba",
|
|
|
|
lime: "#56949f",
|
|
|
|
cyan: "#9ccfd8",
|
2022-02-08 15:12:37 +01:00
|
|
|
};
|
2023-04-08 02:01:42 +02:00
|
|
|
const colorSets = [
|
|
|
|
colors.blue,
|
|
|
|
colors.green,
|
|
|
|
colors.yellow,
|
|
|
|
colors.red,
|
|
|
|
colors.purple,
|
|
|
|
];
|
2021-10-21 22:36:48 +02:00
|
|
|
const getColor = (i) => {
|
2022-02-08 15:12:37 +01:00
|
|
|
return colorSets[i % colorSets.length];
|
2021-10-21 22:36:48 +02:00
|
|
|
};
|
|
|
|
|
2022-05-14 14:20:41 +02:00
|
|
|
const now = new Date();
|
|
|
|
let chartInstance: Chart = null;
|
|
|
|
let chartData: {
|
|
|
|
series: {
|
|
|
|
name: string;
|
2023-04-08 02:01:42 +02:00
|
|
|
type: "line" | "area";
|
2022-05-14 14:20:41 +02:00
|
|
|
color?: string;
|
|
|
|
dashed?: boolean;
|
|
|
|
hidden?: boolean;
|
|
|
|
data: {
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
}[];
|
|
|
|
}[];
|
|
|
|
} = null;
|
|
|
|
|
|
|
|
const chartEl = ref<HTMLCanvasElement>(null);
|
|
|
|
const fetching = ref(true);
|
|
|
|
|
|
|
|
const getDate = (ago: number) => {
|
|
|
|
const y = now.getFullYear();
|
|
|
|
const m = now.getMonth();
|
|
|
|
const d = now.getDate();
|
|
|
|
const h = now.getHours();
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
return props.span === "day"
|
|
|
|
? new Date(y, m, d - ago)
|
|
|
|
: new Date(y, m, d, h - ago);
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
2021-10-21 22:36:48 +02:00
|
|
|
|
2022-05-14 14:20:41 +02:00
|
|
|
const format = (arr) => {
|
|
|
|
return arr.map((v, i) => ({
|
|
|
|
x: getDate(i).getTime(),
|
2022-06-20 10:38:49 +02:00
|
|
|
y: v,
|
2022-05-14 14:20:41 +02:00
|
|
|
}));
|
|
|
|
};
|
2022-01-31 13:07:33 +01:00
|
|
|
|
2022-06-25 11:05:35 +02:00
|
|
|
const { handler: externalTooltipHandler } = useChartTooltip();
|
2022-05-14 14:20:41 +02:00
|
|
|
|
|
|
|
const render = () => {
|
|
|
|
if (chartInstance) {
|
|
|
|
chartInstance.destroy();
|
|
|
|
}
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const gridColor = defaultStore.state.darkMode
|
|
|
|
? "rgba(255, 255, 255, 0.1)"
|
|
|
|
: "rgba(0, 0, 0, 0.1)";
|
|
|
|
const vLineColor = defaultStore.state.darkMode
|
|
|
|
? "rgba(255, 255, 255, 0.2)"
|
|
|
|
: "rgba(0, 0, 0, 0.2)";
|
2022-05-14 14:20:41 +02:00
|
|
|
|
|
|
|
// フォントカラー
|
2023-04-08 02:01:42 +02:00
|
|
|
Chart.defaults.color = getComputedStyle(
|
2023-07-06 03:28:27 +02:00
|
|
|
document.documentElement,
|
2023-04-08 02:01:42 +02:00
|
|
|
).getPropertyValue("--fg");
|
2022-05-14 14:20:41 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const maxes = chartData.series.map((x, i) =>
|
2023-07-06 03:28:27 +02:00
|
|
|
Math.max(...x.data.map((d) => d.y)),
|
2023-04-08 02:01:42 +02:00
|
|
|
);
|
2022-05-14 14:20:41 +02:00
|
|
|
|
|
|
|
chartInstance = new Chart(chartEl.value, {
|
2023-04-08 02:01:42 +02:00
|
|
|
type: props.bar ? "bar" : "line",
|
2022-05-14 14:20:41 +02:00
|
|
|
data: {
|
2023-04-08 02:01:42 +02:00
|
|
|
labels: new Array(props.limit)
|
|
|
|
.fill(0)
|
|
|
|
.map((_, i) => getDate(i).toLocaleString())
|
|
|
|
.slice()
|
|
|
|
.reverse(),
|
2022-05-14 14:20:41 +02:00
|
|
|
datasets: chartData.series.map((x, i) => ({
|
|
|
|
parsing: false,
|
|
|
|
label: x.name,
|
|
|
|
data: x.data.slice().reverse(),
|
|
|
|
tension: 0.3,
|
|
|
|
pointRadius: 0,
|
|
|
|
borderWidth: props.bar ? 0 : 2,
|
|
|
|
borderColor: x.color ? x.color : getColor(i),
|
|
|
|
borderDash: x.dashed ? [5, 5] : [],
|
2023-04-08 02:01:42 +02:00
|
|
|
borderJoinStyle: "round",
|
2022-05-14 14:20:41 +02:00
|
|
|
borderRadius: props.bar ? 3 : undefined,
|
2023-04-08 02:01:42 +02:00
|
|
|
backgroundColor: props.bar
|
|
|
|
? x.color
|
|
|
|
? x.color
|
|
|
|
: getColor(i)
|
|
|
|
: alpha(x.color ? x.color : getColor(i), 0.1),
|
2022-05-14 14:20:41 +02:00
|
|
|
/*gradient: props.bar ? undefined : {
|
|
|
|
backgroundColor: {
|
|
|
|
axis: 'y',
|
|
|
|
colors: {
|
|
|
|
0: alpha(x.color ? x.color : getColor(i), 0),
|
|
|
|
[maxes[i]]: alpha(x.color ? x.color : getColor(i), 0.2),
|
2021-10-21 22:36:48 +02:00
|
|
|
},
|
|
|
|
},
|
2022-05-14 14:20:41 +02:00
|
|
|
},*/
|
|
|
|
barPercentage: 0.9,
|
|
|
|
categoryPercentage: 0.9,
|
2023-04-08 02:01:42 +02:00
|
|
|
fill: x.type === "area",
|
2022-05-14 14:20:41 +02:00
|
|
|
clip: 8,
|
|
|
|
hidden: !!x.hidden,
|
|
|
|
})),
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
aspectRatio: props.aspectRatio || 2.5,
|
|
|
|
layout: {
|
|
|
|
padding: {
|
|
|
|
left: 0,
|
|
|
|
right: 8,
|
|
|
|
top: 0,
|
|
|
|
bottom: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
scales: {
|
|
|
|
x: {
|
2023-04-08 02:01:42 +02:00
|
|
|
type: "time",
|
2022-05-14 14:20:41 +02:00
|
|
|
stacked: props.stacked,
|
|
|
|
offset: false,
|
|
|
|
time: {
|
|
|
|
stepSize: 1,
|
2023-04-08 02:01:42 +02:00
|
|
|
unit: props.span === "day" ? "month" : "day",
|
2022-05-14 14:20:41 +02:00
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
color: gridColor,
|
2023-04-08 02:01:42 +02:00
|
|
|
borderColor: "rgb(0, 0, 0, 0)",
|
2021-10-21 22:36:48 +02:00
|
|
|
},
|
2022-05-14 14:20:41 +02:00
|
|
|
ticks: {
|
|
|
|
display: props.detailed,
|
|
|
|
maxRotation: 0,
|
|
|
|
autoSkipPadding: 16,
|
2021-10-21 22:36:48 +02:00
|
|
|
},
|
2022-05-14 14:20:41 +02:00
|
|
|
adapters: {
|
|
|
|
date: {
|
|
|
|
locale: enUS,
|
2022-02-02 18:08:54 +01:00
|
|
|
},
|
|
|
|
},
|
2022-05-14 14:20:41 +02:00
|
|
|
min: getDate(props.limit).getTime(),
|
|
|
|
},
|
|
|
|
y: {
|
2023-04-08 02:01:42 +02:00
|
|
|
position: "left",
|
2022-05-14 14:20:41 +02:00
|
|
|
stacked: props.stacked,
|
|
|
|
suggestedMax: 50,
|
|
|
|
grid: {
|
|
|
|
color: gridColor,
|
2023-04-08 02:01:42 +02:00
|
|
|
borderColor: "rgb(0, 0, 0, 0)",
|
2022-05-14 14:20:41 +02:00
|
|
|
},
|
|
|
|
ticks: {
|
|
|
|
display: props.detailed,
|
|
|
|
//mirror: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
interaction: {
|
|
|
|
intersect: false,
|
2023-04-08 02:01:42 +02:00
|
|
|
mode: "index",
|
2022-05-14 14:20:41 +02:00
|
|
|
},
|
|
|
|
elements: {
|
|
|
|
point: {
|
|
|
|
hoverRadius: 5,
|
|
|
|
hoverBorderWidth: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
animation: false,
|
|
|
|
plugins: {
|
|
|
|
legend: {
|
|
|
|
display: props.detailed,
|
2023-04-08 02:01:42 +02:00
|
|
|
position: "bottom",
|
2022-05-14 14:20:41 +02:00
|
|
|
labels: {
|
|
|
|
boxWidth: 16,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tooltip: {
|
|
|
|
enabled: false,
|
2023-04-08 02:01:42 +02:00
|
|
|
mode: "index",
|
2022-05-14 14:20:41 +02:00
|
|
|
animation: {
|
|
|
|
duration: 0,
|
|
|
|
},
|
|
|
|
external: externalTooltipHandler,
|
|
|
|
},
|
2023-04-08 02:01:42 +02:00
|
|
|
zoom: props.detailed
|
|
|
|
? {
|
|
|
|
pan: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
zoom: {
|
|
|
|
wheel: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
pinch: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
drag: {
|
|
|
|
enabled: false,
|
|
|
|
},
|
|
|
|
mode: "x",
|
|
|
|
},
|
|
|
|
limits: {
|
|
|
|
x: {
|
|
|
|
min: "original",
|
|
|
|
max: "original",
|
|
|
|
},
|
|
|
|
y: {
|
|
|
|
min: "original",
|
|
|
|
max: "original",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
: undefined,
|
2022-05-14 14:20:41 +02:00
|
|
|
//gradient,
|
|
|
|
},
|
|
|
|
},
|
2023-04-08 02:01:42 +02:00
|
|
|
plugins: [
|
|
|
|
{
|
|
|
|
id: "vLine",
|
|
|
|
beforeDraw(chart, args, options) {
|
|
|
|
if (chart.tooltip?._active?.length) {
|
|
|
|
const activePoint = chart.tooltip._active[0];
|
|
|
|
const ctx = chart.ctx;
|
|
|
|
const x = activePoint.element.x;
|
|
|
|
const topY = chart.scales.y.top;
|
|
|
|
const bottomY = chart.scales.y.bottom;
|
|
|
|
|
|
|
|
ctx.save();
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo(x, bottomY);
|
|
|
|
ctx.lineTo(x, topY);
|
|
|
|
ctx.lineWidth = 1;
|
|
|
|
ctx.strokeStyle = vLineColor;
|
|
|
|
ctx.stroke();
|
|
|
|
ctx.restore();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const exportData = () => {
|
|
|
|
// TODO
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchFederationChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/federation", {
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Received",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.inboxInstances),
|
|
|
|
color: colors.blue,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Delivered",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.deliveredInstances),
|
|
|
|
color: colors.green,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Stalled",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.stalled),
|
|
|
|
color: colors.red,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Pub Active",
|
|
|
|
type: "line",
|
|
|
|
data: format(raw.pubActive),
|
|
|
|
color: colors.purple,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Sub Active",
|
|
|
|
type: "line",
|
|
|
|
data: format(raw.subActive),
|
|
|
|
color: colors.orange,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Pub & Sub",
|
|
|
|
type: "line",
|
|
|
|
data: format(raw.pubsub),
|
|
|
|
dashed: true,
|
|
|
|
color: colors.cyan,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Pub",
|
|
|
|
type: "line",
|
|
|
|
data: format(raw.pub),
|
|
|
|
dashed: true,
|
|
|
|
color: colors.purple,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Sub",
|
|
|
|
type: "line",
|
|
|
|
data: format(raw.sub),
|
|
|
|
dashed: true,
|
|
|
|
color: colors.orange,
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchApRequestChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/ap-request", {
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "In",
|
|
|
|
type: "area",
|
|
|
|
color: "#31748f",
|
|
|
|
data: format(raw.inboxReceived),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Out (succ)",
|
|
|
|
type: "area",
|
|
|
|
color: "#c4a7e7",
|
|
|
|
data: format(raw.deliverSucceeded),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Out (fail)",
|
|
|
|
type: "area",
|
|
|
|
color: "#f6c177",
|
|
|
|
data: format(raw.deliverFailed),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchNotesChart = async (type: string): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/notes", {
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "All",
|
|
|
|
type: "line",
|
|
|
|
data: format(
|
|
|
|
type === "combined"
|
|
|
|
? sum(
|
|
|
|
raw.local.inc,
|
|
|
|
negate(raw.local.dec),
|
|
|
|
raw.remote.inc,
|
2023-07-06 03:28:27 +02:00
|
|
|
negate(raw.remote.dec),
|
2023-04-08 02:01:42 +02:00
|
|
|
)
|
2023-07-06 03:28:27 +02:00
|
|
|
: sum(raw[type].inc, negate(raw[type].dec)),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
color: "#888888",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Renotes",
|
|
|
|
type: "area",
|
|
|
|
data: format(
|
|
|
|
type === "combined"
|
|
|
|
? sum(raw.local.diffs.renote, raw.remote.diffs.renote)
|
2023-07-06 03:28:27 +02:00
|
|
|
: raw[type].diffs.renote,
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
color: colors.green,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Replies",
|
|
|
|
type: "area",
|
|
|
|
data: format(
|
|
|
|
type === "combined"
|
|
|
|
? sum(raw.local.diffs.reply, raw.remote.diffs.reply)
|
2023-07-06 03:28:27 +02:00
|
|
|
: raw[type].diffs.reply,
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
color: colors.yellow,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Normal",
|
|
|
|
type: "area",
|
|
|
|
data: format(
|
|
|
|
type === "combined"
|
|
|
|
? sum(raw.local.diffs.normal, raw.remote.diffs.normal)
|
2023-07-06 03:28:27 +02:00
|
|
|
: raw[type].diffs.normal,
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
color: colors.blue,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "With file",
|
|
|
|
type: "area",
|
|
|
|
data: format(
|
|
|
|
type === "combined"
|
|
|
|
? sum(
|
|
|
|
raw.local.diffs.withFile,
|
2023-07-06 03:28:27 +02:00
|
|
|
raw.remote.diffs.withFile,
|
2023-04-08 02:01:42 +02:00
|
|
|
)
|
2023-07-06 03:28:27 +02:00
|
|
|
: raw[type].diffs.withFile,
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
color: colors.purple,
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchNotesTotalChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/notes", {
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Combined",
|
|
|
|
type: "line",
|
|
|
|
data: format(sum(raw.local.total, raw.remote.total)),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Local",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.local.total),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Remote",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.remote.total),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchUsersChart = async (total: boolean): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/users", {
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Combined",
|
|
|
|
type: "line",
|
|
|
|
data: format(
|
|
|
|
total
|
|
|
|
? sum(raw.local.total, raw.remote.total)
|
|
|
|
: sum(
|
|
|
|
raw.local.inc,
|
|
|
|
negate(raw.local.dec),
|
|
|
|
raw.remote.inc,
|
2023-07-06 03:28:27 +02:00
|
|
|
negate(raw.remote.dec),
|
|
|
|
),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Local",
|
|
|
|
type: "area",
|
|
|
|
data: format(
|
|
|
|
total
|
|
|
|
? raw.local.total
|
2023-07-06 03:28:27 +02:00
|
|
|
: sum(raw.local.inc, negate(raw.local.dec)),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Remote",
|
|
|
|
type: "area",
|
|
|
|
data: format(
|
|
|
|
total
|
|
|
|
? raw.remote.total
|
2023-07-06 03:28:27 +02:00
|
|
|
: sum(raw.remote.inc, negate(raw.remote.dec)),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchActiveUsersChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/active-users", {
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Read & Write",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.readWrite),
|
|
|
|
color: colors.orange,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Write",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.write),
|
|
|
|
color: colors.lime,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Read",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.read),
|
|
|
|
color: colors.blue,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "< Week",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.registeredWithinWeek),
|
|
|
|
color: colors.green,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "< Month",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.registeredWithinMonth),
|
|
|
|
color: colors.yellow,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "< Year",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.registeredWithinYear),
|
|
|
|
color: colors.red,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "> Week",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.registeredOutsideWeek),
|
|
|
|
color: colors.yellow,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "> Month",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.registeredOutsideMonth),
|
|
|
|
color: colors.red,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "> Year",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.registeredOutsideYear),
|
|
|
|
color: colors.purple,
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchDriveChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/drive", {
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
|
|
|
bytes: true,
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "All",
|
|
|
|
type: "line",
|
|
|
|
dashed: true,
|
|
|
|
data: format(
|
|
|
|
sum(
|
|
|
|
raw.local.incSize,
|
|
|
|
negate(raw.local.decSize),
|
|
|
|
raw.remote.incSize,
|
2023-07-06 03:28:27 +02:00
|
|
|
negate(raw.remote.decSize),
|
|
|
|
),
|
2022-06-20 10:38:49 +02:00
|
|
|
),
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Local +",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.local.incSize),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Local -",
|
|
|
|
type: "area",
|
|
|
|
data: format(negate(raw.local.decSize)),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Remote +",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.remote.incSize),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Remote -",
|
|
|
|
type: "area",
|
|
|
|
data: format(negate(raw.remote.decSize)),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchDriveFilesChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/drive", {
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "All",
|
|
|
|
type: "line",
|
|
|
|
dashed: true,
|
|
|
|
data: format(
|
|
|
|
sum(
|
|
|
|
raw.local.incCount,
|
|
|
|
negate(raw.local.decCount),
|
|
|
|
raw.remote.incCount,
|
2023-07-06 03:28:27 +02:00
|
|
|
negate(raw.remote.decCount),
|
|
|
|
),
|
2022-06-20 10:38:49 +02:00
|
|
|
),
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Local +",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.local.incCount),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Local -",
|
|
|
|
type: "area",
|
|
|
|
data: format(negate(raw.local.decCount)),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Remote +",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.remote.incCount),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Remote -",
|
|
|
|
type: "area",
|
|
|
|
data: format(negate(raw.remote.decCount)),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchInstanceRequestsChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/instance", {
|
|
|
|
host: props.args.host,
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "In",
|
|
|
|
type: "area",
|
|
|
|
color: "#31748f",
|
|
|
|
data: format(raw.requests.received),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Out (succ)",
|
|
|
|
type: "area",
|
|
|
|
color: "#c4a7e7",
|
|
|
|
data: format(raw.requests.succeeded),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Out (fail)",
|
|
|
|
type: "area",
|
|
|
|
color: "#f6c177",
|
|
|
|
data: format(raw.requests.failed),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const fetchInstanceUsersChart = async (
|
2023-07-06 03:28:27 +02:00
|
|
|
total: boolean,
|
2023-04-08 02:01:42 +02:00
|
|
|
): Promise<typeof chartData> => {
|
|
|
|
const raw = await os.apiGet("charts/instance", {
|
|
|
|
host: props.args.host,
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Users",
|
|
|
|
type: "area",
|
|
|
|
color: "#31748f",
|
|
|
|
data: format(
|
|
|
|
total
|
|
|
|
? raw.users.total
|
2023-07-06 03:28:27 +02:00
|
|
|
: sum(raw.users.inc, negate(raw.users.dec)),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const fetchInstanceNotesChart = async (
|
2023-07-06 03:28:27 +02:00
|
|
|
total: boolean,
|
2023-04-08 02:01:42 +02:00
|
|
|
): Promise<typeof chartData> => {
|
|
|
|
const raw = await os.apiGet("charts/instance", {
|
|
|
|
host: props.args.host,
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Posts",
|
|
|
|
type: "area",
|
|
|
|
color: "#31748f",
|
|
|
|
data: format(
|
|
|
|
total
|
|
|
|
? raw.notes.total
|
2023-07-06 03:28:27 +02:00
|
|
|
: sum(raw.notes.inc, negate(raw.notes.dec)),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const fetchInstanceFfChart = async (
|
2023-07-06 03:28:27 +02:00
|
|
|
total: boolean,
|
2023-04-08 02:01:42 +02:00
|
|
|
): Promise<typeof chartData> => {
|
|
|
|
const raw = await os.apiGet("charts/instance", {
|
|
|
|
host: props.args.host,
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Following",
|
|
|
|
type: "area",
|
|
|
|
color: "#31748f",
|
|
|
|
data: format(
|
|
|
|
total
|
|
|
|
? raw.following.total
|
2023-07-06 03:28:27 +02:00
|
|
|
: sum(raw.following.inc, negate(raw.following.dec)),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Followers",
|
|
|
|
type: "area",
|
|
|
|
color: "#c4a7e7",
|
|
|
|
data: format(
|
|
|
|
total
|
|
|
|
? raw.followers.total
|
2023-07-06 03:28:27 +02:00
|
|
|
: sum(raw.followers.inc, negate(raw.followers.dec)),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const fetchInstanceDriveUsageChart = async (
|
2023-07-06 03:28:27 +02:00
|
|
|
total: boolean,
|
2023-04-08 02:01:42 +02:00
|
|
|
): Promise<typeof chartData> => {
|
|
|
|
const raw = await os.apiGet("charts/instance", {
|
|
|
|
host: props.args.host,
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
|
|
|
bytes: true,
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Drive usage",
|
|
|
|
type: "area",
|
|
|
|
color: "#31748f",
|
|
|
|
data: format(
|
|
|
|
total
|
|
|
|
? raw.drive.totalUsage
|
2023-07-06 03:28:27 +02:00
|
|
|
: sum(raw.drive.incUsage, negate(raw.drive.decUsage)),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const fetchInstanceDriveFilesChart = async (
|
2023-07-06 03:28:27 +02:00
|
|
|
total: boolean,
|
2023-04-08 02:01:42 +02:00
|
|
|
): Promise<typeof chartData> => {
|
|
|
|
const raw = await os.apiGet("charts/instance", {
|
|
|
|
host: props.args.host,
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Drive files",
|
|
|
|
type: "area",
|
|
|
|
color: "#31748f",
|
|
|
|
data: format(
|
|
|
|
total
|
|
|
|
? raw.drive.totalFiles
|
2023-07-06 03:28:27 +02:00
|
|
|
: sum(raw.drive.incFiles, negate(raw.drive.decFiles)),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchPerUserNotesChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/user/notes", {
|
|
|
|
userId: props.args.user.id,
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
...(props.args.withoutAll
|
|
|
|
? []
|
|
|
|
: [
|
|
|
|
{
|
|
|
|
name: "All",
|
|
|
|
type: "line",
|
|
|
|
data: format(sum(raw.inc, negate(raw.dec))),
|
|
|
|
color: "#888888",
|
|
|
|
},
|
|
|
|
]),
|
|
|
|
{
|
|
|
|
name: "With file",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.diffs.withFile),
|
|
|
|
color: colors.purple,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Renotes",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.diffs.renote),
|
|
|
|
color: colors.green,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Replies",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.diffs.reply),
|
|
|
|
color: colors.yellow,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Normal",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.diffs.normal),
|
|
|
|
color: colors.blue,
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchPerUserFollowingChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/user/following", {
|
|
|
|
userId: props.args.user.id,
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Local",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.local.followings.total),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Remote",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.remote.followings.total),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchPerUserFollowersChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/user/following", {
|
|
|
|
userId: props.args.user.id,
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Local",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.local.followers.total),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Remote",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.remote.followers.total),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchPerUserDriveChart = async (): Promise<typeof chartData> => {
|
2023-04-08 02:01:42 +02:00
|
|
|
const raw = await os.apiGet("charts/user/drive", {
|
|
|
|
userId: props.args.user.id,
|
|
|
|
limit: props.limit,
|
|
|
|
span: props.span,
|
|
|
|
});
|
2022-05-14 14:20:41 +02:00
|
|
|
return {
|
2023-04-08 02:01:42 +02:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: "Inc",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.incSize),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Dec",
|
|
|
|
type: "area",
|
|
|
|
data: format(raw.decSize),
|
|
|
|
},
|
|
|
|
],
|
2022-05-14 14:20:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const fetchAndRender = async () => {
|
|
|
|
const fetchData = () => {
|
|
|
|
switch (props.src) {
|
2023-04-08 02:01:42 +02:00
|
|
|
case "federation":
|
|
|
|
return fetchFederationChart();
|
|
|
|
case "ap-request":
|
|
|
|
return fetchApRequestChart();
|
|
|
|
case "users":
|
|
|
|
return fetchUsersChart(false);
|
|
|
|
case "users-total":
|
|
|
|
return fetchUsersChart(true);
|
|
|
|
case "active-users":
|
|
|
|
return fetchActiveUsersChart();
|
|
|
|
case "notes":
|
|
|
|
return fetchNotesChart("combined");
|
|
|
|
case "local-notes":
|
|
|
|
return fetchNotesChart("local");
|
|
|
|
case "remote-notes":
|
|
|
|
return fetchNotesChart("remote");
|
|
|
|
case "notes-total":
|
|
|
|
return fetchNotesTotalChart();
|
|
|
|
case "drive":
|
|
|
|
return fetchDriveChart();
|
|
|
|
case "drive-files":
|
|
|
|
return fetchDriveFilesChart();
|
|
|
|
case "instance-requests":
|
|
|
|
return fetchInstanceRequestsChart();
|
|
|
|
case "instance-users":
|
|
|
|
return fetchInstanceUsersChart(false);
|
|
|
|
case "instance-users-total":
|
|
|
|
return fetchInstanceUsersChart(true);
|
|
|
|
case "instance-notes":
|
|
|
|
return fetchInstanceNotesChart(false);
|
|
|
|
case "instance-notes-total":
|
|
|
|
return fetchInstanceNotesChart(true);
|
|
|
|
case "instance-ff":
|
|
|
|
return fetchInstanceFfChart(false);
|
|
|
|
case "instance-ff-total":
|
|
|
|
return fetchInstanceFfChart(true);
|
|
|
|
case "instance-drive-usage":
|
|
|
|
return fetchInstanceDriveUsageChart(false);
|
|
|
|
case "instance-drive-usage-total":
|
|
|
|
return fetchInstanceDriveUsageChart(true);
|
|
|
|
case "instance-drive-files":
|
|
|
|
return fetchInstanceDriveFilesChart(false);
|
|
|
|
case "instance-drive-files-total":
|
|
|
|
return fetchInstanceDriveFilesChart(true);
|
|
|
|
|
|
|
|
case "per-user-notes":
|
|
|
|
return fetchPerUserNotesChart();
|
|
|
|
case "per-user-following":
|
|
|
|
return fetchPerUserFollowingChart();
|
|
|
|
case "per-user-followers":
|
|
|
|
return fetchPerUserFollowersChart();
|
|
|
|
case "per-user-drive":
|
|
|
|
return fetchPerUserDriveChart();
|
2022-05-14 14:20:41 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
fetching.value = true;
|
|
|
|
chartData = await fetchData();
|
|
|
|
fetching.value = false;
|
|
|
|
render();
|
|
|
|
};
|
|
|
|
|
|
|
|
watch(() => [props.src, props.span], fetchAndRender);
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
fetchAndRender();
|
|
|
|
});
|
2021-10-21 22:36:48 +02:00
|
|
|
</script>
|
2021-10-23 04:34:41 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.cbbedffa {
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
> .fetching {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
-webkit-backdrop-filter: var(--blur, blur(12px));
|
|
|
|
backdrop-filter: var(--blur, blur(12px));
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
cursor: wait;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|