Skip to content

Commit

Permalink
Fixed #5261, break at the end of a label caused wrong bounding box.
Browse files Browse the repository at this point in the history
  • Loading branch information
TorsteinHonsi committed Apr 29, 2016
1 parent 647c4ae commit fa85db5
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 16 deletions.
8 changes: 4 additions & 4 deletions js/highcharts.src.js
Expand Up @@ -3529,10 +3529,10 @@
}


// remove empty line at end
if (lines[lines.length - 1] === '') {
lines.pop();
}
// Trim empty lines (#5261)
lines = grep(lines, function (line) {
return line !== '';
});


// build the lines
Expand Down
8 changes: 4 additions & 4 deletions js/highmaps.src.js
Expand Up @@ -3527,10 +3527,10 @@
}


// remove empty line at end
if (lines[lines.length - 1] === '') {
lines.pop();
}
// Trim empty lines (#5261)
lines = grep(lines, function (line) {
return line !== '';
});


// build the lines
Expand Down
8 changes: 4 additions & 4 deletions js/highstock.src.js
Expand Up @@ -3529,10 +3529,10 @@
}


// remove empty line at end
if (lines[lines.length - 1] === '') {
lines.pop();
}
// Trim empty lines (#5261)
lines = grep(lines, function (line) {
return line !== '';
});


// build the lines
Expand Down
8 changes: 4 additions & 4 deletions js/parts/SvgRenderer.js
Expand Up @@ -1459,10 +1459,10 @@ SVGRenderer.prototype = {
}


// remove empty line at end
if (lines[lines.length - 1] === '') {
lines.pop();
}
// Trim empty lines (#5261)
lines = grep(lines, function (line) {
return line !== '';
});


// build the lines
Expand Down
@@ -0,0 +1,5 @@
---
resources:
- https://code.jquery.com/qunit/qunit-1.19.0.js
- https://code.jquery.com/qunit/qunit-1.19.0.css
...
@@ -0,0 +1,9 @@
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/heatmap.js"></script>

<div id="qunit"></div>
<div id="qunit-fixture"></div>


<div id="container" style="width: 1000px; margin: 0 auto;"></div>
<div id="exported"></div>
48 changes: 48 additions & 0 deletions samples/issues/highcharts-4.2.4/5261-label-trim-lines/demo.js
@@ -0,0 +1,48 @@
jQuery(function () {

QUnit.test('Left trim', function (assert) {

var ren = new Highcharts.Renderer(
document.getElementById('container'),
500,
300
);

var correctLabel = ren.label('Hello World', 100, 25)
.attr({
'stroke-width': 1,
stroke: 'blue'
})
.add();


var label = ren.label('<br>Hello World', 100, 50)
.attr({
'stroke-width': 1,
stroke: 'blue'
})
.add();

// tspan.dy should be the same as the reference
assert.strictEqual(
label.element.querySelector('tspan').getAttribute('dy'),
correctLabel.element.querySelector('tspan').getAttribute('dy'),
'Tspan dy offset'
);


label = ren.label('Hello World<br>', 100, 50)
.attr({
'stroke-width': 1,
stroke: 'blue'
})
.add();

// tspan.dy should be the same as the reference
assert.strictEqual(
label.element.querySelector('tspan').getAttribute('dy'),
correctLabel.element.querySelector('tspan').getAttribute('dy'),
'Tspan dy offset'
);
});
});

0 comments on commit fa85db5

Please sign in to comment.