new Histogram(config)
See CIQ.Renderer#construct for parameters required by all renderers.
See CIQ.ChartEngine#drawHistogram for more details.
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object | Config for renderer Properties
|
- Version:
-
- ChartIQ Advanced Package
- Since:
-
- 7.5.0 Added the ability to draw negative bars when
yAxis.baselineis set to zero or some other value (see examples). - 9.6.0 Added
config.params.priorityandconfig.params.colMarginparameter - 9.7.0 Added
config.params.errorMessageparameter.
- 7.5.0 Added the ability to draw negative bars when
Examples
// configure the histogram display
const params={
name: "Sentiment Data",
subtype: "stacked",
heightPercentage: 0.7, // how high to go. 1 = 100%
widthFactor: 0.8 // to control space between bars. 1 = no space in between
};
//legend creation callback (optional)
function histogramLegend(colors){
stxx.chart.legendRenderer(stxx,{legendColorMap:colors, coordinates:{x:260, y:stxx.panels["chart"].yAxis.top+30}, noBase:true});
}
// set the renderer
const histRenderer=stxx.setSeriesRenderer(new CIQ.Renderer.Histogram({params: params, callback: histogramLegend}));
// add data and attach.
stxx.addSeries("^NIOALL", {display:"Symbol 1"}, function() {histRenderer.attachSeries("^NIOALL","#6B9CF7").ready();});
stxx.addSeries("^NIOAFN", {display:"Symbol 2"}, function() {histRenderer.attachSeries("^NIOAFN","#95B7F6").ready();});
stxx.addSeries("^NIOAMD", {display:"Symbol 3"}, function() {histRenderer.attachSeries("^NIOAMD","#B9D0F5").ready();});
// this is an example on how to completely remove a renderer and all associated data.
// This should only be necessary if you are also removing the chart itself
// Remove all series from the renderer including series data from the masterData
renderer.removeAllSeries(true);
// detach the series renderer from the chart.
stxx.removeSeriesRenderer(renderer);
// delete the renderer itself.
delete renderer;
Create a histogram renderer on a separate panel with a baseline value, allowing negative bars.
const yax = new CIQ.ChartEngine.YAxis({
position: "left",
baseline: { value: 105 }
});
// Optionally create a separate panel to prevent baseline conflicts with the main chart.
stxx.createPanel("Histogram Panel", "histogram", null, null);
const histRenderer = stxx.setSeriesRenderer(
new CIQ.Renderer.Histogram({
params: {
subtype: 'clustered',
panel: "histogram", // Use the previously created panel.
yAxis: yax,
}
})
);
stxx.addSeries("AMZN", null, function () { histRenderer.attachSeries("AMZN", { color: 'blue' }).ready(); });
stxx.addSeries("MSFT", null, function () { histRenderer.attachSeries("MSFT", { color: 'white' }).ready(); });
stxx.addSeries("GOOGL", null, function () { histRenderer.attachSeries("GOOGL", { color: 'orange' }).ready(); });
Render a horizontal line at the baseline value.
const yAxis = new CIQ.ChartEngine.YAxis({
position: "left",
baseline: {
value: 100,
// Must provide color to render the horizontal line,
// and can optionally provide pattern, lineWidth, and opacity.
color: "red",
pattern: "dotted",
lineWidth: 2,
opacity: 1
}
});
stxx.addSeries("GOOG", {
renderer: "Histogram",
color: "steelblue",
// baseline: { defaultLevel: 100 }, // Add this property to vertically center the baseline at the `defaultLevel` value of 100.
yAxis
});
Extends
Members
-
init :object
-
You may set any initial parameters of the renderer here, and they will be used as default values in the renderer's
paramsobject. In order for these init values to take effect, they must be set on the prototype before the renderer is produced. This object is useful when you do not have access to the constructor, like when usingstxx.setChartType.Type:
- object
- Since:
-
8.4.0
- Inherited From:
- Overrides:
- Default Value:
-
- {}
Example
// Turns on heads-up display mode for the market depth chart. CIQ.Renderer.prototype.init = { headsUp: true }; stxx.setChartType("marketdepth_mountain_volume");
Methods
-
adjustYAxis()
-
If your renderer manages a y-axis then the necessary adjustments to its properties should be made here.
- Since:
-
5.2.0
- Inherited From:
- Overrides:
-
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 idstring The name of the series.
parametersobject | string Settings to control color and opacity of each series in the group. See CIQ.ChartEngine#addSeries for implementation examples.
Argument format can be:
- a
stringcontaining the color - or a more granular
objecthaving the following members:
Properties
Name Type Argument Default Description fieldstring <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_upstring <optional>
Color to use to fill the part when the Close is higher than the previous (or 'transparent' to not display)
border_color_upstring <optional>
Color to use to draw the border when the Close is higher than the previous (or 'transparent' to not display)
opacity_upnumber <optional>
.4 Opacity to use to fill the part when the Close is higher than the previous (0.0-1.0)
border_color_evenstring <optional>
Color to use to draw the border when the Close is equal to the previous (or 'transparent' to not display)
fill_color_downstring <optional>
Color to use to fill the part when the Close is lower than the previous (or 'transparent' to not display)
border_color_downstring <optional>
Color to use to draw the border when the Close is lower than the previous (or 'transparent' to not display)
opacity_downnumber <optional>
.4 Opacity to use to fill the part when the Close is lower than the previous (0.0-1.0)
colorstring <optional>
Color to use to fill the series in the absence of specific up/down color.
border_colorstring <optional>
Color to use to draw the border in the series in the absence of specific up/down color.
fillStylestring <optional>
Color to use to fill the mountain chart.
baseColorstring <optional>
Color to use at the bottom of the mountain chart, will create a gradient with bgColor
bgColorstring <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
permanentboolean <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.
labelsobject <optional>
Draw labels when set for histogram and line renderers
Properties
Name Type Argument Default Description backgroundColorstring <optional>
Label background color override
textColorstring <optional>
Label text color override
fontstring <optional>
"12px Arial" Label font override
boldboolean <optional>
Whether the font should be bold
italicboolean <optional>
Whether the font should be italic
paddingnumber <optional>
Label padding override
verticalOffsetnumber <optional>
Label vertical offset override
insideBarboolean <optional>
Whether to draw labels inside histogram bars
lastVisibleOnlyboolean <optional>
Draw only the last visible label
- Since:
-
5.1.0 Added
fillStyle,baseColor, andbgColorparameters.- 9.6.0 Added
parameters.priorityandparameters.labelsobject with backgroundColor, textColor, font, bold, italic, padding, verticalOffset, insideBar and lastVisibleOnly properties
- 9.6.0 Added
- Inherited From:
- Overrides:
Returns:
Returns a copy of this for chaining
- Type
- CIQ.Renderer
Example
// add multiple series and attach to a custom y-axis on the left. // note how the addSeries callback is used to ensure the data is present before the series is displayed //create the custom axis var axis=new CIQ.ChartEngine.YAxis(); axis.position="left"; axis.textStyle="#FFBE00"; axis.decimalPlaces=0; // no decimal places on the axis labels axis.maxDecimalPlaces=0; // no decimal places on the last price pointer //create the renderer var renderer=stxx.setSeriesRenderer(new CIQ.Renderer.Lines({params:{name:"my-renderer", type:"mountain", yAxis:axis}})); // create your series and attach them to the chart when the data is loaded. stxx.addSeries("NOK", {display:"NOK",width:4},function(){ renderer.attachSeries("NOK", "#FFBE00").ready(); }); stxx.addSeries("SNE", {display:"Sony",width:4},function(){ renderer.attachSeries("SNE", "#FF9300").ready(); }); - a
-
construct(config)
-
Default constructor for a renderer. Override this if desired.
Parameters:
Name Type Description configobject Configuration for the renderer.
Properties
Name Type Argument Description callbackfunction <optional>
Callback function to perform activity post-drawing, for example, creating a legend. It will be called with an object containing the list of instruments and corresponding colors.
idstring <optional>
Handle to access the rendering in the future. If not provided, one will be generated.
paramsobject <optional>
Parameters to control the renderer itself
Properties
Name Type Argument Default Description namestring <optional>
"Data" Name of the renderer. This is used when displaying error message on screen
panelstring <optional>
"chart" The name of the panel to put the rendering on.
overChartboolean <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.
yAxisboolean <optional>
Y-axis object to use for the series.
opacitynumber <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.
Not applicable on Lines with atypeofmountain; use an "RGBA" color instead.bindingobject <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.bindingparameter added.
- Inherited From:
- Overrides:
Example
// add multiple series and attach to a custom y-axis on the left. // See this example working here : https://jsfiddle.net/chartiq/b6pkzrad // note how the addSeries callback is used to ensure the data is present before the series is displayed //create the custom axis var axis=new CIQ.ChartEngine.YAxis(); axis.position="left"; axis.textStyle="#FFBE00"; axis.decimalPlaces=0; // no decimal places on the axis labels axis.maxDecimalPlaces=0; // no decimal places on the last price pointer //create the renderer var renderer=stxx.setSeriesRenderer(new CIQ.Renderer.Lines({params:{name:"my-renderer", type:"mountain", yAxis:axis}})); // create your series and attach them to the chart when the data is loaded. stxx.addSeries("NOK", {display:"NOK",width:4},function(){ renderer.attachSeries("NOK", "#FFBE00").ready(); }); stxx.addSeries("SNE", {display:"Sony",width:4},function(){ renderer.attachSeries("SNE", "#FF9300").ready(); }); -
draw()
-
Perform drawing operations here.
- Inherited From:
- Overrides:
-
drawIndividualSeries(chart [, parameters])
-
Draws one series from the renderer.
Parameters:
Name Type Argument Description chartCIQ.ChartEngine.Chart The chart object to draw the renderers upon
parametersobject <optional>
Parameters used to draw the series, depends on the renderer type
Properties
Name Type Argument Description panelstring <optional>
Name of panel to draw the series upon
- Since:
-
5.1.0
- Inherited From:
- Overrides:
-
drawLabels()
-
Draws labels for Histogram and Lines renderers. It calculates the positions of the labels and draws them on the chart for series that have been created with the "labels" property. Labels property object can contain aditional overrides such as backgroundColor, textColor, padding, vertical offset and font
- Since:
-
9.6.0
- Inherited From:
- Overrides:
-
getDependents(stx)
-
Returns an array of all renderers that depend on a given renderer.
A dependent renderer is one that has
params.dependentOfset to another renderer's name.Parameters:
Name Type Description stxCIQ.ChartEngine A chart object.
- Since:
-
7.3.0
- Inherited From:
- Overrides:
Returns:
Array of dependent renderers.
- Type
- array
-
getYAxis(stx)
-
Returns the y-axis used by the renderer.
Parameters:
Name Type Description stxCIQ.ChartEngine chart engine object
- Since:
-
7.1.0
- Inherited From:
- Overrides:
Returns:
Y-axis
-
isHistogram()
-
Checks if the renderer represents a histogram.
- Since:
-
9.8.0
- Inherited From:
- Overrides:
Returns:
True if the renderer is a histogram.
- Type
- boolean
-
isScatter()
-
Checks if the renderer represents a scatter plot.
- Since:
-
9.8.0
- Inherited From:
- Overrides:
Returns:
True if the renderer is a scatter plot.
- Type
- boolean
-
performCalculations()
-
This function is no longer used by the library. Use CIQ.Renderer#adjustYAxis instead.
- Inherited From:
- Overrides:
- Deprecated:
-
As of 5.2.0. no longer used in library..
-
ready()
-
Call this to immediately render the visualization, at the end of a chain of commands.
- Inherited From:
- Overrides:
Returns:
A copy of this for chaining
- Type
- CIQ.Renderer
-
removeAllSeries( [eraseData])
-
Removes all series from the renderer and the y-axis from the panel if it is not being used by any current renderers.
Parameters:
Name Type Argument Default Description eraseDataboolean <optional>
false Set to true to erase the actual series data in the CIQ.ChartEngine otherwise it will be retained
- Inherited From:
- Overrides:
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. Will turn off comparison mode if there are no more comparisons on the chart if CIQ.ChartEngine.Chart#forcePercentComparison is true.
Parameters:
Name Type Argument Default Description idstring The field name of the series.
preserveSeriesboolean <optional>
false Set to
trueto keep the series data in the CIQ.ChartEngine objects, otherwise it will be deleted.- Since:
-
- 2015-07-01 'preserveSeries' is now available.
- 3.0.0 Series is now removed even if series parameter
permanentis 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.
- 6.2.0 No longer force 'percent'/'linear', when adding/removing comparison series, respectively, unless CIQ.ChartEngine.Chart#forcePercentComparison is true. This allows for backwards compatibility with previous UI modules.
- Inherited From:
- Overrides:
Returns:
A copy of this for chaining
- Type
- CIQ.Renderer
-
undraggable(stx)
-
Returns whether the renderer can be dragged to another axis or panel.
Parameters:
Name Type Description stxCIQ.ChartEngine A chart object.
- Since:
-
7.3.0
- Inherited From:
- Overrides:
Returns:
true, if not allowed to drag.
- Type
- boolean
