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/11 06:08:59 UTC

[GitHub] [echarts] pissang commented on issue #15832: Render custom bar plot with log scale

pissang commented on issue #15832:
URL: https://github.com/apache/echarts/issues/15832#issuecomment-939710508


   @nhhaidee Hi, `api.size` is not usable in the non-linear axis like `log`. The description of `api.size` can be checked at https://echarts.apache.org/en/option.html#series-custom.renderItem.arguments.api.size. 
   
   The underlying logic of `api.size` is quite simple:
   ```ts
   const p0 = api.coord([arbitraryX, arbitrary]);
   const p1 = api.coord([arbitraryX + size[0], arbitrary + size[1]])
   return [p1[0] - p0[0], p1[1] - p0[1]];
   ```
   
   So it's more like a utility method that assumes the axis is linear. For the non-linear axis, the returned size will depends on the picked `[arbitraryX, arbitrary]`. So this method becomes meaningless in this case.
   
   To fix this issue, ss you can see, you can always use `api.coord` to calculate the size of rectangle:
   
   ```ts
   var start = api.coord([api.value(0), api.value(2)]);
   var end = api.coord([api.value(1), 1]); 
   return {
             type: "rect",
             shape: {
               x: start[0],
               y: start[1],
               width: end[0] - start[0],
               height: end[1] - start[1]
             },
             style: api.style()
           };
   ```
   
   We will improve the doc to explain this point.


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