chore(client): tweak ui

This commit is contained in:
syuilo
2022-06-30 22:02:08 +09:00
parent 4c2cd3c8d5
commit cb697cf582
3 changed files with 54 additions and 9 deletions

View File

@@ -45,7 +45,7 @@ Chart.register(
);
const props = defineProps<{
data: { name: string; value: number; color: string; }[];
data: { name: string; value: number; color: string; onClick?: () => void }[];
}>();
const chartEl = ref<HTMLCanvasElement>(null);
@@ -79,6 +79,12 @@ onMounted(() => {
bottom: 16,
},
},
onClick: (ev) => {
const hit = chartInstance.getElementsAtEventForMode(ev, 'nearest', { intersect: true }, false)[0];
if (hit && props.data[hit.index].onClick) {
props.data[hit.index].onClick();
}
},
plugins: {
legend: {
display: false,