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/06/14 07:58:36 UTC

[GitHub] [echarts] g7i commented on a change in pull request #14393: bug(tooltip): tooltip arrow will follow borderWidth. close #14373

g7i commented on a change in pull request #14393:
URL: https://github.com/apache/echarts/pull/14393#discussion_r650372816



##########
File path: src/component/tooltip/TooltipView.ts
##########
@@ -1100,20 +1101,20 @@ function calcTooltipPosition(
             y = rect.y + rectHeight / 2 - domHeight / 2;
             break;
         case 'top':
-            x = rect.x + rectWidth / 2 - domWidth / 2;
+            x = rect.x + rectWidth / 2 - domWidth / 2 - borderWidth / 2;

Review comment:
       :heavy_check_mark: 

##########
File path: src/component/tooltip/TooltipHTMLContent.ts
##########
@@ -60,17 +60,21 @@ function mirrorPos(pos: string): string {
 }
 
 function assembleArrow(
-    backgroundColor: ColorString,
+    tooltipModel: Model<TooltipOption>,
     borderColor: ZRColor,
     arrowPosition: TooltipOption['position']
 ) {
     if (!isString(arrowPosition) || arrowPosition === 'inside') {
         return '';
     }
 
+    const backgroundColor = tooltipModel.get('backgroundColor');
+    const borderWidth = tooltipModel.get('borderWidth');
+
     borderColor = convertToColorString(borderColor);
     const arrowPos = mirrorPos(arrowPosition);
-    let positionStyle = `${arrowPos}:-6px;`;
+    const arrowSize = borderWidth >= 5 ? borderWidth : 5;

Review comment:
       :heavy_check_mark: 

##########
File path: src/component/tooltip/TooltipHTMLContent.ts
##########
@@ -60,17 +60,21 @@ function mirrorPos(pos: string): string {
 }
 
 function assembleArrow(
-    backgroundColor: ColorString,
+    tooltipModel: Model<TooltipOption>,
     borderColor: ZRColor,
     arrowPosition: TooltipOption['position']
 ) {
     if (!isString(arrowPosition) || arrowPosition === 'inside') {
         return '';
     }
 
+    const backgroundColor = tooltipModel.get('backgroundColor');
+    const borderWidth = tooltipModel.get('borderWidth');
+
     borderColor = convertToColorString(borderColor);
     const arrowPos = mirrorPos(arrowPosition);
-    let positionStyle = `${arrowPos}:-6px;`;
+    const arrowSize = borderWidth >= 5 ? borderWidth : 5;
+    let positionStyle = `${arrowPos}:-${Math.sqrt(2 * arrowSize * arrowSize) / 2 + borderWidth}px;`;

Review comment:
       :heavy_check_mark: 

##########
File path: src/component/tooltip/TooltipView.ts
##########
@@ -1084,7 +1084,8 @@ function confineTooltipPosition(
 function calcTooltipPosition(
     position: TooltipOption['position'],
     rect: ZRRectLike,
-    contentSize: number[]
+    contentSize: number[],
+    borderWidth: number
 ): [number, number] {

Review comment:
       :heavy_check_mark: 




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