The View
var view = insight.getView();
This object is a representation of a single view in the client (specifically, the tab that you clicked on in the web client).
Each view has its own HTML file and typically an accompanying JavaScript file as well. Each view also has a reference in the companion file, and together these elements make up the view that is displayed when you click on the corresponding tab in the web client.
This view instance that is returned from the getView() function call has a number of methods and properties that you can call to interact with the view. However, the focus here will be on withFirstScenario.
![]() |
Note The JavaScript reference for the view class lists the other methods and options available.
|
view.withFirstScenario()
This code specifies that we are only interested in the first scenario that has been selected by the user. The function responds by returning a ScenarioObserver object that will handle all our interactions with the view. There are two other similar functions we can call, specifically withScenarios and withAllScenarios, but for now the focus will be on the first scenario. You will learn how and when to use the other function calls with multi-scenario views later in this chapter.