{#each barData as d, i (d.label)} selectedIndex = selectedIndex === i ? -1 : i} on:mouseenter={() => hoveredIndex = i} on:mouseleave={() => hoveredIndex = -1} /> MIN_LABEL_WIDTH ? xScale(d.count) - 5 : xScale(d.count) + 5} y={i * barHeight + (barHeight - 5) / 2} text-anchor={xScale(d.count) > MIN_LABEL_WIDTH ? "end" : "start"} fill={xScale(d.count) > MIN_LABEL_WIDTH ? "white" : "black"} > {d.label}: {d.count} {/each}