susiwen8 commented on a change in pull request #12947:
URL:
https://github.com/apache/incubator-echarts/pull/12947#discussion_r458481565
##########
File path: src/component/tooltip/TooltipView.ts
##########
@@ -752,12 +805,50 @@ class TooltipView extends ComponentView {
html = formatter(params, asyncTicket, callback);
}
- tooltipContent.setContent(html, markers, tooltipModel);
- tooltipContent.show(tooltipModel);
-
this._updatePosition(
tooltipModel, positionExpr, x, y, tooltipContent, params, el
);
+ tooltipContent.setContent(html, markers, tooltipModel,
nearPoint.color, positionExpr);
+ tooltipContent.show(tooltipModel, nearPoint.color);
+
+ }
+
+ _getNearestPoint(
+ point: number[],
+ tooltipDataParams: TooltipDataParams | TooltipDataParams[],
+ coord?: CoordinateSystem
+ ): {
+ x: number;
+ y: number;
+ color: ZRColor;
+ } {
+ let dim = '';
+ if (coord && coord.type === 'cartesian2d') {
+ dim = coord.getBaseAxis().dim;
+ }
+ if (!zrUtil.isArray(tooltipDataParams)) {
+ if (!tooltipDataParams.position) {
+ return {
+ x: point[0],
+ y: point[1],
+ color: tooltipDataParams.color ||
tooltipDataParams.borderColor
+ };
+ }
+ return {
+ x: point[0],
+ y: tooltipDataParams.position[1],
Review comment:
At first `_getNearestPoint` was intended to find the closet point to
cursor (only on cartesian), so I can put `arrow` in right position, but then I
found out it's little tricky (at that time, I wasn't aware `tooltip.position`
which is simpler), so I just fix `tooltip` `y` coordinate to the `y` coordinate
of cursor (soon, I realized it should be `value axis` ), in that case, tooltip
was situated `left` or `right` of point.
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]