We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to determine containing element from chart event

Hi,

When I have multiple charts on a page, I want to use the same Javascript event handlers for each.  I need to be able to get to the containing element of the chart which raised the event. At the moment I'm struggling to work out how to do this from the sender parameter. Is there a way to do this, or any other workarounds you can suggest?

Thanks

Chris


e.g.

$("#container1").ejChart(

               {  

                    // ...            

                     load: 'onload',

                   // ...          

                       });

 

 $("#container2").ejChart(

               {  

                    // ...            

                     load: 'onload',

                   // ...          

                       });

  

function onload(sender) {

// How to determine which element contains the chart which is the source of the event? 

// var container = $("#container1") or $("#container2"), etc...

 }


3 Replies

JA Jayavigneshwaran Syncfusion Team March 2, 2015 04:49 AM UTC

Hi Chris,

Thanks for using Syncfusion product.

We have analyzed this and replicated the scenario shown, in our sample.

Consider the below example. This page has two div namely container1 and container2 which is used to render chart.

The below screen shot shows this.

To get the id of the div on chart load, the below code snippet is used

[JS]

function onchartload(sender){                                               // method called on chart load

        alert("on load of the chart in the div: " +this._id);   // to display alert box

    }

We coded to display an alert box which shows the id of the div on chart load. The below screen shot shows this.

We have also attached the sample in the below location for your reference.
line.zip

Please let us know if you have any concern.

Thanks,

Jayavigneshwaran




CJ Chris John March 2, 2015 09:07 AM UTC

Hi Jayavigneshwaran,

Brilliant - that's exactly what I need.

Many thanks
Chris


JA Jayavigneshwaran Syncfusion Team March 3, 2015 05:06 AM UTC

Hi Chris,
 
Thanks for your update.
 
Regards,
Jayavigneshwraan



Loader.
Live Chat Icon For mobile
Up arrow icon