OnClientPointRegionClick , retrieve index of the series containing the point that was clicked

I have a line-graph that contains several series and points in each series

Each series is tied to a unique object, and every point in each series is a specific date with relationship with the object.
When clicking a point I want to redirect user to an URL

To be able to redirect correctly I need to determine both which date (point), I got this with sender.data.region.Region.PointIndex
But I also need to know which series/object the point/date belongs to, how can I retrieve this from the sender-object?

3 Replies

DD Dharanidharan Dharmasivam Syncfusion Team May 3, 2017 12:53 PM UTC

Hi Viktor, 

Thanks for contacting Syncfusion support. 

We have analyzed your query. You can able to get the series index, point index, x and y values of data points from pointRegionClick event. We have prepared a sample with respect to this scenario and displayed series index, point index, x and y values in an alert box. Also depends upon the points, we have navigated to another URL link. Find the code snippet below. 

ASP.Net: 

<ej:Chart OnClientPointRegionClick="pointClick"> 
</ej:Chart> 
 
function pointClick(sender) { 
            //Get series index and point index 
            var seriesIndex = sender.data.region.SeriesIndex, 
                pointIndex = sender.data.region.Region.PointIndex; 
 
            alert("Series Index : " + seriesIndex + "\nPoint Index : " + pointIndex + "\nX : " +   
                        sender.model.series[seriesIndex].points[pointIndex].x + 
                        "\nY : " + sender.model.series[seriesIndex].points[pointIndex].y); 
 
            //Navigated to URL depends upon points 
            if (pointIndex == 0) 
                window.location = 'https://www.syncfusion.com/'; 
            else if (pointIndex == 1) 
                window.location = 'http://asp.syncfusion.com/demos/web/'; 
            else if (pointIndex == 2) 
                window.location = 'https://help.syncfusion.com/'; 
            else if (pointIndex == 3) 
                window.location = 'http://mvc.syncfusion.com/demos/web/'; 
            else if (pointIndex == 4) 
                window.location = 'https://help.syncfusion.com/api/js/global'; 
            else if (pointIndex == 5) 
                window.location = 'https://help.syncfusion.com/api/js/ejchart'; 
             
        } 

Screenshot: 
 

Sample for reference can be find from the below link. 
 
Thanks, 
Dharani. 



BF BFY May 3, 2017 07:44 PM UTC

Thank you!
Exactly what I was looking for


DD Dharanidharan Dharmasivam Syncfusion Team May 4, 2017 12:17 PM UTC

Hi Viktor 
   
Thanks for your update. 
 
Kindly revert us, if you need further assistance. 
   
Thanks,  
Dharani.  


Loader.
Up arrow icon