Skip to content

Instantly share code, notes, and snippets.

@russelllim22
Last active December 27, 2021 19:59
Show Gist options
  • Save russelllim22/d5c098c175e01d6ed7b29e91c9d70670 to your computer and use it in GitHub Desktop.
Save russelllim22/d5c098c175e01d6ed7b29e91c9d70670 to your computer and use it in GitHub Desktop.
<svg id="chartSVG" viewBox="0,0,1000,2000">
<image width="1000px" height="2000px" style="opacity:0.2;" href="/babies-pixabay.png">
</image>
{#if letterCounts.length > 0}
{#each letterCounts as d, i}
<rect x = 0 y = {yScale(d.letter)} width = {xScale(d.count)} height = {yScale.bandwidth()}
in:fly="{{ x: -1000, duration: 1000, delay: 1000*i}}"></rect>
<text class="bar-label" x = {xScale(d.count) + 15} y = {yScale(d.letter) + yScale.bandwidth()/2}
in:fly="{{ x: -1000, duration: 1000, delay: 1000 * i }}">
{d.letter}: ({Math.round(d.count / totalBabies * 100)}%)
</text>
{/each}
{/if}
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment