diff --git a/src/marks/tip.js b/src/marks/tip.js index b745084d65..78a75cdfb5 100644 --- a/src/marks/tip.js +++ b/src/marks/tip.js @@ -241,6 +241,7 @@ export class Tip extends Mark { text.setAttribute("y", `${+getLineOffset(a, text.childNodes.length, lineHeight).toFixed(6)}em`); text.setAttribute("transform", `translate(${getTextTranslate(a, m, r, w, h)})`); }); + g.attr("visibility", null); } // Wait until the plot is inserted into the page so that we can use getBBox @@ -250,8 +251,11 @@ export class Tip extends Mark { // this step. Perhaps this could be done synchronously; getting the // dimensions of the SVG is easy, and although accurate text metrics are // hard, we could use approximate heuristics. - if (svg.isConnected) Promise.resolve().then(postrender); - else if (typeof requestAnimationFrame !== "undefined") requestAnimationFrame(postrender); + if (index.length) { + g.attr("visibility", "hidden"); // hide until postrender + if (svg.isConnected) Promise.resolve().then(postrender); + else if (typeof requestAnimationFrame !== "undefined") requestAnimationFrame(postrender); + } return g.node(); } diff --git a/test/output/tipNewLines.svg b/test/output/tipNewLines.svg index e2d2f65a39..19771e59d9 100644 --- a/test/output/tipNewLines.svg +++ b/test/output/tipNewLines.svg @@ -25,7 +25,7 @@ between no name - + ​Hello @@ -39,7 +39,7 @@ ​{​} - + a firstb secondx no name