About switch Statements

switch statements use expressions, or cases, to control statement execution. Each case holds one possible value and includes the statements to execute when the value matches the expression result. The following table compares the control logic of a switch to an if...else.

switch

if...else

switch (CheckBox.Checked)
{
case true :
  set the chart type to a line chart 
case false :
  set the chart type to a pie chart 
}
if (CheckBox.Checked==true)
{
  set the chart type to a line chart
}
else
{
  set the chart type to a pie chart 
}

JavaScript evaluates the expression in a switch, then compares the expression value to each case until it finds a matching value. The statements in the matching case are executed and the next case is compared. If the matching case ends with a break statement, JavaScript skips the rest of the cases (conserving execution time).

Note:

Add a check box to the Limits Dashboard section of Sample1mod.bqy. Use switch logic instead of if...else logic to change the chart type.