JavaScript makes a distinction between assignment (=) and comparison (==) operators.
Use = to assign the value on the right to the object on the left.
Use == to test if the values on both sides match (the result is true if they match).
The following exercise uses the Intelligence Client file Sample3.bqy and the RevByTime chart used in Associating Scripts with Radio Buttons. You can use any bqy document that includes a chart. |
Insert a new Dashboard section in Sample3.bqy. Add a line chart and two buttons titled Comparison and Assignment.
Add a JavaScript script to the Comparison button to compare the type of chart to bqChartTypeVerticalBar and open an alert that displays the result of the comparison. Test the comparison button. What does the alert say?
Script the Assignment button to change the chart type to bqChartTypePie. Try the comparison button again. What does the alert say now?
Both JavaScript scripts act on the actual chart, not the view of the chart in the Dashboard section. |
The script for the Comparison button uses == to test if ChartType matches bqChartTypeVerticalBar. The alert displays true if they match, false if they don’t match.
The Assignment button’s script uses = to set RevByTime’s ChartType property equal to bqChartTypePie. The chart changes to a pie chart.