About the mobile side using the echarts map component and adding click events in provinces and regions

demand: use the map component in echarts4 on the mobile page, add the click event of the province, and request the backend to obtain the detailed data and display it in a pop-up window.

status quo:

  1. Provincial click event uses click event

       this.mapChart.on("click", (params) => {
         // do something
     })
    

question:
but on mobile, clicking sometimes doesn"t work. You have to double-click the province. This is why, ah, please give us some advice.

Thank you!

May.23,2021

try tap


1, change to echart version (eliminate framework problems) 2, write a simple click event (eliminate mobile problems)


myChart.getZr().on('click',  (params) => { //echartsgetzrApixindex
    var pointInPixel= [params.offsetX, params.offsetY];
    myChart.containPixel('grid',pointInPixel)
    if (myChart.containPixel('grid',pointInPixel)) {
 var xIndex=myChart.convertFromPixel({seriesIndex:0},[params.offsetX, params.offsetY])[0];
     // xindex xindexdata
    }
  });
Menu