susiwen8 commented on a change in pull request #14214:
URL: https://github.com/apache/echarts/pull/14214#discussion_r570967291



##########
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:
       I have reservation on this, `swtich` makes code more readable when 
multiple conditional branch, but on the other hand `if else` has better 
performance. @plainheart 




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to