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/01/14 09:39:53 UTC

[GitHub] [incubator-echarts] 100pah opened a new issue #12043: Detect whether a click event triggered from any of the elements.

100pah opened a new issue #12043: Detect whether a click event triggered from any of the elements.
URL: https://github.com/apache/incubator-echarts/issues/12043
 
 
   ### What problem does this feature solve?
   The scenario:
   
   Check the case: https://www.echartsjs.com/examples/en/editor.html?c=pie-rich-text
   
   If I want to implement that: click the blank area, deselect all of the selected sectors. How to do it?
   
   Currently, potential way:
   
   ```js
   var clickedOnElement = false;
   
   chart.on('click', 'series.pie', function chartClickHandler(params) {
       clickedOnElement = true;
   });
   
   function zrClickHandler(params) {
       if (clickedOnElement) {
           clickedOnElement = false;
           chart.dispatchAction( ... ); // unselect all of the pie charts
       }
   }
   // If no this setting, the `zrClickHandler` will be called before 
   // the `chartClickHandler` 
   // Check the code of `echarts.js` for more details.
   zrClickHandler.zrEventfulCallAtLast = true;
   
   chart.getZr().on('click', zrClickHandler);
   ```
   
   However, it is not a good way.
   
   ### What does the proposed API look like?
   Enable echarts only use echarts event to implement it rather than depending on zrender events.
   
   ```js
   // blank event is triggered when clicked but no normal echarts click event triggered.
   chart.on('click', 'blank', function () {
       // unselect all of the sectors.
   });
   ```
   
   Moreover, we can provide zr event registering via echarts, where the `zrEventfulCallAtLast` can be resolved:
   ```js
   chart.on('click', 'all', function () {
       // The listener will be called after echarts built-in event called,
       // rather than before them. That is, the listener is auto marked as 
       // `zrEventfulCallAtLast`
   });
   ```
   The naming of 'all' can be further discussed.
   
   All of the implement of it can be in `echarts.js` `_initEvents`.
   
   <!-- 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


With regards,
Apache Git Services

---------------------------------------------------------------------
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 #12043: Detect whether a click event triggered from any of the elements.

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on issue #12043: Detect whether a click event triggered from any of the elements.
URL: https://github.com/apache/incubator-echarts/issues/12043#issuecomment-574088096
 
 
   Hi! We've received your issue and please be patient to get responded. 🎉
   The average response time is expected to be within one day for weekdays.
   
   In the meanwhile, please make sure that **you have posted enough image to demo your request**. You may also check out the [API](http://echarts.apache.org/api.html) and [chart option](http://echarts.apache.org/option.html) to get the answer.
   
   If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org. Please attach the issue link if it's a technical questions.
   
   If you are interested in the project, you may also subscribe our [mail list](https://echarts.apache.org/en/maillist.html).
   
   Have a nice day! 🍵

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


With regards,
Apache Git Services

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


[GitHub] [echarts] Rahulkishanm commented on issue #12043: Detect whether a click event triggered from any of the elements.

Posted by GitBox <gi...@apache.org>.
Rahulkishanm commented on issue #12043:
URL: https://github.com/apache/echarts/issues/12043#issuecomment-907433474


   echart.getZr().on('click', function(event) {
       if (!event.target) {
        // deselect all of the selected sectors. 
       }
     })


-- 
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: commits-unsubscribe@echarts.apache.org

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] [echarts] Rahulkishanm edited a comment on issue #12043: Detect whether a click event triggered from any of the elements.

Posted by GitBox <gi...@apache.org>.
Rahulkishanm edited a comment on issue #12043:
URL: https://github.com/apache/echarts/issues/12043#issuecomment-907433474


   This works for me.
   echart.getZr().on('click', function(event) {
       if (!event.target) {
        // deselect all of the selected sectors. 
       }
     })


-- 
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: commits-unsubscribe@echarts.apache.org

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