new Renderer()
Base class for Renderers. A renderer is used to draw a complex visualization based on one or more "series" of data. This is a reusable object. Once defined and attached to a chart, it shouldn’t have to be recreated every time a symbol changed. The series inside the renderers may change with a new symbol, but the linked renderer itself remains the vehicle for adding series.
Classes
Methods
-
attachSeries(field, 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 STXChart#addSeries for details on how to create a series. See STXChart.addSeries.
The color defined when attaching a series will supersede any color 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 if desired.
Parameters:
Name Type Description field
String The name of the field. Name of the field in the dataSet to use for the series.
parameters
object Settings to control color and opacity of each series in the group. See STXChart#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 Description fill_color_up
string <optional>
Color to use to fill the part when the Close is higher than the previous (#RRGGBB(AA) format or null to not draw)
border_color_up
string <optional>
Color to use to draw the border when the Close is higher than the previous (#RRGGBB(AA) format or null to not draw)
opacity_up
number <optional>
Opacity to use to fill the part when the Close is higher than the previous (0.0-1.0). Default: .4
fill_color_down
string <optional>
Color to use to fill the part when the Close is lower than the previous (#RRGGBB(AA) format or null to not draw)
border_color_down
string <optional>
Color to use to draw the border when the Close is lower than the previous (#RRGGBB(AA) format or null to not draw)
opacity_down
number <optional>
Opacity to use to fill the part when the Close is lower than the previous (0.0-1.0) default: .4
color
string <optional>
Color to use to fill the series if fill_color_up or fill_color_down is not specified (#RRGGBB(AA) format).
permanent
boolean <optional>
For line chart, whether it can be removed by the user. 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.
Returns:
Returns a copy of this for chaining
- Type
- STX.Renderer
Example
stxx.addSeries("NOK", {display:"NOK",data:{useDefaultQuoteFeed:true},width:4}); var axis=new STXChart.YAxis(); axis.position="left"; axis.textStyle="#FFBE00"; renderer=stxx.setSeriesRenderer(new STX.Renderer.Lines({params:{name:"lines", type:"mountain", yAxis:axis}})); renderer.removeAllSeries() .attachSeries("NOK", "#FFBE00") .attachSeries("SNE", "#FF9300") .ready();
- a
-
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 Description name
string <optional>
Name of the renderer. Default: 'Data'. This is used when displaying error message on screen
panel
string <optional>
The name of the panel to put the rendering on, defaults to "chart"
overChart
boolean <optional>
If set to true, will draw the rendering on top of the chart rather than as an underlay. By default rendering will be as underlay.
yAxis
boolean <optional>
Optional Y-axis object to use for the series.
opacity
number <optional>
Opacity of the rendering as a whole. Can be overridden by an opacity set for a series. Valid values are 0.0-1.0. Default: 1
Example
stxx.addSeries("NOK", {display:"NOK",data:{useDefaultQuoteFeed:true},width:4}); stxx.addSeries("SNE", {display:"Sony",data:{useDefaultQuoteFeed:true},width:4}); var axis=new STXChart.YAxis(); axis.position="left"; axis.textStyle="#FFBE00"; renderer=stxx.setSeriesRenderer(new STX.Renderer.Lines({params:{name:"lines", type:"mountain", yAxis:axis}})); renderer.removeAllSeries() .attachSeries("NOK", "#FFBE00") .attachSeries("SNE", "#FF9300") .ready();
-
draw()
-
Perform drawing operations here.
-
performCalculations()
-
If your render manages a yAxis then the necessary calculations (high and low) should be made here
-
ready()
-
Call this to immediately render the visualization, at the end of a chain of commands.
Returns:
A copy of this for chaining
- Type
- STX.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 STXChart otherwise it will be retained
Returns:
A copy of this for chaining
- Type
- STX.Renderer
-
removeSeries(field [, preserveSeries])
-
Removes a 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 field
String The field name of the series.
preserveSeries
Boolean <optional>
false Set to true to keep the series data in the STXChart object.
Returns:
A copy of this for chaining
- Type
- STX.Renderer