Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drill through on pie charts in Report Studio 1

Status
Not open for further replies.

dmunson

Programmer
Jul 21, 2005
19
0
0
US
Some asked a question about creating drill through links in a pie chart. Cognos says it's coming soon but you can't do it in RS now.

Here is a way you can get around it until it comes with the product.


Code:
 <script language="javascript">
/*
To make this work:
1 - Create a new report
2 - Add your chart (I've only tested with pie charts)
3 - Turn on tooltips for the chart (to make it create the area elements)
4 - Add a list, it will probably work with a crosstab also.
5 - Add drill through to the list, using the same column you added as the Series for the pie chart

when you click on the pie chart, it will look for the drill through link with the same label and call the
onclick method.

You could change it pretty easily to hide the list if you really didn't want it in the report.

Dave
*/
attachEvent("onload", initChartDrill);

function initChartDrill(){
	//Find all of the <area> elements on the page and add the doChartDrill function
	var areas = document.getElementsByTagName("area");
	for (var i = 0, ii = areas.length; i < ii; i++)
	{
		areas[i].onclick = doChartDrill;
	}
}

function doChartDrill(){

	//Start by getting the label from the tooltip.
	var alt = this.alt;
	alt=alt.substring(alt.indexOf("="));
	alt=alt.substring(2, alt.indexOf("\n"));

	//Now find a link that matches our label and call the onclick function.

	var links = document.getElementsByTagName("A");
	for(var i = 0, ii = links.length; i < ii; i++){
		if( links[i].innerText == alt && links[i].onclick){
			links[i].onclick();
		}
	}
}
</script>
 
I should also mention you have to add the script to the report with the drill through.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top