Skip to content

Commit

Permalink
Fixed #6144, empty categories caused wrong render of tooltip.
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperMadej committed Mar 22, 2017
1 parent d240fae commit 89537a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion js/parts/SvgRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,7 @@ SVGRenderer.prototype = {
noWrap = textStyles && textStyles.whiteSpace === 'nowrap',
fontSize = textStyles && textStyles.fontSize,
textCache,
isSubsequentLine,
i = childNodes.length,
tempParent = width && !wrapper.added && this.box,
getLineHeight = function (tspan) {
Expand Down Expand Up @@ -2238,7 +2239,7 @@ SVGRenderer.prototype = {
textNode.appendChild(tspan);

// first span on subsequent line, add the line height
if (!spanNo && lineNo) {
if (!spanNo && isSubsequentLine) {

// allow getting the right offset height in exporting in IE
if (!svg && forExport) {
Expand Down Expand Up @@ -2317,6 +2318,8 @@ SVGRenderer.prototype = {
}
}
});
// To avoid beginning lines that doesn't add to the textNode (#6144)
isSubsequentLine = isSubsequentLine || textNode.childNodes.length;
});

if (wasTooLong) {
Expand Down
22 changes: 22 additions & 0 deletions samples/unit-tests/svgrenderer/text/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,25 @@ QUnit.test('textOverflow: ellipsis.', function (assert) {
'Width was too small for ellipsis.'
);
});

QUnit.test('BBox for mulitiple lines', function (assert) {
var outerHTML,
chart = Highcharts.chart('container', {}, function(chart) {
var r = chart.renderer,
lab = r.label('<span></span><br/>line<br/>line', 20, 20)
.css({
color: '#f00'
})
.attr({
fill: 'rgba(0, 100, 0, 0.75)',
padding: 0
})
.add();
outerHTML = lab.text.element.children[0].outerHTML;
});

assert.ok(
!(/dy="\d/.test(outerHTML)),
"Frist line shouldn't have dy (#6144) - visually the red text fits in the green box."
);
});

0 comments on commit 89537a2

Please sign in to comment.