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 2022/06/15 06:51:42 UTC

[GitHub] [echarts] jiawulin001 commented on issue #17162: [Bug] horizontal label margin (distance) in vertical marklines not working

jiawulin001 commented on issue #17162:
URL: https://github.com/apache/echarts/issues/17162#issuecomment-1156058183

   ### Conclusion
   `distance` and `offset` has almost the same function and `offset` works well with any direction. I would suggest use `offset` only and delete `distance` as an API for user.
   Of course if you want to know why problem exists for `distance`, keep reading.
   
   <details>
   <summary>
   Problem Location
   </summary>
   
   The place where the position of label is determined is as followed:
   https://github.com/apache/echarts/blob/11a9247e7fab2e6ff9c60b545ba775e8c1b2412f/src/chart/helper/Line.ts#L449-L454
   Here `distanceX/Y` is literally the user-specified `distance` and they are multiplied by `d[0]/d[1]`. `d` is derived here:
   https://github.com/apache/echarts/blob/11a9247e7fab2e6ff9c60b545ba775e8c1b2412f/src/chart/helper/Line.ts#L365-L366
   `toPos` and `fromPos` is the starting point and ending point of the line and `d` means whether they have differences on x or y coordinates. For example, d=[0,1] if the line is parallel to y axis and point at positive direction. Now that explains why `distanceX` won't work at `label.x` because d[0] = 0 and it deactivate the effect of `distanceX`.
   </details>
   
   I would submit a PR to **either delete the `distance` API, or fix `distance` API**. I consider the former one better because these two APIs are functionally replicate.
   
   


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