Accessing Data
When a scenario observer notify callback is invoked the scenario objects passed in are preloaded with the latest data for the observed entities
You can access the data for these entities as follows:
// Accessing entity data view.withFirstScenario() .withEntities('SCALAR1', 'PARAMETER1', 'SET1') .notify(function(scenario) { var scalar1 = scenario.getScalar('SCALAR1'); var parameter1 = scenario.getParameter('PARAMETER1'); // set1 is a JavaScript array var set1 = scenario.getSet('SET1'); }) .start();
Sets are returned as JavaScript arrays with the values in the array corresponding to the set elements. By default the server will order set values alphanumerically.
scenario.getSet('myset').forEach(function(v) { console.log(v); });
Array values are accessed by specifying the array entity name and one or more tuples of index values.
// Accessing array entity data view.withFirstScenario() .withEntities('Population', 'Countries') .notify(function(scenario) { var countries = scenario.getSet('Countries'); var population = scenario.getArray('Population'); countries.forEach(function(country) { var country = population.getValue([country]); console.log(country); }); }) .start();