Skip to content

Instantly share code, notes, and snippets.

@bmorelli25
Created July 25, 2017 16:42
Show Gist options
  • Save bmorelli25/cf942a44dc03ed1fd006702a82084d62 to your computer and use it in GitHub Desktop.
Save bmorelli25/cf942a44dc03ed1fd006702a82084d62 to your computer and use it in GitHub Desktop.
const svgLocation = document.getElementsByClassName("linechart")[0].getBoundingClientRect();
const adjustment = (svgLocation.width - svgWidth) / 2; //takes padding into consideration
const relativeLoc = e.clientX - svgLocation.left - adjustment;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment