API Reference
Namespaces
Classes
Events
Global
Externals

Class: Context

CIQ.UI. Context


new Context(stx, topNode [, params])

UI context helper class.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the web components can be found here: Web Component Interface.

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine

The chart object to associate with this UI context.

topNode HTMLElement

The top node of the DOM tree for this context. The top node should contain all of the UI elements associated with the chart engine.

params object <optional>

Context parameters.

Methods


advertiseAs(uiHelper, helperName)

Attaches a Helper to the context, so that it can be found later on.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the web components can be found here: Web Component Interface

Parameters:
Name Type Description
uiHelper CIQ.UI.Helper

A UI Helper to attach

helperName String

The helperName of the element. For instance "Loader"


changeSymbol(data [, cb])

Executes a symbol change request on the UI context.

Abstract method that should be overridden. See example.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the web components can be found here: Web Component Interface.

Parameters:
Name Type Argument Description
data object

A symbol data object acceptable by CIQ.ChartEngine#loadChart.

Properties
Name Type Description
symbol string

A financial instrument symbol.

cb function <optional>

A callback function to execute once the symbol change is complete. The first argument of the callback function is a reference to the chart engine.

Since:
  • 8.2.0 Added the cb parameter.

Example
uiContext.changeSymbol = function (data, cb) {
	const { stx, loader } = uiContext;
	if (loader) loader.show();

	if (data.symbol == data.symbol.toLowerCase()) data.symbol = data.symbol.toUpperCase(); // Set a pretty display version.

	// Reset comparisons -- remove this loop to transfer from symbol to symbol.
	for (let field in stx.chart.series) {
		// Keep studies.
		if (stxx.chart.series[field].parameters.bucket != "study") stx.removeSeries(field);
	}

	stx.loadChart(data, function (err) {
		if (err) {
			// Add 'symbol not found error' here if one needed.
			if (loader) loader.hide();
			return;
		}
		if (loader) loader.hide();
		CIQ.ChartEngine.restoreDrawings(stx, stx.chart.symbol);
	});

	if (cb) cb(stx);
};

setLookupDriver(driver)

Sets the lookup driver to be used with the cq-lookup web component.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the web components can be found here: Web Component Interface.

The lookup driver is called to search for matching symbols as data is entered in the set UIContext.UISymbolLookup field.

Parameters:
Name Type Description
driver CIQ.ChartEngine.Driver.Lookup

Lookup driver for cq-lookup component.

Example
UIContext = new CIQ.UI.Context(stxx, document.querySelector("cq-context,[cq-context]"));
UIContext.setLookupDriver(new CIQ.ChartEngine.Driver.Lookup.ChartIQ());
UIContext.UISymbolLookup = document.querySelector(".ciq-search cq-lookup");
UIContext.UISymbolLookup.setCallback(function (context, data) {
	context.changeSymbol(data);
});

isModal()

Checks if the context in modal mode.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the web components can be found here: Web Component Interface

Returns:

true if in modal mode

Type
Boolean

setLoader(loader)

Attaches a loader to a UI context.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the web components can be found here: Web Component Interface

Parameters:
Name Type Description
loader CIQ.UI.Loader

Loader instance