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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to determine containing element from chart event

Thread ID:

Created:

Updated:

Platform:

Replies:

118345 Feb 27,2015 10:38 AM Mar 3,2015 12:06 AM JavaScript 3
loading
Tags: ejChart
Chris John
Asked On February 27, 2015 10:38 AM

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

 }


Jayavigneshwaran [Syncfusion]
Replied On March 1, 2015 11:49 PM

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



Chris John
Replied On March 2, 2015 04:07 AM

Hi Jayavigneshwaran,

Brilliant - that's exactly what I need.

Many thanks
Chris

Jayavigneshwaran [Syncfusion]
Replied On March 3, 2015 12:06 AM

Hi Chris,
 
Thanks for your update.
 
Regards,
Jayavigneshwraan



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;