Skip to main content
Version: latest

Drawing Overrides

The Overrides API includes properties that can be used to customize drawing parameters such as colors, width, size, and more. This article describes ways to customize drawings and contains a list of overrides for each drawing.

Customize drawings

This section describes ways to customize drawings.

Specify default properties

You should use the overrides property of the Widget Constructor to specify the drawing's default properties. For example, the following code sample specifies that all Horizontal Lines should be green and dashed.

var widget = window.tvWidget = new TradingView.widget({
// ...
overrides: {
"linetoolhorzline.linecolor": "rgba(48, 164, 22, 0.8)",
"linetoolhorzline.linestyle": 2,
}
});

Change default properties on the fly

To change the drawing's default properties after the chart is initialized, use the applyOverrides method. All drawings created after the applyOverrides call have new properties. For example, the following code sample specifies that all newly created Horizontal Lines should be purple.

widget.applyOverrides({ "linetoolhorzline.linecolor": "#7f11e0" });

Change the existing drawing

If you want to change a drawing that is already on the chart, use the setProperties method in ILineDataSourceApi. For example, the code sample below specifies new properties for the existing Icon.

const iconId = widget.activeChart().getAllShapes().find(x => x.name === "icon").id;
const icon = widget.activeChart().getShapeById(iconId);
icon.setProperties({ size: 60, color: "#7f11e0" });

Customize a single drawing

If you need to change a style of only one drawing, create the drawing using the Drawings API and pass overrides properties as a parameter. These properties are applied above the default ones that are specified in overrides.

For example, the code sample below specifies that the default Horizontal Line color is green and creates one red Horizontal Line.

var widget = window.tvWidget = new TradingView.widget({
// ...
overrides: {
"linetoolhorzline.linecolor": "rgba(48, 164, 22, 0.8)",
}
});

widget.onChartReady(() => {
widget.chart().createShape(
{ price: 180 },
{
shape: "horizontal_line",
overrides: { linecolor: "#FF0000" },
}
)
});

List of overrides

Refer to DrawingOverrides for a list of overrides.