Drill down on Bar chart with multiple Dimensions

Hello Team Helical,

I have a grouped bar chart which shows the total number of students in primary section and the number of students in secondary section over various years. So for every year there are 2 bars one for primary and the second for secondary class. When I click on primary section bar, I want to drilldown to report where automatically a filter is applied with the class=1,2,3,4,5 and for secondary, class=6,7,8,9,10. How can I do this?
When I am applying drilldown, it is passing the year in the URL to the drilldown chart. I also want the report to open in the same frame as my original chart.

image

Thank You

1 Like

Hello Krishna,

Use the below given script in the JS Editor section of the report. In this script what we have written is that we have defined an onclick event and opening the child report. Now there is ifelse condition to identify on which we are clicking i.e. primary or secondary, and accordingly we are also passing a filter called Class along with values of that into the child report. You can use this blog as a reference to make additional changes as per your requirement.

hi_container.set("preExecution",function(c)
{
	var viz_Options = c.get("viz_Options");
	viz_Options.chartOptions.data = 
		{
		onclick: function (d, i) 
		{
			if(d.id=='Primary')
			{	
					     window.open(window.baseUrl+"?dir=1580286161890/1580286586884/1580286633025/1595799484871&file=92b61fc2-ea68-4c5b-afff-8f32c09d7688.report&mode=dashboard&Class=[1,2,3,4,5] '_self');
			}
			else if (d.id=='Secondary')
			{	
					    window.open(window.baseUrl+"?dir=1580286161890/1580286586884/1580286633025/1595799484871&file=92b61fc2-ea68-4c5b-afff-8f32c09d7688.report&mode=dashboard&Class=[6,7,8,9,10]&”, '_self');
			}
		}
	};
	c.set("viz_Options",viz_Options);
});

Using ‘_self’ will open the child report in the same frame, while using ‘_blank’ will open it in a new tab.

Thank You
From Team Helical