Skip to content

Commit

Permalink
Fixed #5689, text had soft line wraps when white-space: nowrap was us…
Browse files Browse the repository at this point in the history
…ed in combination with text-overflow: ellipsis.
  • Loading branch information
TorsteinHonsi committed Sep 15, 2016
1 parent f0c9389 commit 6a1fac2
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 8 deletions.
5 changes: 3 additions & 2 deletions js/highcharts.src.js
Expand Up @@ -3682,7 +3682,8 @@
// Check width and apply soft breaks or ellipsis
if (width) {
var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && textStyles.whiteSpace !== 'nowrap'),
noWrap = textStyles.whiteSpace === 'nowrap',
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && !noWrap),
tooLong,
actualWidth,
rest = [],
Expand Down Expand Up @@ -3726,7 +3727,7 @@
words = rest;
rest = [];

if (words.length) {
if (words.length && !noWrap) {
softLineNo++;

tspan = doc.createElementNS(SVG_NS, 'tspan');
Expand Down
5 changes: 3 additions & 2 deletions js/highmaps.src.js
Expand Up @@ -3680,7 +3680,8 @@
// Check width and apply soft breaks or ellipsis
if (width) {
var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && textStyles.whiteSpace !== 'nowrap'),
noWrap = textStyles.whiteSpace === 'nowrap',
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && !noWrap),
tooLong,
actualWidth,
rest = [],
Expand Down Expand Up @@ -3724,7 +3725,7 @@
words = rest;
rest = [];

if (words.length) {
if (words.length && !noWrap) {
softLineNo++;

tspan = doc.createElementNS(SVG_NS, 'tspan');
Expand Down
5 changes: 3 additions & 2 deletions js/highstock.src.js
Expand Up @@ -3682,7 +3682,8 @@
// Check width and apply soft breaks or ellipsis
if (width) {
var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && textStyles.whiteSpace !== 'nowrap'),
noWrap = textStyles.whiteSpace === 'nowrap',
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && !noWrap),
tooLong,
actualWidth,
rest = [],
Expand Down Expand Up @@ -3726,7 +3727,7 @@
words = rest;
rest = [];

if (words.length) {
if (words.length && !noWrap) {
softLineNo++;

tspan = doc.createElementNS(SVG_NS, 'tspan');
Expand Down
5 changes: 3 additions & 2 deletions js/parts/SvgRenderer.js
Expand Up @@ -1540,7 +1540,8 @@ SVGRenderer.prototype = {
// Check width and apply soft breaks or ellipsis
if (width) {
var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && textStyles.whiteSpace !== 'nowrap'),
noWrap = textStyles.whiteSpace === 'nowrap',
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && !noWrap),
tooLong,
actualWidth,
rest = [],
Expand Down Expand Up @@ -1584,7 +1585,7 @@ SVGRenderer.prototype = {
words = rest;
rest = [];

if (words.length) {
if (words.length && !noWrap) {
softLineNo++;

tspan = doc.createElementNS(SVG_NS, 'tspan');
Expand Down
Empty file.
@@ -0,0 +1,4 @@
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>

<div id="container"></div>
@@ -0,0 +1,31 @@
$(function () {

var category = "first first first first first first first <br/> second second second <br/> third third third third";

$('#container').highcharts({
"title": {
"text": "'first', 'second', and 'third', should be on their own individual lines"
},
"chart": {
"polar": true
},
"series": [{
"data": [5, 4, 2, 6, 7, 8]
}],
"xAxis": {
"labels": {
"style": {
"whiteSpace": "nowrap"
}
},
"categories": [
category,
category,
category,
category,
category,
category
]
}
});
});

0 comments on commit 6a1fac2

Please sign in to comment.