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 2020/06/24 00:28:29 UTC

[GitHub] [incubator-echarts] plainheart commented on a change in pull request #12758: fix(axisPointer): some properties of label in axisPointer are not working, fix #12642.

plainheart commented on a change in pull request #12758:
URL: https://github.com/apache/incubator-echarts/pull/12758#discussion_r444578576



##########
File path: src/component/axisPointer/viewHelper.js
##########
@@ -60,62 +59,41 @@ export function buildLabelElOption(
     );
     var labelModel = axisPointerModel.getModel('label');
     var paddings = formatUtil.normalizeCssArray(labelModel.get('padding') || 0);
-
-    var font = labelModel.getFont();
-    var textRect = textContain.getBoundingRect(text, font);
-
     var position = labelPos.position;
-    var width = textRect.width + paddings[1] + paddings[3];
-    var height = textRect.height + paddings[0] + paddings[2];
-
-    // Adjust by align.
-    var align = labelPos.align;
-    align === 'right' && (position[0] -= width);
-    align === 'center' && (position[0] -= width / 2);
-    var verticalAlign = labelPos.verticalAlign;
-    verticalAlign === 'bottom' && (position[1] -= height);
-    verticalAlign === 'middle' && (position[1] -= height / 2);
-
-    // Not overflow ec container
-    confineInContainer(position, width, height, api);
+    var font = labelModel.getFont();
 
     var bgColor = labelModel.get('backgroundColor');
     if (!bgColor || bgColor === 'auto') {
         bgColor = axisModel.get('axisLine.lineStyle.color');
     }
 
     elOption.label = {
-        shape: {x: 0, y: 0, width: width, height: height, r: labelModel.get('borderRadius')},
+        shape: {},
         position: position.slice(),
-        // TODO: rich
-        style: {
-            text: text,
+        style: graphic.setTextStyle({}, labelModel, {
+            text: labelModel.get('show') ? text : null,
+            textBackgroundColor: bgColor,
             textFont: font,
-            textFill: labelModel.getTextColor(),
             textPosition: 'inside',
             textPadding: paddings,
-            fill: bgColor,
-            stroke: labelModel.get('borderColor') || 'transparent',
-            lineWidth: labelModel.get('borderWidth') || 0,
-            shadowBlur: labelModel.get('shadowBlur'),
-            shadowColor: labelModel.get('shadowColor'),
-            shadowOffsetX: labelModel.get('shadowOffsetX'),
-            shadowOffsetY: labelModel.get('shadowOffsetY')
-        },
+            textFill: labelModel.getTextColor(),
+            rotation: labelModel.get('rotate'),
+            opacity: labelModel.get('opacity')
+        }, {isRectText: true}),
         // Lable should be over axisPointer.
         z2: 10
     };
 }
 
 // Do not overflow ec container
-function confineInContainer(position, width, height, api) {
-    var viewWidth = api.getWidth();
-    var viewHeight = api.getHeight();
-    position[0] = Math.min(position[0] + width, viewWidth) - width;
-    position[1] = Math.min(position[1] + height, viewHeight) - height;
-    position[0] = Math.max(position[0], 0);
-    position[1] = Math.max(position[1], 0);
-}
+// function confineInContainer(position, width, height, api) {
+//     var viewWidth = api.getWidth();
+//     var viewHeight = api.getHeight();
+//     position[0] = Math.min(position[0] + width, viewWidth) - width;
+//     position[1] = Math.min(position[1] + height, viewHeight) - height;
+//     position[0] = Math.max(position[0], 0);
+//     position[1] = Math.max(position[1], 0);
+// }

Review comment:
       Thank you for pointing out. I'm still not sure if this confining logic should be reserved, so keep this function here. :D




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

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