Namespace: CIQ

CIQ

Base namespace for CIQ library

Previously STX

Classes

Account
Animation
ChartEngine
Drawing
EaseMachine
ExtendedHours
InactivityTimer
Marker
Market
MarketDepth
NameValueStore
Plotter
RangeSlider
Renderer
Share
TFC
ThemeHelper
Tooltip

Namespaces

Comparison
Extras
I18N
QuoteFeed
Scripting
Studies
UI

Members


ipad :boolean

READ ONLY. Will be 'true' if the chart is running on an iPad

Type:
  • boolean

iphone :boolean

READ ONLY. Will be 'true' if the chart is running on an iPhone

Type:
  • boolean

is_chrome :boolean

READ ONLY. Will be 'true' if the chart is running on a Chrome browser

Type:
  • boolean

isAndroid :boolean

READ ONLY. Will be 'true' if the chart is running on an Android OS device

Type:
  • boolean

isEdge :boolean

READ ONLY. Will be 'true' if the chart is running on a Edge browser

Type:
  • boolean

isFF :boolean

READ ONLY. Will be 'true' if the chart is running on a Firefox browser

Type:
  • boolean

isIE :boolean

READ ONLY. Will be 'true' if the chart is running on a IE browser

Type:
  • boolean

isIE8 :boolean

READ ONLY. Will be 'true' if the chart is running on a IE 8 browser

Type:
  • boolean

isIE9 :boolean

READ ONLY. Will be 'true' if the chart is running on a IE 9 browser

Type:
  • boolean

isIOS7 :boolean

READ ONLY. Will be 'true' if the chart is running on an iOS 7 device

Type:
  • boolean

isIOS7or8 :boolean

READ ONLY. Will be 'true' if the chart is running on an IOS7, IOS8, IOS9 or IOS10 device

Type:
  • boolean

isIOS8 :boolean

READ ONLY. Will be 'true' if the chart is running on an iOS 8 device

Type:
  • boolean

isIOS9 :boolean

READ ONLY. Will be 'true' if the chart is running on an iOS 9 device

Type:
  • boolean

isIOS10 :boolean

READ ONLY. Will be 'true' if the chart is running on an iOS 10 device

Type:
  • boolean

isMobile :boolean

READ ONLY. Will be 'true' if the chart is running on a mobile device ( CIQ.isAndroid, CIQ.ipad, or CIQ.iphone )

Type:
  • boolean

isSurface :boolean

READ ONLY. Will be 'true' if the chart is running on a MS Surface like device

Type:
  • boolean

isSurfaceApp :boolean

READ ONLY. Will be 'true' if the chart is running from a MS Surface application

Type:
  • boolean

isWebComponentsSupported :boolean

READ ONLY. Will be 'true' if the chart supports web components

Type:
  • boolean
Since:
  • 6.1.0

noKeyboard :boolean

READ ONLY. Will be 'true' if the chart is running from a device with no Keyboard ( CIQ.ipad, CIQ.iphone, CIQ.isAndroid or CIQ.isSurfaceApp )

Type:
  • boolean

privateBrowsingAlert :boolean

Set once after user is alerted that private browsing is enabled

Type:
  • boolean

timeZoneMap :object

The comprehensive list of timezones can be overwhelming. This is a reduced list that provides what is necessary for the sample UI.

To see the current list and format, open your browser console and type CIQ.timeZoneMap.

If you need to support more timezones, a complete list can be downloaded from here.

This file is large, so add timezones with discretion. The following code snippet demonstrates how to do this. (You can also just add synonyms this way as well). In order to save space, you may want to cherry pick the zones that you will need, and then add them in your initialization code.

    var myAdditionalZones = {
     "zones" : {
      "America/Toronto": [
       [ 300, "Canada", "E%sT", null ]
      ]
     },
     "rules" : {
      "Canada" : [
       [ 2007, "max", "-", "Mar", "Sun>=8", [ 2, 0, 0, null ], 60, "D" ],
       [ 2007, "max", "-", "Nov", "Sun>=1", [ 2, 0, 0, null ], 0, "S" ] ]
     }
    }

// to add all timezones "zones" and "rules" you can simply load the entire timeZoneDataObject.txt file.
    if(timezoneJS) timezoneJS.timezone.loadZoneDataFromObject(myAdditionalZones);

Lastly, be sure to also add the title for them to the CIQ.timeZoneMap object to keep the list and the settings in sync:

 CIQ.timeZoneMap["(UTC-05:00) Toronto"]="America/Toronto";

See CIQ.ChartEngine#setTimeZone for further instructions on how to set the different timezones on the chart.

Type:
  • object

touchDevice :boolean

READ ONLY. Will be 'true' if the chart is running on a touch capable device

Type:
  • boolean

Methods


addMemberToMasterdata(params)

Convenience function to iterate through the charts masterData and add a data member. Used to load initial data for additional series and study symbols and should normally not be called directly. Unless used inside a study initialize function; use CIQ.ChartEngine#addSeries or CIQ.ChartEngine#updateChartData instead. Can be used with any array of data objects which contains at least the 'DT' (date in javascript format) and 'Close' ( close/last price ) elements of an OHLC object.

Parameters:
Name Type Description
params object

Parameters object

Properties
Name Type Argument Default Description
stx CIQ.ChartEngine <optional>

A chart object

data array <optional>

The data to add (which should align or closely align with the chart data by date)

fields array <optional>

The fields from the incoming data objects to extract and add as the new members in each masterData object. One new member will be added per field using the exact same name as in the incoming data. Example: (for each filed name in the array) masterData[mIterator][fieldN]=data[dIterator][fieldN]. Takes precedence over createObject, label and fieldForLabel parameters. Use fields=["*"] to copy all fields in the data object.

label string <optional>

The name of the new member to add into each masterData object. Example: masterData[mIterator][label]=data[dIterator]["Close"]. Required unless "fields" is specified.

createObject string <optional>

If truthy, then each complete incoming data object will be assigned to the new label member in each masterData object. If set to "aggregate", will consolidate the OHLV data with the new data. The data object is expected to be a properly formatted OHLC record, or at least contain a 'Close' price, otherwise this parameter will not be honored. Example: masterData[mIterator][label]=data[dIterator]. This behavior is mutually exclusive with fields.
If the data object contains a 'Value' field, this parameter will not be honored and instead the 'Value' field will be used as follows: masterData[mIterator][label] = data[dIterator]["Value"];

fieldForLabel string <optional>
"Close"

If set, this will be the field from each incoming data object that will be copied into the new label member in each masterData object. If not set, "Close" or "Value" is used, whichever exists; and if neither exists, it will attempt to copy over a field matching the label name. Example: masterData[mIterator][label]=data[dIterator][fieldForLabel]. This behavior is mutually exclusive with fields and createObject.

fillGaps boolean <optional>

If true then gaps in data will be filled by carrying forward the value of from the previous bar.

noCleanupDates boolean <optional>

If true then dates have been cleaned up already by calling CIQ.ChartEngine#doCleanupDates, so do not do so in here.

chart CIQ.ChartEngine.Chart <optional>

The chart to update

Since:

  • • 04-2015 added
    • 15-07-01 fieldForLabel argument
    • 3.0.0 all data sent in will be forced into the chart. Dates are no longer required to be exact matches (minutes, hours, seconds, milliseconds) in order to show up in comparisons.
    • 4.0.0 Arguments are now parameterized. Backward compatibility with old signature.
    • 4.0.0 Added ability to specify copying of all fields by setting params.fields=["*"]
    • 5.2.0 enhanced parameter `createObject` to take a string
    • 5.2.0 added parameter noCleanupDates
Example
//data element format if neither fields, fieldForLabel or createObject are used
{DT:epoch,Date:strDate,Value:value}
{DT:epoch,Date:strDate,Close:value }
//data element format if fields is used
{DT:epoch,Date:strDate,Field1:value,Field2:value,Field3:value,Field4:value}
//data element format if createObject is used
{DT:epoch,Date:strDate,AnyOtherData:otherData,MoreData:otherData,...}

addResizeListener(element, callback)

Attaches a callback to listen for resize events on the DOM.

Parameters:
Name Type Description
element node
callback function

alert(text)

User friendly alerts. The charting engine always uses this instead of alert() for warning or error messages. This method can be overriden as required by your user interface.

Parameters:
Name Type Description
text string

Alert message

Example
// Override with a friendlier alert mechanism!
CIQ.alert=function(text){
	doSomethingElse(text);
}

appendClassName(node, className)

Appends a class name to a node if it isn't already there. This is frequently used to control dynamic behavior via CSS.

Parameters:
Name Type Description
node object

A valid DOM element

className string

Name of class to add to the DOM element

Example
// Apply an "active" css look to an object
CIQ.appendClassName(myNode, "active");

blur( [node])

Reliable, cross-device blur method

Parameters:
Name Type Argument Description
node HTMLElement <optional>

The element to blur. If not supplied then document.activeElement will be blurred


borderPatternToArray( [width] [, pattern])

Convert a pattern type to an array useful for setting the context.setLineDash

Parameters:
Name Type Argument Default Description
width number <optional>
1

A valid lineWidth from 1

pattern string <optional>
solid

A valid pattern (solid, dotted, dashed)

Since:
  • 4.0.0
Returns:

The array representing pixels of draw/skip etc. Use it as argument to context.setLineDash()

Type
array

boxIntersects(bx1, by1, bx2, by2, x0, y0, x1, y1, vtype, isLog)

Determines whether a line intersects a box. This is used within the charting engine to determine whether the cursor has intersected a drawing. Note this function is meant to receive bx1, by1, bx2, by2, x0, y0, x1 and y1 as pixel values and not as ticks/axis values.

Parameters:
Name Type Description
bx1 number
by1 number
bx2 number
by2 number
x0 number
y0 number
x1 number
y1 number
vtype string

Either "segment", "ray" or "line". Anything else will default to segment.

isLog boolean

True if the chart is in log scale and linear values are passed in

Since:
  • 6.0.0 `isLog` parameter removed
Returns:

Returns true if the line intersects the box

Type
boolean

calculateHeikinAshi(stx, newData, computed)

Calculates Heikin-Ashi values. Takes some unaggregated data and returns aggregated data.

This method is used inside CIQ.ChartEngine#createDataSet to determine the data aggregation logic and should not be called directly. Use CIQ.ChartEngine#setAggregationType instead.

See the Chart types tutorial for details on how to override aggregation type defaults.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

newData array

The data to aggregate. Normally the dataSet.

computed array

Cumulative computed records from last pass through this function. Used to increase performance by reusing pre-calculated bars and only calculate missing new bars.

Version:
  • ChartIQ Advanced Package
Since:

  • • 04-2015-15 added
    • 3.0.0 computed parameter added
Returns:

The aggregated data

Type
array

calculateKagi(stx, newData, reversal, computed)

Calculates Kagi chart values. Takes some unaggregated data and returns aggregated data.

This method is used inside CIQ.ChartEngine#createDataSet to determine the data aggregation logic and should not be called directly. Use CIQ.ChartEngine#setAggregationType instead.

Kagi uses Close method only, not High/Low or ATR

See the Chart types tutorial for details on how to override aggregation type defaults.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

newData array

The data to aggregate. Normally the dataSet.

reversal number

The reversal percentage for the kagi lines. This is typically user configurable. Default is 4% for daily, .4% for intraday.

computed array

Cumulative computed records from last pass through this function. Used to increase performance by reusing pre-calculated bars and only calculate missing new bars.

Version:
  • ChartIQ Advanced Package
Since:

  • • 04-2015-15 added
    • 3.0.0 computed parameter added
Returns:

The aggregated data

Type
array

calculateLineBreak(stx, newData, pricelines, computed)

Calculates Line Break chart values. Takes some unaggregated data and returns aggregated data.

This method is used inside CIQ.ChartEngine#createDataSet to determine the data aggregation logic and should not be called directly. Use CIQ.ChartEngine#setAggregationType instead.

See the Chart types tutorial for details on how to override aggregation type defaults.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

newData array

The data to aggregate. Normally the dataSet.

pricelines number

The number of lines to use for the line break count. This is typically user configurable. Default is 3.

computed array

Cumulative computed records from last pass through this function. Used to increase performance by reusing pre-calculated bars and only calculate missing new bars.

Version:
  • ChartIQ Advanced Package
Since:

  • • 04-2015-15 added
    • 3.0.0 computed parameter added
Returns:

The aggregated data

Type
array

calculatePointFigure(stx, newData, pandf, computed)

Calculates Point and Figure (P&F) chart values. Takes some unaggregated data and returns aggregated data.

This method is used inside CIQ.ChartEngine#createDataSet to determine the data aggregation logic and should not be called directly. Use CIQ.ChartEngine#setAggregationType instead.

See the Chart types tutorial for details on how to override aggregation type defaults.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

newData array

The data to aggregate. Normally the dataSet.

pandf object

The parameters for point and figure.

Properties
Name Type Argument Description
box number <optional>

The box size. Default is automatically determined based on the price.

reversal number <optional>

The reversal amount, in boxes. Default is 3.

computed array

Cumulative computed records from last pass through this function. Used to increase performance by reusing pre-calculated bars and only calculate missing new bars.

Version:
  • ChartIQ Advanced Package
Since:
  • 3.0.0 computed parameter added
Returns:

The aggregated data

Type
array

calculateRangeBars(stx, newData, range, computed)

Calculates range bars. Takes some unaggregated data and returns aggregated data.

This method is used inside CIQ.ChartEngine#createDataSet to determine the data aggregation logic and should not be called directly. Use CIQ.ChartEngine#setAggregationType instead.

See the Chart types tutorial for details on how to override aggregation type defaults.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

newData array

The data to aggregate. Normally the dataSet.

range number

The price range for the range bars. This is typically user configurable. Defaults to a ramge size so that about 300 bars worth of time are displayed; about a year for a daily chart, about 5 hours on a minute chart.

computed array

Cumulative computed records from last pass through this function. Used to increase performance by reusing pre-calculated bars and only calculate missing new bars.

Version:
  • ChartIQ Advanced Package
Since:
  • 3.0.0 computed parameter added
Returns:

The aggregated data

Type
array

calculateRenkoBars(stx, newData, range, computed)

Calculates Renko bars. Takes some unaggregated data and returns aggregated data.

This method is used inside CIQ.ChartEngine#createDataSet to determine the data aggregation logic and should not be called directly. Use CIQ.ChartEngine#setAggregationType instead.

Renko bars use Close method only, not High/Low or ATR

See the Chart types tutorial for details on how to override aggregation type defaults.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

newData array

The data to aggregate. Normally the dataSet.

range number

The brick size for the renko bars. This is typically user configurable. Defaults to a brick size so that about 300 bars worth of time are displayed; about a year for a daily chart, about 5 hours on a minute chart.

computed array

Cumulative computed records from last pass through this function. Used to increase performance by reusing pre-calculated bars and only calculate missing new bars.

Version:
  • ChartIQ Advanced Package
Since:
  • 3.0.0 computed parameter added
Returns:

The aggregated data

Type
array

calculateTradingDecimalPlaces(params)

Determines how many decimal places the security trades. This is a callback from CIQ.ChartEngine.calculateTradingDecimalPlaces and you can override this with your own functionality. The default algorithm is to check the most recent 50 quotes and find the maximum number of decimal places that the stock has traded. This will work for most securities but if your market data feed has rounding errors or bad data then you may want to supplement this algorithm that checks the maximum value by security type.

Parameters:
Name Type Description
params object

Parameters

Properties
Name Type Description
stx CIQ.ChartEngine

The chart object

chart CIQ.ChartEngine.Chart

The chart in question

symbol object

The symbol object. If you create charts with just stock symbol then symbolObject.symbol will contain that symbol

Returns:

The number of decimal places

Type
number

chooseForegroundColor(backgroundColor)

Chooses either a white or black foreground color depending on the "lightness" of the background color. Note that this simply checks if the value is above the hue which works well but not ideally for red colors which the human eye interprets differently. More complex algorithms are available but chartists rarely use red as a background color.

Parameters:
Name Type Description
backgroundColor string

The background color (CSS format)

Returns:

Either #000000 (black) or #FFFFFF (white) depending on which will look best on the given background color

Type
string

cleanPeriodicity(period [, interval], timeUnit)

Convenience function to convert API periodicity parameters to internal periodicity format.

Parameters:
Name Type Argument Description
period string

The period value as required by CIQ.ChartEngine#setPeriodicity

interval string <optional>

The interval value as required by CIQ.ChartEngine#setPeriodicity

timeUnit string

The timeUnit value as required by CIQ.ChartEngine#setPeriodicity

Since:
  • 5.1.1
Returns:

object containing internally compliant periodicity,interval, timeUnit

Type
object

clearCanvas(canvas [, stx])

Animation Loop Clears the canvas. Uses the fastest known method except on the legacy Android browser which had many problems!

Parameters:
Name Type Argument Description
canvas object

A valid HTML canvas object

stx object <optional>

A chart object, only necessary for old Android browsers on problematic devices


clearNode(node)

Removes all DOM elements in a given node. This is extremely useful when dynamically generating content.

Parameters:
Name Type Description
node object

The node to clear


clearSafeClickTouches(div)

Clears all safeClickTouch events from a DOM element.

Parameters:
Name Type Description
div object

The DOM element to clear events


clone(from [, to])

Clones an object. This function creates a deep (recursive) clone of an object. The object can be a primitive or an object or an array. Note that cloning objects that reference DOM nodes can result in stack overflows. Use with caution.

Parameters:
Name Type Argument Description
from object

The source object

to object <optional>

Optional existing object of same type. Can improve performance when objects are reusable.

Returns:

A deep clone of the "from" object

Type
object

colorsEqual(color1, color2)

Checks if two colors are the same. Will compare alpha channel is provided as well.

Parameters:
Name Type Description
color1 string

First color, in rgb, rgba, css hex, or literal format

color2 string

Second color, in rgb, rgba, css hex, or literal format

Since:
  • 4.0.0
Returns:

true if equivalent

Type
boolean
Example
var isSame=CIQ.colorsEqual("rgba (255,255,255,0.3)", "#FFFFFF");
		returns false
var isSame=CIQ.colorsEqual("rgba (255,255,255,1)", "#FFFFFF");
		returns true

colorToHex(color)

Converts an rgb or rgba color to a hex color

Parameters:
Name Type Description
color string

The rgb or rgba color, such as in CSS format

Since:
  • 4.0.0 Converts 3 char hex (#FFC) to six characters (#FFFFCC)
Returns:

The hex color. If "transparent" or no color is sent in, #000000 will be assumed

Type
string
Example
var hexColor=CIQ.colorToHex("rgba (255,255,255,0.3)");

commas(val)

Returns a string representation of a number with commas in thousands, millions or billions places. Note that this function does not handle values with more than 3 decimal places!!!

Parameters:
Name Type Description
val number

The value

Returns:

The result with commas

Type
string
Example
// Returns 1,000,000
CIQ.commas(1000000);

computeEquationChart(equation, map)

Computes an equation that may contain symbols and simple arithmetic operators. Parentheses can be used to separate portions of the equation. PEMDAS priority is observed. Symbols can be optionally contained within brackets. Valid examples: 3IBM, 4+(IBM2), (IBM-GM)/2 If the equation cannot be resolved an exception is thrown.

Parameters:
Name Type Description
equation string

The equation to compute.

map Object

A map of symbols to data

Version:
  • ChartIQ Advanced Package
Returns:

A consolidated array of equation results

Type
Array

condenseInt(txt)

Condenses a number into abbreviated form by adding "k","m","b" or "t". This method is used in the y-axis for example with volume studies.

Parameters:
Name Type Description
txt number

A numerical value

Since:
  • 4.0.0 now returns `txt` untouched if under 1000. Previously was removing all decimal places.
Returns:

Condensed version of the number if over 999, otherwise returns txt untouched

Type
string
Example
// This will return 12m
condenseInt(12000000);

convertBoxToPixels( [stx], panelName, box)

Converts a box represented by two corner coordinates [tick0,value0] and [tick1,value1] into pixel coordinates.

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine <optional>

The chartEngine

panelName string

Panel on which the coordinates reside

box object

Box to convert

Properties
Name Type Argument Description
x0 number <optional>
y0 number <optional>
x1 number <optional>
y1 number <optional>
Since:
  • 6.0.0
Returns:

A converted box

Type
object

convertClickToTouchEnd(id)

Converts an onClick event to an ontouchend event. If the device is known to be a touch device then this can be used to change onclick events that are set as attributes (in HTML). ontouchend events are more responsive than onclick events and can improve the user experience. When coding for cross-device implementations it is recommended to use CIQ.safeClickTouch programmatically rather than using hardcoded attributes

Parameters:
Name Type Description
id string

The id of a node containing an onClick attribute

Since:
  • 6.0.0 deprecated
Deprecated:
  • Yes

convertCurrencyCode(code)

Converts a currency code from ISO to char

Parameters:
Name Type Description
code string

The string to convert, e.g. USD

Returns:

The converted string, e.g. $

Type
string

convertFutureMonth(x)

Converts a future month to the month index or vice versa. Month indexes begin with 1 for January

Parameters:
Name Type Description
x char

The value to convert. If numeric, will convert to Future month letter. If Alpha, will convert to month index.

Returns:

Converted value

Type
char

convertTimeZone(dt, originalTimeZone, targetTimeZone)

Converts a Date object from one time zone to another using the timezoneJS.Date library

Parameters:
Name Type Description
dt date

Original JavaScript Date object, from the original time zone

originalTimeZone string

The original time zone

targetTimeZone string

The target time zone

Returns:

The date in the target timezone. This is a timezoneJS.Date which behaves the same as a native Date.

Type
date

convertToLocalTime(dt, originalTimeZone)

This method converts a time from another timezone to local time on the browser

Parameters:
Name Type Description
dt date

The original time

originalTimeZone string

A valid timezone

Returns:

The date converted to local time

Type
date

convertToNativeColor(color)

Converts a color to the internal format used by the browser. This allows interchange of hex, rgb, rgba colors

Parameters:
Name Type Description
color string

A CSS color

Returns:

The native formatted color

Type
string

countDecimals(n)

Convenience function to count number of decimal places in a number

Parameters:
Name Type Description
n number

The number to check

Since:
  • TBD now handles scientific notation
Returns:

Number of decimal places

Type
number

createLabel(params)

Adds text on the canvas for the floating label over the y axis.

Uses native canvas functions to add the text. You can override this function if you wish to customize how the text on the floating y axis labels are displayed. See example.

Parameters:
Name Type Description
params object
Properties
Name Type Description
ctx object

A valid HTML Canvas Context

x number

Left position of drawing on canvas

txt number

Text for the lavel

y number

Y position of drawing on canvas

margin object

Margin around the text

Properties
Name Type Description
left object

Left margin of text

top object

Top margin of text

backgroundColor number

Background color of the shape drawn under the text, if any. This is used to find the text color if there is no color specified

color number

Text color

Since:
  • 3.0.0 - New Function
Example
// customized version which adds a dash before the label text 
		CIQ.createLabel=function(params){
			// set the vertical alignment of the text 
			params.ctx.textBaseline="middle";
			
			// set the color for the text and background color behind the text
			params.ctx.fillStyle=params.color?params.color:CIQ.chooseForegroundColor(params.backgroundColor);
			
			if(	params.ctx.fillStyle === params.backgroundColor){	
				// Best effort to pick a foreground color that isn't the same as the background!
				if(params.backgroundColor.toUpperCase()=="#FFFFFF")
					params.ctx.fillStyle="#000000";
				else
					params.ctx.fillStyle="#FFFFFF";
			}
			
			//add the text to the canvas.
			// see we are adding a dash ('- ') before the text
			params.ctx.fillText('- '+params.txt, params.x + params.margin.left, params.y + params.margin.top);
			
			// set the horizontal alignment of the text  
			params.ctx.textAlign="left";
		};

createObjectChainNames(field, properties)

Create arrow notation strings (field-->property) of a given field and an array of properties Used to create a set of object properties in string format for later use by CIQ.existsInObjectChain Its main use is to pass field names into CIQ.ChartEngine#determineMinMax.

Parameters:
Name Type Description
field string

Base object.

properties array

Array of strings representing properties

Since:
  • 5.1.0
Returns:

Array of object properties expressed in arrow notation (field-->property)

Type
array
Example
var fields=CIQ.createObjectChainNames("ABC.D",["High","Low"]);
fields===["ABC.D-->High","ABC.D-->Low"]

dataBindSafeAssignment(target, source)

This method changes the target object's contents to match the contents of the source object. This is functionally equivalent to target=source except that it preserves the existence of the target object. This is vitally important if there are data bindings to the target object otherwise those data bindings would remain attached to a phantom object! The logic here is orchestrated so that you will receive update, add and delete notifications for each field that changes.

Parameters:
Name Type Description
target object

The target object

source object

The source object

Since:
  • 2015-11-1

deleteRHS(map, object)

Deletes the map entries for which the right hand side is the object in question.

Parameters:
Name Type Description
map object

JavaScript map object

object object

The actual object to be deleted from the map

Returns:

Returns true if any object actually deleted

Type
boolean

derivedFrom(child, parent)

Replacement for isPrototypeOf and instanceof so that both types of inheritance can be checked

Parameters:
Name Type Description
child object

The object instance to check

parent object

Prototype

Since:
  • 07/01/2015
Returns:

True if the object is derived from the parent

Type
boolean

deriveFromObjectChain(base, extension)

Given a dot notation string, we want to navigate to the location in a base object, creating the path along the way

Parameters:
Name Type Description
base object

Base object.

extension string

String in dot notation

Since:
  • 2015-11-1
Returns:

A tuple containing obj and member

Type
object
Example
var tuple=CIQ.deriveFromObjectChain(stx.layout, "pandf.box");
tuple.obj===stx.layout.pandf
tuble.member==="box"
tuple.obj[tuple.member]=3;  // stx.layout.pandf.box=3

displayableDate(stx, chart, dt)

Displays a date according to the current chart settings and periodicity. It will format the date according to the folllowing order:

  1. xAxis formatter
  2. Internationalization
  3. default
     a. Daily: mm-dd-yyyy
     b. Intraday: mm/dd hh:mm[:ss[:ms]]

This method is used in CIQ.ChartEngine.AdvancedInjectable#headsUpHR to format the floating label over the x axis, and can be overitten as needed to achieve the desired results.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The charting object

chart CIQ.ChartEngine.Chart

The specific chart

dt date

JavaScript date

Since:
  • 4.0.0
Returns:

Formatted date

Type
string

drawLegend(stx, params)

Draws a legend for the series that are displayed on the chart.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object to draw

params object

parameters for drawing the legend

Properties
Name Type Argument Description
chart CIQ.ChartEngine.Chart <optional>

The chart object

legendColorMap object <optional>

A map of series names to colors and display symbols ( example IBM:{color:'red', display:'Int B M'} )

coordinates object <optional>

Coordinates upon which to draw the items, in pixels relative to top left of panel ( example {x:50, y:0} ). If null, uses chart.legend

noBase boolean <optional>

Set to true to not draw the base (the chart symbol's color) in the legend


drawLegendItem(stx, xy, label, color)

Draws an item in the legend and returns the position for the next item

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

xy array

An X,Y tuple (from chart.legend)

label string

The text to print in the item

color string

The color for the background of the item

Returns:

A tuple containing the X,Y position for the next the item

Type
array

efficientDOMUpdate(node, member, value)

Sets a member or style for a DOM element only if it isn't already set. This is more efficient than blindly updating the DOM.

Parameters:
Name Type Description
node HTMLElement

Node to update

member string

The DOM member to update

value string

The value to set

Since:
  • 4.0.0

ensureDefaults(target, defaults)

Accepts a default parameters object and sets the field values for the target only if they are missing. Note that a value of null will not be overridden. Only undefined (missing) values will be overridden.

Parameters:
Name Type Description
target object

The object needing potential default values

defaults object

Default values

Since:
  • 3.0.0
Returns:

Returns the modified target object

Type
object
Example
var target={"color":"red"};
var defaults={"color":"blue", "shape":"triangle"};
CIQ.ensureDefaults(target, defaults);
>> target==={"color":"red", "shape":"triangle"};

equals(a, b [, exclude])

Returns true if the objects are an exact match

Parameters:
Name Type Argument Description
a object

First object

b object

Second object

exclude object <optional>

Exclude these fields

Returns:

True if they are an exact match

Type
boolean

existsInObjectChain(base, extension)

Given an arrow notation string (a-->b-->c), we want to navigate to the location in a base object, to see if it exists

Parameters:
Name Type Description
base object

Base object.

extension string

String in arrow notation

Since:
  • 5.1.0
Returns:

A tuple containing obj and member; a null will be returned if path does not exist

Type
object
Example
var tuple=CIQ.existsInObjectChain(stx.dataSegment[0], "ABC.D-->High");
tuple.obj===stx.dataSegment[0]["ABC.D"]
tuple.member==="High"
tuple.obj[tuple.member]=28.7;  // stx.dataSegment[0]["ABC.D"].High=28.7

extend(target, source [, shallow])

Extends an object, similar to jquery.extend() with a deep copy

Only does a recursive deep copy if the source is plain object.

Parameters:
Name Type Argument Description
target object

Target object

source object

Original object

shallow boolean <optional>

If true then extend will not recurse through objects

Since:

  • • 5.1.0 Undefined properties do not copy to target object
    • 5.2.0 Target of a deep copy may now be a class instance
Returns:

Target object after extension

Type
object

fetchEquationChart(params, cb)

Extracts symbols from an equation and fetches the quotes for them.

Parameters:
Name Type Description
params object

Parameters used for the fetch

cb function

Callback function once all quotes are fetched

Version:
  • ChartIQ Advanced Package

fillArea(stx, points, params)

Fills an area on the chart, usually created by a study.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

points array

The set of points, this is an array of chart coordinates in array form e.g. [[x1,y1],[x2,y2]]. The points should be arranged to form a loop; the loop need not be closed.

params object

parameters

Properties
Name Type Argument Description
color string <optional>

color to fill the area

opacity number <optional>

opacity of fill, 0 to 1. Defaults to 0.1

tension number <optional>

Tension for splining. Requires "js/thirdparty/splines.js"

panelName string <optional>

Name of panel to draw on. If omitted or invalid, area may fill over top or bottom of plot area

yAxis CIQ.ChartEngine.YAxis <optional>

The y-axis for the area (will use default axis if not specified)

Since:

  • • 01-2015-20 `params.panelName` added
    • 4.0.0 Combined arguments into params, added tension
    • 5.2.0 `params.yAxis` added

fillIntersecting(stx, panelName, parameters)

Fills an area on the chart delimited by intersecting bands.

Bands can be anchored by different y-axis as determined by the parameters.topAxis and parameters.bottomAxis parameters.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

panelName string

The name of the panel

parameters object

The configuration parameters

Properties
Name Type Argument Description
topBand string

The name of the quote field to use as the top band

bottomBand string

The name of the quote field to use as the bottom band

topSubBand string <optional>

Name of the field within the top band to use, for example when plotting a series

bottomSubBand string <optional>

Name of the field within the bottom band to use, for example when plotting a series

topColor string

The color of the top band, used to fill in a cloud whose top edge is the topBand

bottomColor string

The color the bottom band, used to fill in a cloud whose top edge is the bottomBand

tension number <optional>

Tension for splining. Requires "js/thirdparty/splines.js"

topAxis CIQ.ChartEngine.YAxis

The y-axis for the top band (will use default axis if not specified)

bottomAxis CIQ.ChartEngine.YAxis

The y-axis for the bottom band (will use default axis if not specified)

skipTransform boolean

If true then any transformations (such as comparison charting) will not be applied

opacity number

The color opacity/transparency as a decimal number (1= full opacity / no transparency). Default is 0.3.

Since:

  • • 4.0.0 Changed `sd` argument to `panelName` argument, added `parameters.topColor`, `parameters.bottomColor`, `parameters.opacity` and `parameters.skipTransform`, removed `parameters.fillFuture`
    • 4.1.2 Removed quotes argument; function always uses dataSegment.
Example
var parameters={
			topBand: "Leading Span A " + sd.name,
			bottomBand: "Leading Span B " + sd.name,
			topColor: "green",
			bottomColor: "red"
		};
		CIQ.fillIntersecting(stx, sd.panel, parameters)

fillTransparentCanvas(context, color, width, height)

Sets the transparent parts of the canvas to the specified background color. Used to ensure a background when turning charts into images because normally the background is the background of the DIV container and not the canvas itself.

Parameters:
Name Type Description
context object

An HTML canvas context

color string

The color to set the background. Any valid HTML canvas color.

width number

Width to apply color (Could be less than size of canvas)

height number

Height to apply color (Could be less than size of canvas if applying branding for instance)


findNodesByText(startNode, text)

Find all nodes that match the given text. This is a recursive function so be careful not to start too high in the DOM tree.

Parameters:
Name Type Description
startNode object

A valid DOM element from which to start looking

text string

The text to search for

Returns:

An array of nodes that match the text

Type
array

first(o)

Convenience function returns the first property in an object. Note that while this works in all known browsers the EMCA spec does not guarantee that the order of members in an object remain static. This method should therefore be avoided. When ordering is important use an Array!

Parameters:
Name Type Description
o object

A JavaSCript object

Returns:

The first element in the object or null if it is empty

Type
object

fixPrice(price)

Given a numeric price that may be a float with rounding errors, this will trim off the trailing zeroes

Parameters:
Name Type Description
price number

The price

Returns:

The price trimmed of trailing zeroes

Type
number

fixScreen()

Fixes screen scroll. This can occur when the keyboard opens on an ipad or iphone.


focus(node, useTimeout)

Microsoft surface bug requires a timeout in order for the cursor to show up in a focused text box. iPad also, sometimes, when embedded in an iframe, so set useTimeout if in an iframe!

Parameters:
Name Type Description
node object

A DOM element to focus

useTimeout number

Whether to apply a timeout or not. If number then the number of milliseconds.


formatEquation(equation)

Extracts symbols from an equation. An equation can consist of symbols and the following operators: +-/*%() PEMDAS order is followed. Additionally, symbols can be enclosed in brackets [] to treat them as literal non-parseables.

Parameters:
Name Type Description
equation string

The equation to parse (e.g. IBM+GE)

Version:
  • ChartIQ Advanced Package
Returns:

Parsed equation, {equation: [formatted equation], symbols: [array of symbols found in the equation]}

Type
object

friendlyDate(dt)

Converts a date into yyyy/mm/dd hh:mm format

Parameters:
Name Type Description
dt date

A JavaScript Date object

Returns:

Date in yyyy/mm/dd hh:mm format

Type
string

fromET(est)

Converts a JavaScript date from Eastern Time Zone to the browser's local time zone. Daylight Savings Time is hard coded. @see CIQ.getETDateTime

Parameters:
Name Type Description
est date

JavaScript Date object representing a date/time in eastern time zone

Returns:

JavaScript Date object converted to browser's local time zone

Type
date

getAjaxServer(url)

Gets an Ajax server dependent on browser method. If IE9 and a cross domain request then XDomainRequest() will be used rather than XMLHttpRequest.

Parameters:
Name Type Description
url string

The url to connect with

Returns:

An ajax server

Type
object

getBackgroundColor(el)

Gets the background color of an element by traversing up the parent stack.

Parameters:
Name Type Description
el HTMLElement

The element to examine

Returns:

The background color

Type
string

getETDateTime()

Gets the current time in Eastern Time Zone. This can be used as a convenience for determining open and closing times of US markets.

Returns:

JavaScript Date representing the time in Eastern Time Zone

Type
date

getEventDOM( [e])

Get the source element for a DOM event depending on browser type

Parameters:
Name Type Argument Description
e object <optional>

Event if available from browser

Returns:

The DOM node that registered the event

Type
object

getHostName(url)

Returns the host portion of a url

Parameters:
Name Type Description
url string

The url, such as document.location.href

Returns:

The host portion, including port, if the url is a valid URI

Type
string

getLines(ctx, phrase, l)

Turns a portion of raw text into multi-line text that fits in a given width. This is used for autoformatting of annotations

Parameters:
Name Type Description
ctx object

A valid HTML Canvas Context

phrase string

The text

l number

The width in pixels to fit the text within on the canvas

Returns:

An array of individual lines that should fit within the specified width

Type
array

getYearDay( [dt])

Gets the day of the year

Parameters:
Name Type Argument Description
dt date <optional>

optional The date to check. If omitted, will use the current date.

Returns:

Day of year

Type
number

hasClassName(node, className)

Returns true if a class name is currently assigned to the DOM node

Parameters:
Name Type Description
node object

A valid DOM element

className string

The class name to search for

Returns:

True if the class name is currently assigned to the DOM node

Type
boolean

hexToRgba(color, opacity)

Converts color to rgba. This does not accept literal color names such as "black"

Parameters:
Name Type Description
color string

The hex rgb or rgba color, such as in CSS format

opacity number

The 'alpha' value. Defaults to full opacity (100%)

Returns:

The rgba color

Type
string
Example
var rgba=CIQ.hexToRgba('rgb(0, 115, 186)');
var rgba=CIQ.hexToRgba('#0073BA');

hideByText(startNode, text)

Hide nodes that match a certain text string.

Parameters:
Name Type Description
startNode object

A valid DOM element from which to start looking

text string

The text to match against CIQ.findNodesByText


hideKeyboard( [newFocus])

Closes the keyboard on a touch device by blurring any active input elements.

Parameters:
Name Type Argument Description
newFocus HTMLElement <optional>

Element to change focus to


hsv(color)

Converts a color from hex or rgb format to Hue, Saturation, Value. This does not accept literal color names such as "black"

Parameters:
Name Type Description
color string

The color (from CSS)

Returns:

[Hue, Saturation, Value], or null if invalid color.

Type
array

innerHTML(node, html)

Microsoft RT disallows innerHTML that contains DOM elements. Use this method to override when necessary.

Parameters:
Name Type Description
node object

A valid DOM element to change innerHTML

html string

The html text to change

Example
CIQ.innerHTML(node, "My innerHTML contains <span>a span</span> and MS RT doesn't like that");

inputKeyEvents(node, cb)

Captures enter key events. Also clears the input box on escape key.

Parameters:
Name Type Description
node object

The DOM element to attach the event to. Should be a text input box.

cb function

Callback function when enter key is pressed.


installTapEvent(div [, params])

Converts an object to emit "stxtap" events. This uses CIQ#safeClickTouch. You should use addEventListener("tap") to receive the events.

Parameters:
Name Type Argument Description
div HTMLElement

The element to convert

params object <optional>

Parameters to pass to CIQ#safeClickTouch

Properties
Name Type Argument Default Description
stopPropagation boolean <optional>
false

If set to true then propagation will be stopped

Since:
  • 04-2015

intersectLineLineX()

Get the X intersection point between two lines


intersectLineLineY()

Get the Y intersection point between two lines


isDST( [dt])

DST checker. Returns whether input date is in DST

Parameters:
Name Type Argument Description
dt date <optional>

optional The date to check. If omitted, will use the current date.

Returns:

True for DST, false for not.

Type
boolean

isEmpty(o)

Returns true if an object has no members

Parameters:
Name Type Description
o object

A JavaScript object

Returns:

True if there are no members in the object

Type
boolean

isTransparent(color)

Returns true if the color is transparent. In particular it checks rgba status. Note that the charting engine often interprets transparent colors to mean that a color should be automatically determined based on the brightness of the background.

Parameters:
Name Type Description
color string

The color (from CSS)

Returns:

True if transparent

Type
boolean

isValidNumber(n)

Convenience function to determine if a value is a valid number.

Parameters:
Name Type Description
n number

The number to check

Since:
  • 5.2.2
Returns:

True if n is a real finite number. NaN, Infinity, null, undefined, etc are not considered to be a valid number.

Type
boolean

last(o)

Convenience function for returning the last property in an object. Note that while this works in all known browsers the EMCA spec does not guarantee that the order of members in an object remain static. This method should therefore be avoiding. When ordering is important use an Array!

Parameters:
Name Type Description
o object

A JavaScript object

Returns:

The final member of the object or null if the object is empty

Type
object

linesIntersect(x1, x2, y1, y2, x3, x4, y3, y4, type)

Determines whether two lines intersect

Parameters:
Name Type Description
x1 number
x2 number
y1 number
y2 number
x3 number
x4 number
y3 number
y4 number
type string

Either "segment", "ray" or "line"

Returns:

Returns true if the two lines intersect

Type
boolean

loadScript(scriptName, cb)

Loads JavaScript dynamically. This method keeps a static memory of scripts that have been loaded to prevent them from being loaded twice. The callback function however is always called, even if the script has already been loaded.

Parameters:
Name Type Description
scriptName string

The url of the script to load

cb function

Callback function to call when the script is loaded


loadStylesheet(stylesheet, cb)

Loads a stylesheet.

Parameters:
Name Type Description
stylesheet string

Name of stylesheet file.

cb function

Function to call when the stylesheet is fully loaded

Since:
  • 2016-03-11

loadUI(url, el, cb)

Dynamically load UI elements from an external HTML file. This is accomplished by rendering raw HTML in an iframe and then cloning all of the newly created DOM elements into our main document. The iframe is then removed.

The title of the iframe is checked. External content should not have a title. By convention, 404 or 500 errors have a title and so we use this to determine whether the iframe contains valid content or not.

Parameters:
Name Type Description
url string

The external url to fetch new UI content

el HtmlElement

Element to append the UI content to, default is document.body

cb function

A callback function to call when the new UI is available

Since:
  • 6.1.0 added el argument

loadWidget(widget, el, cb)

Loads a feature function widget. Feature function widgets consist of a css file, a JS file and an HTML file. This can be used to dynamically load content and functionality.

Parameters:
Name Type Description
widget string

Name of widget. The js, css and html files should be this name.

el HtmlElement

Element to append the UI content to, default is document.body

cb function

Function to call when the widget is fully loaded

Since:
  • 6.1.0 added el argument

localStorageSetItem(name, value)

Convenience function for storing a name value pair in local storage. This will detect if private browsing is enabled because localStorage is inoperable under private browsing

Parameters:
Name Type Description
name string

Name to store

value string

Value to store


log10(y)

Returns the log base 10 of a value

Parameters:
Name Type Description
y number

The value

Returns:

log10 value

Type
number

makeCamelCase(name)

Converts from hyphenated to camel case. Used primarily for converting css style names (which are hyphenated) to property values (which are camel case)

Parameters:
Name Type Description
name string

Hyphenated style name

Returns:

Camel case style name

Type
string

minMax(series, field, subField, highLow)

This method will return an tuple [min,max] that contains the minimum and maximum values in the series where values are series[field]

Parameters:
Name Type Description
series array

The series

field string

The name of the series to look at

subField string

The name of the field within the series to look at

highLow boolean

True when comparing max High/min Low vs a specific field

Since:
  • 5.1.0 added subField, highLow arguments
Returns:

Tuple containing min and max values in the series

Type
array

mmddhhmm(strdt)

Converts a string form date into mm-dd hh:mm format

Parameters:
Name Type Description
strdt string

Date in string format (such as yyyymmddhhmm, yyyy-mm-dd hh:mm, etc)

Since:
  • 5.0.0 will output seconds and millis if present
Returns:

Date in mm-dd hh:mm format

Type
string

mmddyyyy(dt)

Converts a JavaScript Date or string form date to mm/dd/yyyy format

Parameters:
Name Type Description
dt string

Date in JavaScript Date or string format such as YYYY-MM-DD

Since:
  • 2016-07-16
Returns:

Date in mm/dd/yyyy format

Type
string

money(val [, decimals] [, currency])

Prints out a number in US Dollar monetary representation

Parameters:
Name Type Argument Default Description
val number

The amount

decimals number <optional>
2

Number of decimal places.

currency string <optional>

Currency designation. If omitted, will use $.

Returns:

US Dollar monetary representation // Returns $100.00 CIQ.money(100, 2);

Type
string

monthAsDisplay(i, displayLetters [, stx])

Convenience function for creating a displayable month name using CIQ.monthLetters and CIQ.monthAbv. Please note that those arrays may not be utilized if the library is used in conjunction with Internationalization. This method is used primarily to create the x-axis of a chart

Parameters:
Name Type Argument Description
i number

The numerical month (0-11)

displayLetters boolean

True if just the first letter should be displayed (such as a tight display)

stx object <optional>

The chart object, only necessary if Internationalization is in use

Returns:

String representation of the month

Type
string

newChild(div, tagName [, className] [, txt])

Convenience function for dynamically creating a new node and appending it into the DOM.

Parameters:
Name Type Argument Description
div object

The targeted parent node

tagName string

The type of node to be created

className string <optional>

Optional class name to set the new node

txt string <optional>

Optional text to insert

Returns:

The new node

Type
object

noop(params)

Displays floating text label, without any background shapes, over the y axis.

Calls CIQ.createLabel; which can be customized to control the text format for these labels. Will draw text in the color normally used for the background shape. For example, 'green' text for the up tick and 'red' text for a down tick.

Visual Reference:
noop

Parameters:
Name Type Description
params object
Properties
Name Type Description
ctx object

A valid HTML Canvas Context

x number

Left position of drawing on canvas

txt number

Text for the lavel

y number

Y position of drawing on canvas

margin object

Margin around the text

Properties
Name Type Description
left object

Left margin of text

top object

Top margin of text

backgroundColor number

Text color; since there is no background shape.

Since:
  • 5.2.1 - Will now draw text in the color normally used for the background shape. For example, 'green' text for the up tick and 'red' text for a down tick.

objLength(o)

Returns the number of members in an object

Parameters:
Name Type Description
o object

A valid JavaScript object

Returns:

The number of members in the object

Type
number

outerWidth(node)

Returns the width of a DOM element including left and right margins.

Parameters:
Name Type Description
node HTMLElement

The DOM element to measure

Returns:

The width including margins

Type
number

pageHeight()

Returns the height of the page. It is aware of iframes and so will never return a value that is greater than the value of the parent

Returns:

Height of page in pixels

Type
number

pageWidth()

Returns the width of the page. It is aware of iframes and so will never return a value that is greater than the value of the parent

Returns:

Width of page in pixels

Type
number

postAjax(params, arg1, arg2, arg3, arg4)

Convenience function for making an ajax post. If payload is non-null then the method will be set to POST, otherwise GET. Cross origin ajax is support on IE9.

Parameters:
Name Type Description
params object

Parameters for the post

Properties
Name Type Argument Description
url string <optional>

The url to send the ajax query to

payload string <optional>

An optional payload to send

cb CIQ.postAjax~requestCallback <optional>

Callback function when complete

contentType string <optional>

Optionally override the content type

noEpoch boolean <optional>

By default the epoch is appended as a query string to bust caching. Set this to false to not append the epoch.

method string <optional>

Optionally override the HTTP method

headers array <optional>

Optional additional HTTP headers to send

responseHeaders boolean <optional>

Optional Set to true to have callback passed the response headers from the server

timeout number <optional>

Optional Request timeout in msec. If omitted, timeout is default (no timeout)

ungovernable boolean <optional>

Optional If true, request not subject to rate limiting

arg1 string

Payload

arg2 function

Callback

arg3 string

Ajax content type

arg4 boolean

Set to true for no epoch

Since:
  • 3.0.0 Added timeout and ungovernable params
Returns:

True if there were no errors fetching data.

Type
boolean

prepareChannelFill(stx, parameters)

Fills an area on the chart delimited by non intersecting top and bottom bands (channel), usually created by a study.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

parameters object

The configuration parameters

Properties
Name Type Description
panelName string

The name of the panel

noSlopes boolean

If set then chart will fill rectangles with no transition lines between levels

topBand string

The name of the quote field to use as the top band

bottomBand string

The name of the quote field to use as the bottom band

opacity number

The color opacity/transparency as a decimal number (1= full opacity / no transparency)

color string

The fill color

Since:
  • 4.1.2 Removed quotes argument; function always uses dataSegment.
Example
CIQ.prepareChannelFill(stx,{"color":dngradient,"opacity":1,"panelName":sd.name,"topBand":"Zero "+sd.name,"bottomBand":"Under "+sd.name});

preparePeakValleyFill(stx, parameters)

Fills an area on the chart delimited by a series line closed off by a horizontal threshold line, usually created by a study.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

parameters object

The configuration parameters

Properties
Name Type Argument Description
panelName string <optional>

The name of the panel

band string <optional>

The name of the quote field to use as the series line

threshold number <optional>

The price where the horizontal line hits yaxis/series to enclose the fill area. If not set will look to parameters.reverse to determine if threshold is the lowest or highest value of the plot.

reverse boolean <optional>

Valid only if parameters.threshold is not set. If this parameter is set to true, threshold will be highest value of plot. Otherwise, threshold will be lowest value of plot.

direction number <optional>

1 to fill from the threshold upwards or -1 to fill from the threshold downwards

edgeHighlight object <optional>

Set to either a color or a Styles object as returned from CIQ.ChartEngine#canvasStyle to draw the threshold line.

edgeParameters object <optional>

The parameters to draw the threshold line as required by CIQ.ChartEngine#plotLine

gapDisplayStyle object <optional>

Gap object as set by See CIQ.ChartEngine#setGapLines.

opacity number <optional>

The color opacity/transparency as a decimal number (1= full opacity / no transparency). Default is 0.3.

step boolean <optional>

True for a step chart

tension number <optional>

Tension for splining. Requires "js/thirdparty/splines.js"

color string <optional>

The fill color

roundOffEdges boolean <optional>

Round the first and last point's X value to the previous and next integer, respectively.

yAxis CIQ.ChartEngine.YAxis <optional>

The y-axis for the band (will use default axis if not specified)

Since:

  • • 4.0.0 Added `parameters.reverse`, made `parameters.threshold` optional in case filling to top or bottom of panel
    • 4.1.2 Removed quotes argument; function always uses dataSegment.
    • 5.2.0 `params.yAxis` added
    • 5.2.0 `parameters.gaps` has been deprecated and replaced with `parameters.gapDisplayStyle`
Example
if(sd.outputs.Gain) CIQ.preparePeakValleyFill(stx,{panelName:sd.panel, band:"Result " + sd.name, threshold:sd.study.centerline, direction:1, color:sd.outputs.Gain});
if(sd.outputs.Loss) CIQ.preparePeakValleyFill(stx,{panelName:sd.panel, band:"Result " + sd.name, threshold:sd.study.centerline, direction:-1, color:sd.outputs.Loss});

qs( [query])

A parsed query string object Does not support using multi-value keys (i.e. "a=1&a=2")

Parameters:
Name Type Argument Description
query string <optional>

Query string. If not provided then the browser location's query string will be used

Returns:

An object containing the parsed values of the query string

Type
object

readablePeriodicity(stx)

Creates a string with a periodicity that is easy to read given a chart

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart object

Returns:

A periodicity value that can be displayed to an end user

Type
string

rect(params)

Displays a floating label over the y axis.

Draws a rectangle on the canvas using using CIQ.roundRect with a radius of 0 It then calls CIQ.createLabel to print the text over this background shape; which can be customized to control the text format for these labels.

Visual Reference:
rect

Parameters:
Name Type Description
params object
Properties
Name Type Argument Description
ctx object

A valid HTML Canvas Context

x number

Left position of drawing on canvas

top number

Top position of drawing on canvas

width number

Width of rectangle

height number

Height of rectangle

fill boolean <optional>

Whether to fill the background, or just draw the rectangle border.

txt number <optional>

Text for the label

y number <optional>

Y position of drawing on canvas

margin object <optional>

Margin around the text

Properties
Name Type Argument Description
left object <optional>

Left margin of text

top object <optional>

Top margin of text

backgroundColor number <optional>

Background color. This is the background color of the rectangle.

color number <optional>

Text color

Since:
  • 3.0.0 - function signature changed: This function now takes a params object instead of 8 different parameters

removeNullValues(obj)

Returns an object copy with any null values removed

Parameters:
Name Type Description
obj object

Object to remove nulls

Returns:

Object with nulls removed

Type
object

removeResizeListener(element, callback)

Removes an attached a callback to listen for an element.

Parameters:
Name Type Description
element node
callback function

replaceFields(obj, mapping)

This method will iterate through the object and replace all of the fields using the mapping object. This would generally be used to compress an object for serialization. so that for instance "lineWidth" becomes "lw". This method is called recursively.

Parameters:
Name Type Description
obj object

Object to compress

mapping object

Object containing name value pairs. Each name will be replaced with its corresponding value in the object.

Returns:

The newly compressed object

Type
object

reverseObject(obj)

This method reverses the fields and values in an object

Parameters:
Name Type Description
obj object

Object to reverse

Returns:

The reversed object

Type
object
Example
reverseObject({ one: "a", two: "b" }) // returns { a: "one", b: "two" }

roundRect(params [, edge])

Displays a floating label over the y axis.

Draws a rectangle, with curved corners, on the canvas. It then calls CIQ.createLabel to print the text over this background shape; which can be customized to control the text format for these labels.

Visual Reference:
roundRect

Parameters:
Name Type Argument Description
params object
Properties
Name Type Argument Description
ctx object

A valid HTML Canvas Context

x number

Left position of drawing on canvas

top number

Top position of drawing on canvas

width number

Width of rectangle

height number

Height of rectangle

radius number

Radius of rounding

fill boolean <optional>

Whether to fill the background, or just draw the rectangle border.

txt number <optional>

Text for the label

y number <optional>

Y position of drawing on canvas

margin object <optional>

Margin around the text

Properties
Name Type Argument Description
left object <optional>

Left margin of text

top object <optional>

Top margin of text

backgroundColor number <optional>

background color. This is the background color of the rectangle.

color number <optional>

Text color

edge string <optional>

"flush","arrow"

Since:
  • 3.0.0 - function signature changed: This function now takes a params object and the drawing type instead of 8 different parameters. Also, this function will draw the label if `params.txt` is present, otherwise just the floating label outline will be drawn

roundRectArrow(params)

Displays a floating label over the y axis.

Draws a rectangle on the canvas, with an arrowhead on the screen, using using CIQ.roundRect with an edge setting of "arrow".
It then calls CIQ.createLabel to print the text over this background shape; which can be customized to control the text format for these labels.

Visual Reference:
roundRectArrow

Parameters:
Name Type Description
params object
Properties
Name Type Argument Description
ctx object

A valid HTML Canvas Context

x number

Left position of drawing on canvas

top number

Top position of drawing on canvas

width number

Width of rectangle

height number

Height of rectangle

radius number

Radius of rounding

fill boolean <optional>

Whether to fill the background, or just draw the rectangle border.

txt number <optional>

Text for the label

y number <optional>

Y position of drawing on canvas

margin object <optional>

Margin around the text

Properties
Name Type Argument Description
left object <optional>

Left margin of text

top object <optional>

Top margin of text

backgroundColor number <optional>

Background color. This is the background color of the rectangle.

color number <optional>

Text color

Since:
  • 3.0.0 - function signature changed: This function now takes a params object instead of 8 different parameters

safeClickTouch(div, fc, params)

Use this instead of onclick or ontouch events. This function will automatically use the quickest available but also protect against being called twice. By default any previous safeClickTouch listeners will be cleared (to allow re-use of the element).

Parameters:
Name Type Description
div object

The DOM element to attach an event

fc function

The function to call when the object is pressed

params object

Parameters to drive behavior.

Properties
Name Type Argument Default Description
safety object <optional>

An object, generated from a CIQ.safeDrag association to prevent the click from being triggered when a drag operation is released

allowMultiple boolean <optional>
false

If set then multiple click events can be associated with the node

preventUnderlayClick boolean <optional>
true

By default prevents an underlaying element from being "clicked" on a touch device 400ms after the overlay was tapped. Set to false for input fields, or any div containing input fields (body)

absorbDownEvent boolean <optional>
true

Ensures that a mousedown, pointerdown, touchstart event doesn't get passed to the parent.

Since:
  • 11/01/2015 Removed timers in favor of a new algorithm. This algorithm allows only the first event to fire from a UI interaction to execute the fc function.

safeDrag(div [, fcDown] [, fcMove] [, fcUp])

Safe function to handle dragging of objects on the screen. This method is cross-device aware and can handle mouse or touch drags. This method does not actually move the objects but provides callbacks that explain when drag operations begin and cease, and what movements are made during the drag. Callbacks should be used to move the actual objects (if it is desired to move objects during a drag operation). For convenience, displacementX and displacementY are added to callback events to indicate the distance from the original starting point of the drag. A "safety" object is returned which can optionally be passed into CIQ.safeClickTouch to prevent errant click events from being triggered when a user lets go of a drag

Parameters:
Name Type Argument Description
div object

The draggable DOM element

fcDown function <optional>

Callback function when a drag operation begins. Receives an event object.

fcMove function <optional>

Callback function when a drag move occurs. Receives an event object.

fcUp function <optional>

Callback function when the drag operation ends. Receives an event object.

Returns:

Safety object which can be passed to CIQ.safeClickTouch

Type
object

safeMouseOut(node, fc)

Used in conjunction, safeMouseOut and safeMouseOver ensure just a single event when the mouse moves in or out of an element. This is important because simple mouseout events will fire when the mouse crosses boundaries within an element. Note that this function will do nothing on a touch device where mouseout is not a valid operation.

Parameters:
Name Type Description
node object

A valid DOM element

fc function

Function to call when the mouse has moved out


safeMouseOver(node, fc)

This method is guaranteed to only be called once when a user mouses over an object. @see CIQ#safeMouseOut

Parameters:
Name Type Description
node object

A valid DOM element

fc function

Function to call when mouse moves over the object


scrub(obj [, removeNulls])

Deletes (removes) nulls or undefined fields (names) from an object. This is useful when marshalling (saving) an object where you don't wish null or undefined values to show up in the marshalled object (such as when converting to JSON)

Parameters:
Name Type Argument Description
obj object

The object to scrub

removeNulls boolean <optional>

Whether or not to remove null values


semiRoundRect(params)

Displays a floating label over the y axis.

Draws a rectangle on the canvas, with just the right side curved corners, using using CIQ.roundRect with an edge setting of "flush". It then calls CIQ.createLabel to print the text over this background shape; which can be customized to control the text format for these labels.

Visual Reference:
semiRoundRect

Parameters:
Name Type Description
params object
Properties
Name Type Argument Description
ctx object

A valid HTML Canvas Context

x number

Left position of drawing on canvas

top number

Top position of drawing on canvas

width number

Width of rectangle

height number

Height of rectangle

radius number

Radius of rounding

fill boolean <optional>

Whether to fill the background, or just draw the rectangle border.

txt number <optional>

Text for the label

y number <optional>

Y position of drawing on canvas

margin object <optional>

Margin around the text

Properties
Name Type Argument Description
left object <optional>

Left margin of text

top object <optional>

Top margin of text

backgroundColor number <optional>

Background color. This is the background color of the rectangle.

color number <optional>

Text color

Since:
  • 3.0.0 - function signature changed: This function now takes a params object instead of 8 different parameters

setCaretPosition(ctrl, pos)

Sets the position of the cursor within a textarea box. This is used for instance to position the cursor at the end of the text that is in a textarea.

Parameters:
Name Type Description
ctrl object

A valid textarea DOM element

pos number

The position in the text area to position


setValueIfNotActive(el, value)

Sets the value of an input box only if it is not active. This prevents an input box from changing underneath a user, which can be extremely frustrating on touch devices.

Parameters:
Name Type Description
el HTMLElement

The input element

value string

The value to set


shallowClone(from)

Non recursive clone. This will only clone the top layer and is safe to use when objects contain DOM nodes.

Parameters:
Name Type Description
from object

Object to be cloned

Returns:

A shallow clone of the "from" object

Type
object

standardUTCDate(dt)

Converts a date into YYYY-MM-DDTHH:MM:SSZ format (UTC)

Parameters:
Name Type Description
dt date

A JavaScript Date object

Returns:

Date in YYYY-MM-DDTHH:MM:SSZ format

Type
string

stripPX(text)

Strips the letters "px" from a string. This is useful for converting styles into absolutes.

Parameters:
Name Type Description
text string

String value with "px"

Returns:

The numeric value

Type
number
Example
var leftPosition=CIQ.stripPX(node2.style.left)

strToDate(dt)

Converts a string form date into a JavaScript object. Only use if you know that the string will not include a time, otherwise use @see CIQ.strToDateTime

Parameters:
Name Type Description
dt string

Date in string format such as MM/DD/YY or YYYYMMDD or 2014-10-25T00:00:00+00:00 or 201506170635

Returns:

JavaScript date object -new Date()-

Type
date

strToDateTime(dt)

Converts a string form date into a JavaScript Date object with time. Supports various standard date formats

Parameters:
Name Type Description
dt string

String form of a date (such as yyyymmddhhmm, yyyy-mm-dd hh:mm, etc)

Returns:

A JavaScript Date object

Type
date

swapClassName(node, newClassName, oldClassName)

Convenience method for swapping two class names within a node. Such as for changing state.

Parameters:
Name Type Description
node object

A valid DOM element

newClassName string

The class name to swap in

oldClassName string

The class name to swap out


symbolEqual(left, right)

Returns true if two symbols match. Symbols can be strings or symbolObjects. By default, the "symbol" member is compared, and then a "source" member if one exists. If the objects have an "equals()" function member then that will be used for comparison. You can override this with your own method if you have other requirements.

Parameters:
Name Type Description
left object

Symbol object

right object

Symbol object

Returns:

true if the same

Type
boolean

tickedRect(params)

Displays a floating label over the y axis.

Draws a 'ticked' rectangle on the canvas, using using CIQ.roundRect. It then calls CIQ.createLabel to print the text over this background shape; which can be customized to control the text format for these labels.

Visual Reference:
tickedRect

Parameters:
Name Type Description
params object
Properties
Name Type Argument Description
ctx object

A valid HTML Canvas Context

x number

Left position of drawing on canvas

top number

Top position of drawing on canvas

width number

Width of rectangle

height number

Height of rectangle

radius number

Radius of rounding

fill boolean <optional>

Whether to fill the background, or just draw the rectangle border.

txt number <optional>

Text for the label

y number <optional>

Y position of drawing on canvas

margin object <optional>

Margin around the text

Properties
Name Type Argument Description
left object <optional>

Left margin of text

top object <optional>

Top margin of text

backgroundColor number <optional>

background color. This is the background color of the rectangle.

color number <optional>

Text color

Since:
  • 3.0.0 - function signature changed: This function now takes a params object instead of 8 different parameters

timeAsDisplay(dt [, stx] [, precision])

Displays a time in readable form. If Internationalization is in use then the time will be in 24 hour Intl numeric format

Parameters:
Name Type Argument Description
dt date

JavaScript Date object

stx object <optional>

Chart object if Internationalization is in use

precision number <optional>

Precision to use. If null then hh:mm. CIQ.SECOND then hh:mm:ss. If CIQ.MILLISECOND then hh:mm:ss.mmmmm

Returns:

Human friendly time, usually hh:mm

Type
string

toggleClassName(node, className)

Toggles the className on or off

Parameters:
Name Type Description
node HTMLElement

The node to toggle

className string

The class name to toggle


TradingCentral(stx, token, partner)

Controller class to assist in the creation and processing of Trading Central™ API requests.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart instance to modify

token string

Trading Central API token

partner number

Trading Central API parnter number


translatableTextNode(stx, english [, language])

Creates a document node which facilitates translation to other languages, if stx.translationCallback callback function is set. If there is no translationCallback, a standard text node is returned.

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine

The chart object

english string

The word to translate

language string <optional>

Language. Defaults to CIQ.I18N.language.

Returns:

A node in the following form if translationCallback exists: translation If it does not exist, a text node is returned.

Type
HTMLElement

unappendClassName(node, className)

Removes a class name from a node if it is set

Parameters:
Name Type Description
node object

A valid DOM element

className string

The class name to remove


uniqueID()

Returns a short, pseudo unique ID based on the current time. Radix 36 is used resulting in a compact string consisting only of letters and numerals. While not guaranteed to be unique, this function has a high probability of uniqueness when it is triggered by human activity even in a large user base.

Returns:

A unique string consisting of letters and numerals

Type
string

waitForPlugins(plugins, cb)

Checks to see if the enabled plugins are done dynamically loading.

Parameters:
Name Type Description
plugins array

An array of strings that define which plugins to check The plugin names provided must match the following format: if cq-scriptiq is enabled, 'scriptiq' is the plugin name entered into the array

cb function

Function to call when all the plugins are fully loaded

Since:
  • 6.1.0

withinElement(node, x, y)

Returns true if a point, in absolute screen position, is within an element

Parameters:
Name Type Description
node object

A valid DOM element to check whether the point overlaps

x number

Absolute screen X position of point

y number

Absolute screen Y position of pointer

Returns:

True if the point lies inside of the DOM element

Type
boolean

xIntersection(vector, y)

Determines the X value at which point Y intersects a line (vector)

Parameters:
Name Type Description
vector object

Object of type {x0,x1,y0,y1}

y number

Y value

Returns:
  • X intersection point
Type
number

yIntersection(vector, x)

Determines the Y value at which point X intersects a line (vector)

Parameters:
Name Type Description
vector object

Object of type {x0,x1,y0,y1}

x number

X value

Returns:
  • Y intersection point
Type
number

yyyymmdd(dt)

Converts a JavaScript Date to yyyy-mm-dd format

Parameters:
Name Type Description
dt date

JavaScript Date object

Returns:

Date in yyyy-mm-dd format

Type
string

yyyymmddhhmm(dt)

Converts a date into yyyymmddhhmm format

Parameters:
Name Type Description
dt date

A JavaScript Date object

Returns:

Date in yyyymmddhhmm format

Type
string

yyyymmddhhmmssmmm(dt)

Converts a date into yyyymmddhhmmssmmm format

Parameters:
Name Type Description
dt date

A JavaScript Date object

Returns:

Date in yyyymmddhhmmssmmm format

Type
string