problem: merits chart slice remains active after mouseout

resolve https://github.com/nostrocket/hypergolic/issues/115
This commit is contained in:
Bob
2024-08-20 17:58:06 +08:00
parent 6de9e2bfaa
commit f042e36ad9

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">