* It is assumed that the dropdown list has already been populated with a list of measure objects
This script works for bar and line charts
Widgets
Dropdown List: dropdown_1
Chart: Chart_1
Script placed in the dropdown onSelect event
// get the dropdown selected key & write the value to the variable ‘ddlkey’
var ddlkey = dropdown_1.getSelectedKey();
// get the measure on the chart value axis
var chartmeasure = Chart_1.getMeasures(Feed.ValueAxis)[0];
// remove the current measure from the chart
Chart_1.removeMeasure(chartmeasure,Feed.ValueAxis);
// add the measure selected in dropdown to the chart
Chart_1.addMeasure(ddlkey,Feed.ValueAxis);
Code language: JavaScript (javascript)
