The UI potion if this namespace is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
Comparison namespace
Members
-
<static> colorOrder :Array
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
Default color selection for Comparison UI. This array will be traversed as the user adds comparison charts and then loop back at the end.Type:
- Array
- Version:
-
- ChartIQ Advanced Package
-
<static> colorPointer :Number
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
The current location in the STX.Comparison.colorOrder array.Type:
- Number
- Version:
-
- ChartIQ Advanced Package
-
<static> correlationPanel
-
ID of the study panel to create for the correlation coefficient
- Version:
-
- ChartIQ Advanced Package
-
<static> requestCorrelation
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
Initial value of UI input for toggling correlation coefficient- Version:
-
- ChartIQ Advanced Package
-
<static> type :string
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
Comparisons can either be "compare", "overlay" or "absolute".The UI defaults to "compare" which produces a y-axis with relative percentage changes.
"overlay" overlays the series so that the axis is not shared.
"absolute" renders each series on the exact y-axis values (This is not recommended for series that do not share a similar y-axis price range).
Type:
- string
- Version:
-
- ChartIQ Advanced Package
- Since:
-
- 03/17/2015 "absolute" puts all series on the same axis (developers should ensure that series are around the same price range)
Methods
-
<static> add(stx, compareSymbol, cb, display [, parameters])
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
Adds a new comparison symbol. This method is driven from the UI but can also be called programatically if the comparison UI is at least available in the page. Otherwise, if you are not using the sample GUI, you can override this method to exclude references to the UI. If available, it will use the STX.QuoteFeed infrastructure to fetch data. You can override the comparison data source in STX.Comparison.fetchParameters:
Name Type Argument Description stx
object The chart object
compareSymbol
string/object The symbol to compare. A symbol string or an object representing the symbol can be used. If using an object, you can send anything you want in it, but you must always include at least a 'symbol' element. This object will be passed on to STX.Comparison.fetch as
parameters.symbolObject
. And if using the fetch() method for data loading, it will be present in the parameters list there as well.cb
function Callback function
display
string The text to display on the legend.
parameters
object <optional>
Optional parameters to describe the series. See STXChart#addSeries for full list
- Version:
-
- ChartIQ Advanced Package
- Since:
-
07/01/2015 added parameters argument.
2015-11-1 compareSymbol can now be a string or an object.
Example
STX.Comparison.add(stxx, 'GE',null,'General Motors');
-
<static> attachColorPicker()
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
Attaches a color picker to the comparison UI- Version:
-
- ChartIQ Advanced Package
-
<static> createComparisonSegment()
-
Creates the comparison lines. Comparison charts use a transform to transform the y-axis to percentages.
-
<static> fetch(stx, comparisonSymbol, cb, parameters)
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
If you're not using a QuoteFeed, then add here your version of fetch to retrieve the comparison data. The data you fetch should be in the standard chart OHLC format, or as outlined by STXChart#addSeries. Please review the Data Format section to properly format your OHLC quote objects. Once the comparison data is available, assign it toparameters.data
and calladdSeries()
. See example for suggested code.Parameters:
Name Type Description stx
object The chart object
comparisonSymbol
string The symbol to compare.
cb
function Callback function
parameters
object Optional parameters to describe the series. See STXChart#addSeries for full list
- Version:
-
- ChartIQ Advanced Package
Example
STX.Comparison.fetch=function(stx, comparisonSymbol, parameters, cb){ // fetch comparison data here and set the data for the series STX.postAjax("jason.asp?symbol="+comparisonSymbol+"&range=", null, function (status, response) { if (status != 200) { return; // error } parameters.data = JSON.parse(response); stx.addSeries(comparisonSymbol, parameters, cb); // always include the callback (cb) function! }); };
-
<static> initialize(stx [, inputEventHandling])
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
Initializes the comparison UI to handle keystrokes and color picking and to associate it with a chart objectParameters:
Name Type Argument Description stx
object The chart object
inputEventHandling
boolean <optional>
Set to false to bypass default input event handling
- Version:
-
- ChartIQ Advanced Package
-
<static> percentToPrice(stx, chart, percent)
-
Untransform function for comparison charting
Parameters:
Name Type Description stx
STXChart The charting object
chart
STXChart.Chart The specific chart
percent
number The price to untransform
Returns:
The untransformed price
- Type
- number
-
<static> priceFormat(stx, panel, price)
-
Formats the percentage values on the comparison chart
Parameters:
Name Type Description stx
STXChart The chart object
panel
STXChart.Panel The panel
price
number The percentage (whole number)
Returns:
The percentage formatted as a percent (possibly using localization if set in stx)
- Type
- string
-
<static> priceToPercent(stx, chart, price)
-
Transform function for comparison charting
Parameters:
Name Type Description stx
STXChart The charting object
chart
STXChart.Chart The specific chart
price
number The price to transform
Returns:
The transformed price (into percentage)
- Type
- number
-
<static> processComparison(stx, symbol, comparison)
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
Backwards compatibility Iterates through the charts masterData and adds a data member for the comparison. The data member will be the string defined by "symbol". Dates must be exact matches (minutes, hours, seconds, milliseconds) in order to show up in the comparison.Parameters:
Name Type Description stx
object A chart object
symbol
string The data member to add for comparison
comparison
array Comparison data (which should align or closely align with the chart data by date)
- Version:
-
- ChartIQ Advanced Package
- Deprecated:
-
- use STX#addMemberToMasterdata instead
-
<static> quoteFeedCallback()
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
Code for loading additional quote data for comparisons or studies. Use this when using STX.QuoteFeed "pull" data by calling it in the callback function. See stx-advanced.html for an example. This will be executed after every quoteFeed fetch call, and is used to keep the main symbol in sync with any other active symbols on the chart.- Deprecated:
-
- Yes
-
<static> reset(stx)
-
This function is maintained for legacy implementations only (not using web components). New implementations should use functionality included in the web components (stxUI.js)
Resets comparisons, removing all existing comparisons and resetting the UI. Call this when changing symbols or to "remove all" comparisons.Parameters:
Name Type Description stx
object The chart object
- Version:
-
- ChartIQ Advanced Package
-
<static> toggleCorrelate()
-
Turns on and off the checkbox for generating correlation coefficient