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/04/21 07:14:33 UTC

[GitHub] [echarts] pissang commented on a diff in pull request #16904: feat(View): `View` center suuport `string`

pissang commented on code in PR #16904:
URL: https://github.com/apache/echarts/pull/16904#discussion_r854858229


##########
src/coord/View.ts:
##########
@@ -127,11 +128,13 @@ class View extends Transformable implements CoordinateSystemMaster, CoordinateSy
     /**
      * Set center of view
      */
-    setCenter(centerCoord?: number[]): void {
+    setCenter(centerCoord?: (number | string)[]): void {
         if (!centerCoord) {
             return;
         }
-        this._center = centerCoord;
+        const rect = this.getBoundingRect();
+
+        this._center = [parsePercent(centerCoord[0], rect.width), parsePercent(centerCoord[1], rect.height)];

Review Comment:
   The percent value should be relative to the chart width and chart height. Which can be get with `api.getWidth` and `api.getHeight()`.



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