pissang commented on a change in pull request #14214: URL: https://github.com/apache/echarts/pull/14214#discussion_r571347295
########## File path: src/component/tooltip/TooltipHTMLContent.ts ########## @@ -358,6 +358,34 @@ class TooltipHTMLContent { + `border-color: ${nearPointColor};` + (tooltipModel.get('extraCssText') || ''); + const userWidth = tooltipModel.get(['textStyle', 'width']); + if (userWidth != null) { + el.style.cssText += `;width:${userWidth}px;`; + // `text-overflow_string` has very humble compatibility + // shttps://caniuse.com/mdn-css_properties_text-overflow_string + const ellipsis = tooltipModel.get(['textStyle', 'ellipsis']); + const userOverflow = tooltipModel.get(['textStyle', 'overflow']); + switch (userOverflow) { + case 'truncate': + el.style.cssText += ';overflow:hidden;' + + `text-overflow:${ellipsis != null ? `\'${ellipsis}\'` : 'ellipsis'};` + + 'white-space:nowrap;'; + break; + + case 'break': + el.style.cssText += ';word-break:break-word;white-space:normal;'; + break; + + case 'breakAll': + el.style.cssText += ';word-break:break-all;white-space:normal;'; + break; + + default: + el.style.cssText += ''; + break; + } + } Review comment: My humble option: `switch...case...` and `if...else...` has minor performance in most cases. I think they both OK. Code size and readability are the main concerns in this case. I will prefer @plainheart solution. It reduces much redundant strings and is clear enough from my side. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org For additional commands, e-mail: commits-h...@echarts.apache.org