Line Chart - Show only with filter
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.
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:
Feel free to reach out if you have any questions!
-Hari