TheoXiong commented on issue #7479: echarts.format.truncateText
URL: 
https://github.com/apache/incubator-echarts/issues/7479#issuecomment-490782589
 
 
   查看源码,大概明白了,第二个参数应该是文本宽度(单位:像素px)。
   ```
   /**
    * Show ellipsis if overflow.
    *
    * @public
    * @param  {string} text
    * @param  {string} containerWidth
    * @param  {string} font
    * @param  {number} [ellipsis='...']
    * @param  {Object} [options]
    * @param  {number} [options.maxIterations=3]
    * @param  {number} [options.minChar=0] If truncate result are less
    *                  then minChar, ellipsis will not show, which is
    *                  better for user hint in some cases.
    * @param  {number} [options.placeholder=''] When all truncated, use the 
placeholder.
    * @return {string}
    */
   function truncateText(text, containerWidth, font, ellipsis, options) {
       if (!containerWidth) {
           return '';
       }
   
       var textLines = (text + '').split('\n');
       options = prepareTruncateOptions(containerWidth, font, ellipsis, 
options);
   
       // FIXME
       // It is not appropriate that every line has '...' when truncate 
multiple lines.
       for (var i = 0, len = textLines.length; i < len; i++) {
           textLines[i] = truncateSingleLine(textLines[i], options);
       }
   
       return textLines.join('\n');
   }
   
   
   /**
    * @public
    * @param {string} text
    * @param {string} font
    * @return {Object} width
    */
   function measureText(text, font) {
       return methods$1.measureText(text, font);
   }
   
   // Avoid assign to an exported variable, for transforming to cjs.
   methods$1.measureText = function (text, font) {
       var ctx = getContext();
       ctx.font = font || DEFAULT_FONT$1;
       return ctx.measureText(text);
   };
   
   ```
   
   

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to