I was having the same problem with ngbootstrap. It turns out that the tooltip creates a div, and if it is inside an svg, Angular will not render it. So my solution was to create a little html mask over the area of the svg where I wanted to trigger the tooltip.
HTML:
<div>
<svg>
<ellipse id="svg_2" cy="78.999999" cx="1042.499999" stroke-width="1.5" stroke="#000" fill="#fff"/>
</svg>
<div ngbTooltip="My tooltip" class="mytooltip" triggers="hover:blur click:blur focus:blur" [ngStyle]="{ 'left.px': leftPosition, 'top.px': topPosition }"></div>
</div>
Where leftPosition
and topPosition
are set dynamically in your ts
file.
SCSS/CSS:
.mytooltip {
position: absolute;
width: 10px; //whatever is a reasonable hit area
height: 10px;
}
If your svg element placement is not dynamic, then you could just put it all in the style sheet. In my case, I had multiple tooltips I needed to attach to elements with varying widths and positions. You could also drop the class and add all the styling to ngStyle
.
This method is probably not good for massively dynamic or interactive svgs, such as with D3.js, but that has it's own tooltip system anyway.