Class: Renderer

CIQ. Renderer


new Renderer()

Base class for Renderers. A renderer is used to draw a complex visualization based on one or more "series" of data. Renderers only need to be attached to a chart once. You can change symbols and continue using the same renderer. The series associated with a renderer may change at any time, but the linked renderer itself remains the vehicle for display them.

Series are associated with renderers by calling attachSeries(). More typically though, this is done automatically when CIQ.ChartEngine#addSeries is used. The parameters for addSeries() are passed both to the renderer's constructor and also to attachSeries().

To manually create a renderer use CIQ.ChartEngine#setSeriesRenderer

Classes

Bars
Candles
Heatmap
Histogram
HLC
HLCBox
Lines
MarketDepth
OHLC
Scatter
Shading
SimpleHistogram

Methods


registerColorFunction(name, fc)

Registers a colorFunction for use with a renderer. It is necessary to register a color function if you want the function to be tied back to an imported renderer.

Parameters:
Name Type Description
name string

The name of the registered function

fc function

The function to register


unregisterColorFunction(name)

Unregisters a colorFunction for use with a renderer.

Parameters:
Name Type Description
name string

The name of the registered function


adjustYAxis()

If your renderer manages a yAxis then the necessary adjustments to its properties should be made here

Since:
  • 5.2.0

attachSeries(id, parameters)

Attach a series to the renderer. This assumes that the series data is already in the dataSet and simply connects it to the renderer with the specified parameters. See CIQ.ChartEngine#addSeries for details on how to create a series.

Any parameters defined when attaching a series, such as colors, will supersede any defined when a series was created. This allows you to attach the same series to multiple renderers, each rendering displaying the same series data in a different color, for example.

Parameters:
Name Type Description
id string

The name of the series.

parameters object

Settings to control color and opacity of each series in the group. See CIQ.ChartEngine#addSeries for implementation examples.

Argument format can be:

  • a string containing the color
  • or a more granular object having the following members:

Properties
Name Type Argument Default Description
field string <optional>

The name of the field. Name of the field in the dataSet to use for the series. If omitted, defaults to id

fill_color_up string <optional>

Color to use to fill the part when the Close is higher than the previous (or 'transparent' to not display)

border_color_up string <optional>

Color to use to draw the border when the Close is higher than the previous (or 'transparent' to not display)

opacity_up number <optional>
.4

Opacity to use to fill the part when the Close is higher than the previous (0.0-1.0)

border_color_even string <optional>

Color to use to draw the border when the Close is equal to the previous (or 'transparent' to not display)

fill_color_down string <optional>

Color to use to fill the part when the Close is lower than the previous (or 'transparent' to not display)

border_color_down string <optional>

Color to use to draw the border when the Close is lower than the previous (or 'transparent' to not display)

opacity_down number <optional>
.4

Opacity to use to fill the part when the Close is lower than the previous (0.0-1.0)

color string <optional>

Color to use to fill the series in the absence of specific up/down color.

border_color string <optional>

Color to use to draw the border in the series in the absence of specific up/down color.

fillStyle string <optional>

Color to use to fill the mountain chart.

baseColor string <optional>

Color to use at the bottom of the mountain chart, will create a gradient with bgColor

bgColor string <optional>

Color to use at the top of the mountain chart, will create a gradient if baseColor is specified. Otherwise, will fill the mountain solid with this color unless fillStyle is specified

permanent boolean <optional>

Whether the attached series can be removed by the user (lines and bars only). By default the series will not be permanent. This flag (including the default) will supersede the permanent flag of the actual series. As such, a series will not be permanent unless you set this flag to 'true', even if the series being attached was flaged set as permanent when defined. This gives the renderer most control over the rendering process.

Since:
  • 5.1.0 added fillStyle, baseColor, bgColor parameters
Returns:

Returns a copy of this for chaining

Type
CIQ.Renderer
Example
stxx.addSeries("NOK", {display:"NOK",width:4});

		var axis=new CIQ.ChartEngine.YAxis();
		axis.position="left";
		axis.textStyle="#FFBE00";

		var renderer=stxx.setSeriesRenderer(new CIQ.Renderer.Lines({params:{name:"lines", type:"mountain", yAxis:axis}}));

		renderer.removeAllSeries()
			.attachSeries("NOK", "#FFBE00")
			.attachSeries("SNE", "#FF9300")
			.ready();

construct(config)

Default constructor for a renderer. Override this if desired.

Parameters:
Name Type Description
config object

Configuration for the renderer

Properties
Name Type Argument Description
callback function <optional>

Callback function to perform activity post-drawing, for example, creating a legend. It will be called with a 'colors' argument, which will be an array of objects containing the colors used to draw the rendering. ( Example: cb(colors); ). See example for format.

id string <optional>

Handle to access the rendering in the future. If not provided, one will be generated.

params object <optional>

Parameters to control the renderer itself

Properties
Name Type Argument Default Description
name string <optional>
"Data"

Name of the renderer. This is used when displaying error message on screen

panel string <optional>
"chart"

The name of the panel to put the rendering on.

overChart boolean <optional>
true

If set to false, will draw the rendering behind the main chart rather than over it. By default rendering will be as overlay on the main chart.

yAxis boolean <optional>

Y-axis object to use for the series.

opacity number <optional>
1

Opacity of the rendering as a whole. Can be overridden by an opacity set for a series. Valid values are 0.0-1.0.

binding object <optional>

Allows the use of the study output colors within the renderer. See an example in the Using Renderers to Display Study Output section of the Studies tutorial.

Since:
  • 5.2.0 `config.params.binding` parameter added.
Example
stxx.addSeries("NOK", {display:"NOK",width:4});
		stxx.addSeries("SNE", {display:"Sony",width:4});

		var axis=new CIQ.ChartEngine.YAxis();
		axis.position="left";
		axis.textStyle="#FFBE00";

		var renderer=stxx.setSeriesRenderer(new CIQ.Renderer.Lines({params:{name:"lines", type:"mountain", yAxis:axis}}));

		renderer.removeAllSeries()
			.attachSeries("NOK", "#FFBE00")
			.attachSeries("SNE", "#FF9300")
			.ready();

draw()

Perform drawing operations here.


drawIndividualSeries(chart [, parameters])

Draws one series from the renderer Called by CIQ.ChartEngine#drawSeries

Parameters:
Name Type Argument Description
chart CIQ.ChartEngine.Chart

The chart object to draw the renderers upon

parameters object <optional>

Parameters used to draw the series, depends on the renderer type

Properties
Name Type Argument Description
panel string <optional>

Name of panel to draw the series upon

Since:
  • 5.1.0

performCalculations()

If your renderer manages a yAxis then the necessary calculations (high and low) should be made here

Deprecated:

ready()

Call this to immediately render the visualization, at the end of a chain of commands.

Returns:

A copy of this for chaining

Type
CIQ.Renderer

removeAllSeries( [eraseData])

Removes all series from the renderer and the yAxis from the panel if it is not being used by any current renderers.

Parameters:
Name Type Argument Default Description
eraseData boolean <optional>
false

Set to true to erase the actual series data in the CIQ.ChartEngine otherwise it will be retained

Returns:

A copy of this for chaining

Type
CIQ.Renderer

removeSeries(id [, preserveSeries])

Removes a series from the renderer. The yAxis and actual series data will also be removed if no longer used by any other renderers. When the last series is removed from the renderer, the chart it is attached to will remove the renderer.

Parameters:
Name Type Argument Default Description
id string

The field name of the series.

preserveSeries boolean <optional>
false

Set to true to keep the series data in the CIQ.ChartEngine object.

Since:

  • • 2015-07-01 'preserveSeries' is now available
    • 3.0.0 series is now removed even if series parameter 'permanent' is set to true. The permanent parameter only prevents right click user interaction and not programmatically requested removals.
    • 4.0.0 series data is now totally removed from masterData if no longer used by any other renderers.
Returns:

A copy of this for chaining

Type
CIQ.Renderer