ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How do you get the sector that is clicked in a pie chart.
Posted by Brent on Jan-24-2011 21:17
I have a clickable pie chart.
I want to explode the sector that is clicked.

How do I get the number of the sector that is clicked?

The only examples I see in your help files, are where you are hard-coding a sector number.

Thanks,
Brent

  Re: How do you get the sector that is clicked in a pie chart.
Posted by Peter Kwan on Jan-25-2011 04:23
Hi Brent,

When one clicks on a sector, ChartDirector will include the sector number as the query parameter "sector" in the URL. Your code can use that query parameter to get the sector number, and use it in setExplode instead of using a hard coded number.

In fact, in the original sample code that comes with ChartDirector, in the "Simple Clickable Charts" sample code, when one clicks on the pie chart, it will display a web page showing the sector number clicked. You may try to look at the code in that web page to see how it gets the sector number.

Hope this can help.

Regards
Peter Kwan

  Re: How do you get the sector that is clicked in a pie chart.
Posted by Brent on Jan-25-2011 04:28
Thanks much for the reply!  Ah, that's the problem.

We actually call a javascript function when they click the sector, and in the javascript function we call __DoPostback so that we can pass some information back to the server.

Is there a way we can get the sector in our javascript function?  We already add a custom field to our chart's image map.  Can we also add the sector, and somehow get that in our click event that we handle in javascript?

Thanks,
Brent

  Re: How do you get the sector that is clicked in a pie chart.
Posted by Peter Kwan on Jan-25-2011 04:36
Hi Brent,

Yes. The field for the sector number is {sector}. For example:

WebChartViewer1.ImageMap = c.getHTMLImageMap("aaa.aspx", "", "onclick='myCustomFunction(\\"{field0}\\", {sector});'");

In the above, when the sector is clicked, the Javascript function "myCustomFunction" will be called with 2 arguments - the custom field, and the sector number.

Hope this can help.

Regards
Peter Kwan

  Re: How do you get the sector that is clicked in a pie chart.
Posted by Brent on Jan-25-2011 05:14
Awesome Peter.  That did the trick.  Thanks so much for the fast and accurate replies!
Brent