You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/10/12 02:01:26 UTC

[GitHub] [echarts] plainheart edited a comment on issue #15858: how to change the Y axisLabel to base-10 exponential form ?

plainheart edited a comment on issue #15858:
URL: https://github.com/apache/echarts/issues/15858#issuecomment-940589952


   参见以下两种方式
   
   ```js
   // 使用预设字符
   const superscripts = ['⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹'];
   function getSuperScripts(val) {
     return (val + '')
       .split('')
       .map(t => superscripts[t])
       .join('');
   }
   
   // 使用 Unicode
   const superscriptsUnicode = ['B9', 'B2', 'B3'];
   function getSuperScripts2(val) {
     return (val + '')
       .split('')
       .map(t => String.fromCharCode('0x' + (t > 0 && t < 4 ? '00' + superscriptsUnicode[t - 1] : '207' + t)))
       .join('');
   }
   ```
   
   然后 ECharts 添加 `axisLabel` 配置
   
   ```js
   axisLabel: {
       formatter: (val) => {
         // 2 为底数 val 为指数
        // getSuperScripts 或 getSuperScripts2 均可
         return '2' + getSuperScripts2(val);
       }
   }
   ```


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

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org