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/11/24 00:55:54 UTC

[GitHub] [incubator-echarts] jinyang1994 opened a new issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

jinyang1994 opened a new issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669


   ### What problem does this feature solve?
   我们的业务中期望tooltip与axisPointer保持一个固定的距离,目前tooltip位置主要还是取决于鼠标的位置。
   
   ### What does the proposed API look like?
   ```javascript
   tooltip: {
     position(..., trigger) {}, // trigger 可以为触发tooltip显示的一些相关信息,比如axisPointer,click事件等等
   }
   ```
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   <!-- This issue is in English. DO NOT REMOVE -->


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


[GitHub] [incubator-echarts] jinyang1994 edited a comment on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
jinyang1994 edited a comment on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-732734724


   @Ovilia 我目前的写法应该就是`Function`回调函数的形式,有一个比较困惑的地方是,我该如何获取`axisPointer`的`position`数据,主要是它的`top`和`left`。有什么比较好的思路么?


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


[GitHub] [incubator-echarts] jinyang1994 commented on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
jinyang1994 commented on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-732517405


   或者有什么办法可以在chart实例上面获取到axisPointer的一些信息


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


[GitHub] [incubator-echarts] echarts-bot[bot] commented on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-732640523


   @jinyang1994 Please provide a demo for the issue either with https://codepen.io/Ovilia/pen/dyYWXWM or https://www.makeapie.com/editor.html.


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


[GitHub] [incubator-echarts] jinyang1994 closed issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
jinyang1994 closed issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669


   


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


[GitHub] [incubator-echarts] Ovilia commented on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
Ovilia commented on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-733417095


   第二个参数 `params` 可以获取到数据,可以试试用 [echartsInstance.convertToPixel](https://echarts.apache.org/en/api.html#echartsInstance.convertToPixel) 获取到数据点的位置,横向的应该就是 axisPointer 的位置。


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


[GitHub] [incubator-echarts] jinyang1994 commented on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
jinyang1994 commented on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-733459333


   ```javascript
   position(point, params) {
     if (params.length) {
       const { axisIndex, axisValue } = params[0];
       
       instance.convertToPixel({ xAxisIndex: axisIndex }, axisValue); // axisPointer position x 
     }
   }
   ```


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


[GitHub] [incubator-echarts] jinyang1994 commented on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
jinyang1994 commented on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-732639421


   > 没有看到 axisPointer 的相关事件,是不是可以手动指定 Tooltip 的位置?https://echarts.apache.org/zh/option.html#tooltip.position
   
   ```
   position: (point, params, dom, rect, size) => {
     const { contentSize, viewSize } = size;
     const position = { top: (viewSize[1] - contentSize[1]) / 2 };
   
      if (point[0] <= viewSize[0] / 2) {
        position.left = point[0] + 10;
      } else {
        position.left = point[0] - 10 - contentSize[0];
      }
               
      return position;
   },
   ```
   
   目前我是这样做的,当`axisPointer`开启`snap`时,axisPointer的位置还是跟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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [incubator-echarts] Ovilia commented on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
Ovilia commented on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-732723463


   [tooltip.position](https://echarts.apache.org/zh/option.html#tooltip.position) 可以是回调函数形式的,看看能不能实现


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


[GitHub] [incubator-echarts] Ovilia commented on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
Ovilia commented on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-732637745


   没有看到 axisPointer 的相关事件,是不是可以手动指定 Tooltip 的位置?https://echarts.apache.org/zh/option.html#tooltip.position


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


[GitHub] [incubator-echarts] jinyang1994 edited a comment on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
jinyang1994 edited a comment on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-733459333


   @Ovilia 谢谢你的耐心解答,你的方案解决了我的需求
   
   ```javascript
   position(point, params) {
     if (params.length) {
       const { axisIndex, axisValue } = params[0];
       
       instance.convertToPixel({ xAxisIndex: axisIndex }, axisValue); // axisPointer position x 
     }
   }
   ```


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


[GitHub] [incubator-echarts] jinyang1994 commented on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
jinyang1994 commented on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-732734724


   @Ovilia 目前有一个比较困惑的地方是,我该如何获取`axisPointer`的`position`数据,主要是它的`top`和`left`。有什么比较好的思路么?


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


[GitHub] [incubator-echarts] jinyang1994 commented on issue #13669: 当axisPointer触发时,如何在tooltip position获得 axisPointer位置信息

Posted by GitBox <gi...@apache.org>.
jinyang1994 commented on issue #13669:
URL: https://github.com/apache/incubator-echarts/issues/13669#issuecomment-732651209


   ![image](https://user-images.githubusercontent.com/15340367/100049792-200fc600-2e53-11eb-8d90-5de79585f724.png)
   期望的是,红色横线部分的距离保持不变,跟随axisPointer移动而移动
   [https://codepen.io/jinyang1994/pen/KKMObZj](https://codepen.io/jinyang1994/pen/KKMObZj)


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