cancel
Showing results for 
Search instead for 
Did you mean: 

Line Chart - Show only with filter

HQ_Dev_Prod
7 - Data Storage
7 - Data Storage

I am building a line chart that shows value over time. However, there are over items. Is there a way to setup the line chart to only show when I filter on one item?

Example:

Line chart is blank > then I select one item from my drop down or filter > then the line chart will show it's value over time. 

3 REPLIES 3

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @HQ_Dev_Prod ,

You can achieve this by using a widget script. Add the script below to your line chart and ensure you update the variable 'filterTitle' with the name of your filter.

This script will also display the message "Select one filter item" if no items or more than one item are selected. For further customization of the message and image, check out this post: https://www.binextlevel.com/post/custom-no-result-message

 

const filterTitle = 'Category';

widget.on('beforequery', function(w, args){
	const dashFilter = prism.activeDashboard.filters.flatten().find(el => el.jaql.title === filterTitle);
	
	if(!dashFilter) {
		return;
	}
	if(!(dashFilter.jaql.filter.members && dashFilter.jaql.filter.members.length === 1)) {
		args.query.metadata.length = 0;
	}
})

//To Customize message
widget.on('domready', function(se){
	const dashFilter = prism.activeDashboard.filters.flatten().find(el => el.jaql.title === filterTitle);
	
	if(!dashFilter) {
		return;
	}
		
	if(!(dashFilter.jaql.filter.members && dashFilter.jaql.filter.members.length === 1)) {
		if (prism.activeWidget == null)
			no_result_container = $(`widget[widgetid="${se.oid}"]`)
		else
			no_result_container = $('.prism-widget-preview')
		
		$(no_result_container).find('.widget-no-result-overlay .widget-no-result-notify-holder .no-result-title').text('Select one filter item')
	}
})

 

Result:

harikm007_0-1726638106629.gif

Feel free to reach out if you have any questions!

-Hari

https://www.binextlevel.com/ 

 

Thank you Hari!

Is it possible to set this process up so that if I select an item from a pie chart to filter the data, the line chart populates? Such that I don't have to go to the filters pan, but rather I can drill down to the line chart detail for a specific item from a pie chart? 

 

If I understand your question correctly, you want the line chart to update when you click on a slice of the pie chart, right? If that's the case, clicking on a slice of the pie chart automatically applies a filter to the dashboard, so the same script should work here. Please refer to the GIF below.

 

harikm007_0-1726670522933.gif

 

Does that address your question?