diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-01-03 14:08:52 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-01-03 14:08:52 +0900 |
| commit | fb05e86db72740933292f105da3fce43b8fafb1f (patch) | |
| tree | 350c5e7f18444a9fbcc46088d3ffaee3a09e43a6 /packages/frontend/src/scripts | |
| parent | perf(client): use shallowRef instead of ref for template reference (diff) | |
| download | misskey-fb05e86db72740933292f105da3fce43b8fafb1f.tar.gz misskey-fb05e86db72740933292f105da3fce43b8fafb1f.tar.bz2 misskey-fb05e86db72740933292f105da3fce43b8fafb1f.zip | |
:art:
Diffstat (limited to 'packages/frontend/src/scripts')
| -rw-r--r-- | packages/frontend/src/scripts/chart-legend.ts | 12 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/chart-vline.ts | 4 |
2 files changed, 15 insertions, 1 deletions
diff --git a/packages/frontend/src/scripts/chart-legend.ts b/packages/frontend/src/scripts/chart-legend.ts new file mode 100644 index 0000000000..6a5370cc87 --- /dev/null +++ b/packages/frontend/src/scripts/chart-legend.ts @@ -0,0 +1,12 @@ +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; diff --git a/packages/frontend/src/scripts/chart-vline.ts b/packages/frontend/src/scripts/chart-vline.ts index 10021583e0..f321443834 100644 --- a/packages/frontend/src/scripts/chart-vline.ts +++ b/packages/frontend/src/scripts/chart-vline.ts @@ -1,3 +1,5 @@ +import { Plugin } from 'chart.js'; + export const chartVLine = (vLineColor: string) => ({ id: 'vLine', beforeDraw(chart, args, options) { @@ -18,4 +20,4 @@ export const chartVLine = (vLineColor: string) => ({ ctx.restore(); } }, -}); +}) as Plugin; |