button to set a dynamic limit in the chart display

Hello everybody and a happy new year!

I am displaying a pie chart in which the number of values depends very much on the filter.
In Scriptcase I can only set a fixed limit of the displayed values. (in the left menu bar)
Has anyone found a solution how I can e.g. create a filter that only the top 3, 5 or 10 or any number of values are displayed in the chart. Just like I select a filter after the export I would like to be able to limit the number of results with a button.