You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2018/08/15 03:49:13 UTC

[GitHub] LYlanfeng commented on issue #8791: 極坐標軸文字超過四字寬度,其他Lable消失BUG

LYlanfeng commented on issue #8791: 極坐標軸文字超過四字寬度,其他Lable消失BUG
URL: https://github.com/apache/incubator-echarts/issues/8791#issuecomment-413086195
 
 
   原因是找到了,就是下面代码造成的,修改源码是可以解决的,可以自己增加一个配置项目,然后修改源码。但是感觉这个应该属于一个bug吧,对于极坐标的类目计算有问题。
   ```javascript
   function calculateCategoryInterval() {
   //...
      var unitSpan = axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue);// 这个计算出来一直是40
   //dataToCoord 这个方式是说是序列尺,但是在这个图好像是否有问题。
       var unitW = Math.abs(unitSpan * Math.cos(rotation)); 
       var unitH = Math.abs(unitSpan * Math.sin(rotation)); // 这个会一直是0,导致下面计算是无穷大
   
       var maxW = 0;
       var maxH = 0;
   
       // Caution: Performance sensitive for large category data.
       // Consider dataZoom, we should make appropriate step to avoid O(n) loop.
       for (; tickValue <= ordinalExtent[1]; tickValue += step) {
           var width = 0;
           var height = 0;
   
           // Polar is also calculated in assumptive linear layout here.
           // Not precise, do not consider align and vertical align
           // and each distance from axis line yet.
           var rect = getBoundingRect(
               labelFormatter(tickValue), params.font, 'center', 'top'
           );
           // Magic number
           width = rect.width * 1.3;
           height = rect.height * 1.3;
   
           // Min size, void long loop.
           maxW = Math.max(maxW, width, 7);
           maxH = Math.max(maxH, height, 7);
       }
   
       var dw = maxW / unitW;
       var dh = maxH / unitH;
       // 0/0 is NaN, 1/0 is Infinity.
       isNaN(dw) && (dw = Infinity);
       isNaN(dh) && (dh = Infinity);
       var interval = Math.max(0, Math.floor(Math.min(dw, dh))); // 最终在这个地方取间隔就会出现问题
     // 在这个地方可以增加一个自己属性配置,而重置interval值为0
   //...
   }
   
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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