You use the CreateShape method to add a shape to a dashboard; for example, a goal for football, and you use the RemoveShape method to remove the shape of the goal. To perform the physical adding and removing of the shape, configure two command buttons.
Note: | Modify the example to suit your requirements. |
To configure two command buttons:
In Interactive Reporting Studio, use the dashboard from the Placing Objects procedure.
From Elements, expand Controls, and drag two command buttons onto the dashboard.
In Properties, enter a Name and Title.
For example, type AddGoal as the Name, and Add a Goal as the Title.
Repeat steps 4-5 for CommandButton3 with alternate data.
For example, type DelGoal as the Name, and Delete the Goal as the Title.
From Graphics, drag a rectangle onto the dashboard, right-click, and select Properties.
The rectangle will be added or removed by the command buttons.
For example, type LeftGoal.
In Script Editor, copy and paste this code, or modify to suit your requirements.
var objRect = ActiveSection.Shapes.CreateShape(bqRectangle) objRect.Name = "LeftGoal" objRect.Placement.XOffset = Field.Placement.XOffset - 10 objRect.Placement.YOffset = Field.Placement.YOffset - 10 objRect.Placement.Width = Ball.Placement.Width - 60 objRect.Placement.Height = Field.Placement.Height + 20 objRect.Fill.Color = bqBlack
In Script Editor, copy and paste this code, or modify to suit your requirements.
try{ Shapes.RemoveShape("LeftGoal") }catch(e){} // no worries it does not exist