Sign in to follow this  
srpokala

Chart rerender when one of the item on the legend is hidden

Recommended Posts

Hi,

 

I have line chart in which i have 3 sets of data and one of them datasets have data in the 1200 range and other are in the 50 range.

 

When i click on Test2 legend in the graph it hides that specific line but the graph does not re render and adjust the values with the existing chart lines

 

Here is the screenshot for that.

 

post-51664-0-65239900-1375381946_thumb.jpg

 

How do i achieve rerendering in that case when one of the legend is hidden.

 

Any help is appreciated.

 

 

Thanks

Share this post


Link to post
Share on other sites

Hi,

 

The feature of re-drawing and re-scaling the chart when the legend of the chart is clicked is not present as of now.

 

But as a workaround, you may use the "LegendItemClicked" event and change the XML/JSON being used to create the chart. When the Legend is clicked again, you can change the XML/JSON back to the previous one. By doing this, you can achieve the required functionality. Please find a sample attached which uses the above specified method.

 

Hope this helps. :)

Rescale on click of Legend.zip

Share this post


Link to post
Share on other sites

Hi,

 

Thanks for the sample example it helps but i need to lad the data dynamically so i cannot have xml or json files.

 

So is there a way i can get the name of the legend when it is clicked as opposed to the index so that i can pass that info to the ajax call.

 

 

Thanks

Sri

Share this post


Link to post
Share on other sites

Hi Sri,

 

Yes, it is possible to obtain the seriesName of the legend. Try "argumentsObject.datasetName". This should give you the legend name (dataset seriesName corresponding to the legend).

 

Hope this helps.

Share this post


Link to post
Share on other sites

Yes this did help and thanks for the response.

 

Now when i have multiple charts on the same page is there a way for me to differentiate which chart i have clicked?

 

because it just gets me the legend information and not the chart.

 

Any suggestions of how to vary this implementation to get the chart information on legend click.

 

 

Thanks

Sri

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Yes, you can get the chart object from the "LegendItemClicked" event by using the "eventObject.eventId" parameter.

 

On function call of "LegendItemClicked" event, you can get the chart object instance by "FusionCharts(eventObject.eventId)".

 

For more information on "FusionCharts JavaScript API - Events", please visit the link: http://docs.fusioncharts.com/charts/contents/JavaScript/API/Events.html

 

Hope this helps!

Share this post


Link to post
Share on other sites

function LegendItemClickedFunc(eventObject, argumentsObject) {
        var test = FusionCharts(eventObject.eventId);
        alert(test);

}

 

When i do this it throws an exception and minimizes the window .

 

Am i doing something wrong here?

 

Can you point me to an example that would be helpful.

Edited by srpokala

Share this post


Link to post
Share on other sites

Hi,

 

You may refer to the sample attached by Haritha in this topic itself.

 

Please let us know your requirement so that we can suggest you accordingly.

Share this post


Link to post
Share on other sites

I have already checked the example but now my requirement has changed and now i have 3 pie charts on a view and when a legend is clicked i need to display a grid with that information.

 

So for one chart it works well but now i have 3 and only one eventlistner which handles for all 3 charts and i need to get the name of the chart on which the legend is clicked and when i have done the approach above mentioned like this

 

FusionCharts.addEventListener("LegendItemClicked", LegendItemClickedFunc);

function LegendItemClickedFunc(eventObject, argumentsObject) {
        var test = FusionCharts(eventObject.eventId);
        alert(test);

}

 

it threw an exception.

 

Am i doing something wrong here? or how do i get the chart name on which the legend is clicked.

Share this post


Link to post
Share on other sites

Hi,

 

You may get the chart id using the code below,

 

function LegendItemClickedFunction(eventObject,argumentsObject)
    {
        alert(eventObject.sender.attributes.id); // gives the chart id

}

 

Hope this helps!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this