plainheart commented on a change in pull request #14393:
URL: https://github.com/apache/echarts/pull/14393#discussion_r663622792
##########
File path: src/component/tooltip/TooltipHTMLContent.ts
##########
@@ -81,15 +85,15 @@ function assembleArrow(
transformStyle += `translateX(-50%) rotate(${arrowPos === 'top' ? 225
: 45}deg)`;
}
- const borderStyle = `${borderColor} solid 1px;`;
+ const borderStyle = `${borderColor} solid ${borderWidth}px;`;
const styleCss = [
- 'position:absolute;width:10px;height:10px;',
+ `position:absolute;width:${borderWidth}px;height:${borderWidth}px;`,
Review comment:
It may be not appropriate to use `borderWidth` as arrow size, but
perhaps we can multiply it by a factor. And the calculated `arrowOffset` seems
to be not accurate enough. Here is my humble opinion about the calculation,
```diff
src/component/tooltip/TooltipHTMLContent.ts
@@ -73,22 +73,27 @@ function assembleArrow(
borderColor = convertToColorString(borderColor);
const arrowPos = mirrorPos(arrowPosition);
- const arrowOffset = Math.round(Math.sqrt(2 * borderWidth * borderWidth)
/ 2) + borderWidth;
- let positionStyle = `${arrowPos}:-${arrowOffset}px;`;
+ const arrowSize = Math.max(Math.round(borderWidth) * 1.5, 6);
+ let positionStyle = '';
let transformStyle = CSS_TRANSFORM_VENDOR + ':';
+ let rotateDeg = 0;
if (indexOf(['left', 'right'], arrowPos) > -1) {
positionStyle += 'top:50%';
- transformStyle += `translateY(-50%) rotate(${arrowPos === 'left' ?
-225 : -45}deg)`;
+ transformStyle += `translateY(-50%) rotate(${rotateDeg = arrowPos
=== 'left' ? -225 : -45}deg)`;
}
else {
positionStyle += 'left:50%';
- transformStyle += `translateX(-50%) rotate(${arrowPos === 'top' ?
225 : 45}deg)`;
+ transformStyle += `translateX(-50%) rotate(${rotateDeg = arrowPos
=== 'top' ? 225 : 45}deg)`;
}
+ const arrowOffset = Math.round((borderWidth * Math.SQRT2 + arrowSize /
2) * 100) / 100;
+ positionStyle += `;${arrowPos}:-${arrowOffset}px`;
+ const margin = Math.round(borderWidth / 2 *
Math.abs(Math.cos(rotateDeg)) * 100) / 100;
const borderStyle = `${borderColor} solid ${borderWidth}px;`;
const styleCss = [
- `position:absolute;width:${borderWidth}px;height:${borderWidth}px;`,
+ `position:absolute;width:${arrowSize}px;height:${arrowSize}px;`,
`${positionStyle};${transformStyle};`,
+ `margin-${arrowPos}:${margin}px;`,
`border-bottom:${borderStyle}`,
`border-right:${borderStyle}`,
`background-color:${backgroundColor};`
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]