Initializing help system before first use

Getting Started with the JavaScript API 4.1

The JavaScript API offers a powerful way to create custom web views for an Xpress Insight application.

With this API you can create attractive, interactive views which present, interact with, and modify the underlying optimization data and control the execution of scenarios.

This reference describes the JavaScript API and should be used as an aid to developing and deploying optimization applications using Xpress Insight.

For an introduction and detailed guidance on writing custom views read the Xpress Insight Developers Guide, Chapter 6.

<xpressdir>\docs\insight\Xpress_Insight_developers_guide.pdf

A comprehensive set of examples are also available that demonstrate how to use the API in practice, found in:

<xpressdir>\examples\insight

A useful starting point in exploring this reference is the insight global object. The UI components such as tables, forms and charts are exposed in the namespace insight.components.

Quick Start

The quick start project at <xpressdir>\examples\insight\quick_start.zip has the following JavaScript code which serves as a good base for your own projects.

insight.ready(function () {
    // Get the Insight View.
    var view = insight.getView();

    // Listen to the selected scenario(s).
    // In this case the first scenario in the view selection is listened to.
    var observer = view.withFirstScenario();

    // Bind the relevant page DOM elements to the Insight Components or to a function.
    // At least one component or function must be bound to the observer.
    // The following shows a simple function being bound to the observer which logs summary data changes to the console.
    observer.withSummaryData()
        .notify(function (scenario) {
            console.log(scenario.getName() + ' summary data has changed');
        });

    // Start listening to the observed scenarios and render the view.
    view.start();
});