Class: DialogHelper

CIQ.Studies. DialogHelper


new DialogHelper(params)

Generates an object that can be used to create a dialog for creating or modifying a study.

The object will then contain arrays for inputs, outputs and parameters.

  • Each output will describe a color swatch that should be generated.
  • Each input will describe a form field that should be generated.
    • If a placeholder attribute of yyyy-mm-dd or hh:mm:ss is set on an input field, the dialog will display a "date" or "time" input type, instead of a string input type.
      Example:
      "AVWAP": {
          "name": "Anchored VWAP",
          "overlay": true,
          "calculateFN": CIQ.Studies.calculateAnchoredVWAP,
          "initializeFN": CIQ.Studies.initAnchoredVWAP,
          "inputs": {"Field":"field", "Anchor Date":"", "Anchor Time":""},
          "outputs": {"VWAP":"#FF0000"},
          "attributes":{
              "Anchor Date": {placeholder:"yyyy-mm-dd"},
              "Anchor Time": {placeholder:"hh:mm:ss", step:1}
          }
      • Actual date/time displays are dependent on browser compatibility.
      • The time is expected to be entered, and will be displayed in the displayZone. It will converted as needed to the dataZone before used internally, so it always matches masterData. See CIQ.ChartEngine#setTimeZone

The results of the dialog would then be passed to CIQ.Studies.addStudy.

Parameters:
Name Type Description
params object

Object containing the following:

Properties
Name Type Argument Description
name string <optional>

The libraryEntry key for the study to add. The libraryEntry is the object that defines the prototype for a study. May contain attributes which are used to help construct the input fields of the study dialog. See documentation of CIQ.Studies.studyLibrary and DialogHelper Object. Not needed if params.sd is present.

sd studyDescriptor <optional>

A study descriptor; when requesting values for an existing study. If present, takes precedence over params.name. You may set the 'panelName' parameter to "panel" (sd.parameters.panelName), and this method will provide in the parameters object an array of valid panels, which you can present to the user as options to move the study to a different panel.

axisSelect boolean <optional>

If set, the helper will include the axis position and color selection in the parameters section.

panelSelect boolean <optional>

If set, the helper will include the panel and underlay selection in the parameters section.

stx CIQ.CIQ.ChartEngine

A chart object

Since:

  • • 6.3.0 Added parameters `axisSelect` and `panelSelect`
    • 6.3.0 If a placeholder attribute of `yyyy-mm-dd` or `hh:mm:ss` is set on an input field, the dialog will display a "date" or "time" input type, instead of a string input type.
Examples
var helper=new CIQ.Studies.DialogHelper({name:"stochastics",stx:stxx});
console.log('Inputs:',JSON.stringify(helper.inputs));
console.log('Outputs:',JSON.stringify(helper.outputs));
console.log('Parameters:',JSON.stringify(helper.parameters));
// how to set the DialogHelper to get a list of all available panels as part of the parameters object
var sd = CIQ.Studies.addStudy(stxx, "Aroon");
var dialogHelper = new CIQ.Studies.DialogHelper({"stx":stxx,"sd":sd, panelSelect:true});
console.log('Parameters:',JSON.stringify(dialogHelper.parameters));
// Create a DialogHelper without an sd
var dialogHelper = new CIQ.Studies.DialogHelper({"stx":stxx,"name":"ma"})

Methods


adjustInputTimesForDisplayZone( [updates])

Adjust all date & time fields in the DialogHelper to use the display zone.

This function can adjust both to and from the display zone depending on the presence of the second argument. When creating the DialogHelper, the second argument is null, and any date and time in the study descriptor's inputs is converted to display zone when stored in the DialogHelper's inputs property. When updating the DialogHelper, the second argument contains any changed fields. If a date or time has been changed, it is converted back from display zone so it can be stored correctly in the study descriptor. It is assumed that the updated date and time are in display zone already. The function adjusts the time by changing the updates object if it is passed, or the inputs property if it is not.

In the example below, it is assumed that there are input fields named "Anchor Date" and "Anchor Time". Whenever you want to set up an input field with date and time, use this convention: Name both fields the same name and add " Date" to one and " Time" to the other.

Parameters:
Name Type Argument Description
updates Object <optional>

If updating, it should contain an object with updates to the inputs object used in CIQ.Studies.addStudy.

Since:
  • 6.3.0
Example
var helper=new CIQ.Studies.DialogHelper({sd:sd, stx:stx});
var updates={inputs:{"Anchor Time":"06:00"}};
helper.adjustInputTimesForDisplayZone(updates});

updateStudy(updates)

Update (or add) the study attached to the DialogHelper.

Once added or modified, the new study descriptor will be stored in the sd object of the DialogHelper. The DialogHelper members will be updated when calling this function to reflect the changes. However, other DialogHelper instances which exist will not be refreshed; for example, options which list all panels or all fields will not contain any new records or have old records removed as a result of another helper's update. In that case, you will need to recreate the helper before reusing it.

Parameters:
Name Type Description
updates Object

If updating, it should contain an object with updates to the inputs, outputs and parameters object used in CIQ.Studies.addStudy. A new study ID will be created using the default format or parameters.replaceID, if provided.

Since:
  • 6.3.0 this instance will refresh after an update; recreating no longer necessary.
Examples
var helper=new CIQ.Studies.DialogHelper({sd:sd, stx:stx});
helper.updateStudy({inputs:{Period:60}});
var updatedStudy = helper.sd;
// add the study
var initialStudy = CIQ.Studies.addStudy(stxx, "Aroon");

// move it to the primary (chart) panel
var dialogHelper = new CIQ.Studies.DialogHelper({"stx":stxx,"sd":initialStudy});
dialogHelper.updateStudy({"parameters":{"panelName":"chart"}});

// move the updated study back to its own panel
dialogHelper.updateStudy({"parameters":{"panelName":"Own panel"}});