1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-14 06:38:28 +09:00
cherrypick/packages/frontend/src/scripts/chart-legend.ts
2024-02-13 15:59:27 +00:00

18 lines
505 B
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { Plugin } from 'chart.js';
import MkChartLegend from '@/components/MkChartLegend.vue';
export const chartLegend = (legend: InstanceType<typeof MkChartLegend>) => ({
id: 'htmlLegend',
afterUpdate(chart, args, options) {
// Reuse the built-in legendItems generator
const items = chart.options.plugins.legend.labels.generateLabels(chart);
legend.update(chart, items);
},
}) as Plugin;