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/28 03:56:24 UTC

[GitHub] [echarts] Ovilia commented on a diff in pull request #17212: fix(axis): fix `axis.nameTextStyle.overflow` option not working

Ovilia commented on code in PR #17212:
URL: https://github.com/apache/echarts/pull/17212#discussion_r908005681


##########
src/component/axis/AxisBuilder.ts:
##########
@@ -420,10 +420,26 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu
 
         const textFont = textStyleModel.getFont();
 
+        const coordSysModel = axisModel.getCoordSysModel();
+        const coordSys = coordSysModel ? coordSysModel.coordinateSystem : null;
+
         const truncateOpt = axisModel.get('nameTruncate', true) || {};
-        const ellipsis = truncateOpt.ellipsis;
+        const ellipsis = textStyleModel.get('ellipsis') || truncateOpt.ellipsis;
+        const overflow = textStyleModel.get('overflow') || 'none';
+
+        let nameTruncateDefaultWidth;
+
+        if (overflow !== 'none') {
+            nameTruncateDefaultWidth = Math.abs(extent[1] - extent[0]); // Current axis length.
+            if (!isNameLocationCenter(nameLocation)) {
+                const rect = coordSys && coordSys.getRect && coordSys.getRect();
+                nameTruncateDefaultWidth = rect ? rect.width : nameTruncateDefaultWidth * 2;

Review Comment:
   It's odd to use `nameTruncateDefaultWidth * 2` because is this is assuming we are using polar coordinate. @pissang @100pah Please help further review this PR.



##########
src/component/axis/AxisBuilder.ts:
##########
@@ -420,10 +420,26 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu
 
         const textFont = textStyleModel.getFont();
 
+        const coordSysModel = axisModel.getCoordSysModel();
+        const coordSys = coordSysModel ? coordSysModel.coordinateSystem : null;
+
         const truncateOpt = axisModel.get('nameTruncate', true) || {};
-        const ellipsis = truncateOpt.ellipsis;
+        const ellipsis = textStyleModel.get('ellipsis') || truncateOpt.ellipsis;
+        const overflow = textStyleModel.get('overflow') || 'none';
+
+        let nameTruncateDefaultWidth;
+
+        if (overflow !== 'none') {
+            nameTruncateDefaultWidth = Math.abs(extent[1] - extent[0]); // Current axis length.
+            if (!isNameLocationCenter(nameLocation)) {

Review Comment:
   Why should centered name not using ellipsis?



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