1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-15 01:05:42 +02:00
Files
misskey/packages/frontend/src/utility/chart-vline.ts
syuilo 41592eafb3 refactor: make noImplicitAny true (#17083)
* wip

* Update emojis.emoji.vue

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update manager.ts

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update analytics.ts
2026-01-09 22:06:40 +09:00

30 lines
753 B
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { Plugin } from 'chart.js';
export const chartVLine = (vLineColor: string) => ({
id: 'vLine',
beforeDraw(chart, args, options) {
const tooltip = chart.tooltip as any;
if (tooltip?._active?.length) {
const ctx = chart.ctx;
const xs = tooltip._active.map((a: any) => a.element.x) as number[];
const x = xs.reduce((a, b) => a + b, 0) / xs.length;
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();
}
},
}) as Plugin;