Skip to content

Instantly share code, notes, and snippets.

@nautilytics
Created January 29, 2020 21:48
Show Gist options
  • Save nautilytics/a183f9603ae4755294cd539558960e9f to your computer and use it in GitHub Desktop.
Save nautilytics/a183f9603ae4755294cd539558960e9f to your computer and use it in GitHub Desktop.
An SVG Mask for interactive mouse events on an area chart
<svg width="100%" height="100%">
<defs>
<mask
id='mask-for-area-chart'
maskUnits="userSpaceOnUse"
maskContentUnits="userSpaceOnUse">
<path d="M0Z" style="fill: white;">
</path>
</g>
</mask>
</defs>
<rect
mask='url(#mask-for-area-chart)'
style="fill: steelblue;"
width="100%"
height="100%">
</rect>
<g>
<rect
mask='url(#mask-for-area-chart)'
style="fill: green;"
x="selectedItem.x"
height="100%"
width="barWidth">
</rect>
</g>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment