Class: Chart

STXChart. Chart


new Chart()

Defines an object used for rendering a chart. Chart objects contain the data and config for each chart but they don't actually exist on the screen until a panel is attached. A chart object is attached to both the main chart panel and any related study panels so they can share the same chart data.

Example: stxx.panels['chart'].chart

Example: stxx.chart (convenience shortcut for accessing the main chart object - same as above)

Example stxx.panels['Aroon (14)'].chart

Members


allowScrollPast :boolean

If set to false, the chart will be anchored on left side preventing white space to be created past the oldest tick; The amount of white space allowed on the right will be limited by STXChart#minimumLeftBars

Type:
  • boolean
Default Value:
  • true

baseline :object

Parameters used to control the baseline in baseline_delta charts

Type:
  • object

baseline.actualLevel :number

actualLevel - This is computed automatically. Do not set.

Type:
  • number
Default Value:
  • null

baseline.defaultLevel :number

defaultLevel - If set to a value, overrides the default behavior of baseline chart which is to set baseline to leftmost point visible on the chart.

Type:
  • number
Default Value:
  • null

baseline.includeInDataSegment :boolean

includeInDataSegment - If set to true, forces a line chart (usually a baseline chart) to begin inside the chart, whereas normally the first point in a line chart is off the left edge of the screen.

Type:
  • boolean
Default Value:
  • false

baseline.userLevel :boolean/number

userLevel - Value of the user-set baseline level. To prevent user from adjusting the baseline, set this property to false.

Type:
  • boolean/number
Default Value:
  • null

customChart.colorFunction :object

This function will be called on certain chart types, before rendering each tick in the dataSegment, to determine the proper color to use on each bar, candle or line segment. Mainly used to setting colors for 'up' vs. 'down' ticks. For use with 'colored_bar', 'colored_line', "colored_mountain", 'candle', 'hollow_candle' and 'volume_candle' chart only.

Expected format :

    function(stx, quote, mode)

Parameters:

    {object} stx    - A chart object
    (object} quote    - A properly formated OHLC object.
    {string} mode    - Applicable on 'candle', 'hollow_candle' and 'volume_candle' charts only. Allowed values: "shadow", "outline", and "solid".
                        `shadow`- indicates the function is asking for the candle wick color
                        `outline` indicates the function is asking for the candle border color
                        `solid` indicates the function is asking for the candle fill color
                                    (Inside of candle. Not applicable on 'hollow_candle' or 'volume_candle')

Returns:

    {string/object} Color to use for the bar, candle or line segment component. Set to null to skip bar or line segment.
    For colored line charts a color/pattern combination can be returned in an object of the follwing format: `{pattern:[3,3],color:"red"}`

See Chart Types and Styles for more details.

Type:
  • object
Default Value:
  • null
Example
stxx.chart.customChart.colorFunction=function(stx, quote, mode){
		if(mode=="shadow" || mode=="outline") return "black";  //draw black wicks and borders
		else{
			if(quote.Close>100) return "green";
			else if(quote.DT.getHours()<12) return "yellow";
			else return "orange";
		}
		return null;
	};

dataSegment :object

Contains the segment of the data set that is displayed on the screen (view-window). See Data Loading for details.

Type:
  • object

dataSet :object

Contains the current complete data set created by STXChart#createDataSet, adjusted for periodicity and with calculated studies. See Data Loading for details.

Type:
  • object

hideDrawings :boolean

Set to true to temporarily hide drawings

Type:
  • boolean
Default Value:
  • false

legendRenderer :function

Function used to render the Legend when multiple series are being displayed on the main chart panel. Update your prototype or a specific chart instance, if you want to use a different rendering method for legend. See STX.drawLegend for details and function signature.

Defaults to STX.drawLegend

Type:
  • function
Since:
  • 07/01/2015
Example
stxx.chart.legendRenderer = yourFunction; // must follow the function signature of STX.drawLegend;

lockScroll :Boolean

set this to true to turn off auto-scrolling when fresh data comes in. By default, the chart will scroll backward whenever a new bar comes in, so as to maintain the chart's forward position on the screen. If lockScroll is true then fresh bars with advance the chart forward (and eventually off the right edge of the screen)

Note that setSpan({base:"today"}) will set an internal variable that accomplishes the same thing. This is a unique case.

Type:
  • Boolean
Since:
  • 05-2016-10
Default Value:
  • false

masterData :object

The master data for this chart. This data is never modified by the chart engine itself and should not be altered directly. Use STXChart#setMasterData , STXChart#appendMasterData, or STXChart#streamTrade to manipulate this object. See Data Loading for details.

Type:
  • object

scroll :number

Current number of ticks scrolled in from the end of the chart. Setting to zero would theoretically cause the chart to be scrolled completely to the left showing an empty canvas. Setting to 10 would display the last 10 candles on the chart. Setting to maxTicks would display a full screen on the chart (assuming enough data is available).

Type:
  • number
Default Value:
  • 0

symbolDisplay :string

Set this to presnet an alternate name for the symbol on the chart label and comparison legend. You can set stxx.chart.symbolDisplay='yourName'; right before calling newChart(). Alternatively, a good place to set it is in your fetch() function, if using STX.QuoteFeed. See example.

Type:
  • string
Default Value:
  • null
Example
// on your fetch initial load add the following
params.stx.chart.symbolDisplay='yourName for '+params.symbol;

xaxisFactor :number

Determines at which zoom level interior axis points are displayed. Value in pixels.

Type:
  • number
Default Value:
  • 30

yaxisPaddingLeft :number

How much padding to leave for the left y-axis. Default is enough for the axis. Set to zero to overlap y-axis onto chart.

Type:
  • number
Since:
  • 07/01/2015
Default Value:
  • null

yaxisPaddingRight :number

How much padding to leave for the right y-axis. Default is enough for the axis. Set to zero to overlap y-axis onto chart.

Type:
  • number
Since:
  • 07/01/2015
Default Value:
  • null