Skip to content

Commit

Permalink
Multiline edge labels throw an exception #2386
Browse files Browse the repository at this point in the history
`labelLineHeight` must be prefixed like other label values, because of source and target labels.  Using multiline labels for source and target sides of an edge doesn't generally make sense, but this change is necessary for the value for the main edge label to be distinct from the others.  This issue is caused by the addition of the line-height style property #2115.
  • Loading branch information
maxkfranz committed May 8, 2019
1 parent 3942e51 commit ac8a9c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/extensions/renderer/base/coord-ele-math/labels.js
Expand Up @@ -301,7 +301,8 @@ BRp.applyPrefixedLabelDimensions = function( ele, prefix ){
let labelDims = this.calculateLabelDimensions( ele, text );
let lineHeight = ele.pstyle('line-height').pfValue;
let textWrap = ele.pstyle('text-wrap').strValue;
let numLines = textWrap !== 'wrap' ? 1 : (util.getPrefixedProperty( _p.rscratch, 'labelWrapCachedLines', prefix ).length || 1);
let lines = util.getPrefixedProperty( _p.rscratch, 'labelWrapCachedLines', prefix ) || [];
let numLines = textWrap !== 'wrap' ? 1 : Math.max(lines.length, 1);
let normPerLineHeight = labelDims.height / numLines;
let labelLineHeight = normPerLineHeight * lineHeight;

Expand All @@ -314,7 +315,7 @@ BRp.applyPrefixedLabelDimensions = function( ele, prefix ){
util.setPrefixedProperty( _p.rstyle, 'labelHeight', prefix, height );
util.setPrefixedProperty( _p.rscratch, 'labelHeight', prefix, height );

_p.rscratch.labelLineHeight = labelLineHeight;
util.setPrefixedProperty( _p.rscratch, 'labelLineHeight', prefix, labelLineHeight );
};

BRp.getLabelText = function( ele, prefix ){
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/renderer/canvas/drawing-label-text.js
Expand Up @@ -319,7 +319,7 @@ CRp.drawText = function( context, ele, prefix, applyRotation = true, useEleOpaci

if( ele.pstyle( 'text-wrap' ).value === 'wrap' ){
let lines = util.getPrefixedProperty( rscratch, 'labelWrapCachedLines', prefix );
let lineHeight = _p.rscratch.labelLineHeight;
let lineHeight = util.getPrefixedProperty( rscratch, 'labelLineHeight', prefix );
let halfTextW = textW/2;
let justification = this.getLabelJustification(ele);

Expand Down

0 comments on commit ac8a9c0

Please sign in to comment.