Merge pull request #116 from bob2402/pie-slice

problem: merits chart slice remains active after mouseout
This commit is contained in:
gsovereignty
2024-08-20 21:37:55 +08:00
committed by GitHub

View File

@@ -127,14 +127,26 @@
});
}
$: {
if (chartInstance && hoveredPubkey !== null) {
const index = data.findIndex((item) => item.pubkey === hoveredPubkey);
let prehoverdPubkey: string | null = null;
$: if (chartInstance) {
if (hoveredPubkey !== null) {
selectSlice(hoveredPubkey);
prehoverdPubkey = hoveredPubkey;
} else {
if (prehoverdPubkey) {
selectSlice(prehoverdPubkey);
prehoverdPubkey = null;
}
}
}
function selectSlice(pubkey: string) {
const index = data.findIndex((item) => item.pubkey === pubkey);
if (index !== -1) {
chartInstance.toggleDataPointSelection(index);
}
}
}
</script>
<div class="relative h-full w-full">