Skip to content

Instantly share code, notes, and snippets.

@pzi
Created September 22, 2015 01:39
Show Gist options
  • Save pzi/b493d216d1d86053485e to your computer and use it in GitHub Desktop.
Save pzi/b493d216d1d86053485e to your computer and use it in GitHub Desktop.
// this = marker under mouse
const matrix = this.getScreenCTM()
.translate(+this.getAttribute('cx'), +this.getAttribute('cy'));
const graphDiv = document.getElementById(graphOptions.chart.id).getBoundingClientRect();
let tooltTipLeftpx = matrix.e - graphDiv.left;
if (tooltTipLeftpx > (graphOptions.chart.width - (graphOptions.chart.padding * 1.5))) {
tooltTipLeftpx -= graphOptions.chart.padding * 2;
}
tooltip.style({
'left': `${tooltTipLeftpx}px`,
'top': `${matrix.f - graphDiv.top}px`
});
@pzi
Copy link
Author

pzi commented Sep 22, 2015

Note: I am using a div outside the svg as a tooltip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment