Dynamic Chart - Select


Im trying to build a chart, which works neatly with its datasource as a query.

however, i would like to have a select options for users to switch which data is displayed(populated) in the chart.

What would be the best way to achieve this?

At the moment im experimenting with something like this but cannot get it to work:

**let selectedQuery;

switch (select1.value) {
case '1':
selectedQuery = topp10omsetning;
case '2':
selectedQuery = topp10cardscheme;
selectedQuery = defaultQuery; //

MAAchart.query = selectedQuery;

Many thanks :slight_smile:

You could use a ternary operator when the user selects from the dropdown to display the specific data from each query (If you run all queries when the page loads and provided each query payload is formatted accordingly)
In the data source field for the chart you could do something like:

Thank you for your reply ScottR,

I tried out your suggestion, however the chart does not visualize data from any query with this solution (these are all run when the page load).

I also tried making 2 individual charts, with 2 different top10queries, and they both give the desired result on their own, but not in combination with the select unfortunately

Any chance you can share some more info? Screenshots?