Plugins

You can add auxiliary elements to your chart using plugins (via the plugins keyword).

Vertical line

LightweightCharts.Plugins.lwc_vert_lineFunction
lwc_vert_line(index::Int64; kw...) -> LWCPlugin

Adds a vertical line based on index to the chart.

Keyword arguments

Name::TypeDefault (Possible values)Description
label_text::String""Vertical line label.
width::Float643.0Vertical line width.
color::StringRandom colorColor of the vertical line.
label_background_color::StringRandom colorLabel background color.
label_text_color::String"white"Label text color.
show_label::BoolfalseLabel visibility.
source

Examples

using LightweightCharts

t_values = round(Int64, time()) .+ collect(0:300)
x_values = map(x -> 1/(x - 250), 0:300)

chart = lwc_line(
    t_values,
    x_values;
    line_color = "#7678ed",
    label_name = "hyperbola",
    price_scale_id = LWC_RIGHT,
    plugins = [
        lwc_vert_line(
            250;
            color = "#f18701",
            label_background_color = "#f35b04",
            show_label = true,
            label_text = "lwc_vert_line",
        ),
    ],
)

lwc_save("vert_line_example.html", chart)

Tooltip

LightweightCharts.Plugins.lwc_tooltipFunction
lwc_vert_line(; kw...) -> LWCPlugin

Adds a dynamic tooltip to the chart following the cursor and displaying the values.

Keyword arguments

Name::TypeDefault (Possible values)Description
line_color::String"rgba(0, 0, 0, 0.2)"Tooltip line color.
title::String""Tooltip title.
follow_mode::LWC_TOOLTIP_TYPELWC_TOOLTIP_TOP (LWC_TOOLTIP_TRACK)Tooltip Location.
horizontal_deadzone_width::Int6445
vertical_deadzone_height::Int64100Horizontal deadzone height.
vertical_spacing::Int6420Vertical spacing.
top_offset::Int6420Vertical offset for tooltip.
source

Examples

using LightweightCharts

t_values = round(Int64, time()) .+ collect(1:300)
x_values = map(x -> cos(x / 10), 1:300)

chart = lwc_line(
    t_values,
    x_values;
    line_color = "#0fa3b1",
    label_name = "cos",
    line_type = LWC_STEP,
    line_width = 2,
    price_scale_id = LWC_RIGHT,
    plugins = [
        lwc_tooltip(;
            line_color = "#7400b8",
            follow_mode = LWC_TOOLTIP_TRACK,
        ),
    ],
)

lwc_save("tooltip_example.html", chart)

Delta tooltip

LightweightCharts.Plugins.lwc_delta_tooltipFunction
lwc_vert_line(; kw...) -> LWCPlugin

Adds a dynamic tooltip to the chart following the cursor and displaying the values (and their change, while holding down the mouse button).

Keyword arguments

Name::TypeDefault (Possible values)Description
line_color::String"rgba(0, 0, 0, 0.2)"Line color.
show_time::BoolfalseDetailed time display.
top_offset::Int6420Vertical offset for tooltip.
source

Examples

using LightweightCharts

t_values = round(Int64, time()) .+ collect(1:300)
x_values = map(x -> sin(x / 10), 1:300)

chart = lwc_line(
    t_values,
    x_values;
    line_color = "#90be6d",
    label_name = "sin",
    line_width = 2,
    price_scale_id = LWC_RIGHT,
    plugins = [
        lwc_delta_tooltip(;
            show_time = true,
            top_offset = 10,
        ),
    ],
)

lwc_save("delta_tooltip_example.html", chart)

Trend line

LightweightCharts.Plugins.lwc_trend_lineFunction
lwc_trend_line(start_index, start_price, end_index, end_price; kw...) -> LWCPlugin

Adds a trend line to the chart starting with start_index and start_price and ending with end_index and end_price.

Keyword arguments

Name::TypeDefault (Possible values)Description
line_color::StringRandom colorLine color.
width::Int646Line width.
show_labels::BooltrueLabels visibility.
label_background_color::String"rgba(255, 255, 255, 0.85)"Label background color.
label_text_color::String"rgb(0, 0, 0)"Label text color.
source

Examples

using LightweightCharts

t_values = round(Int64, time()) .+ collect(1:300)
x_values = map(x -> cos(x / 10), 1:300)

chart = lwc_line(
    t_values,
    x_values;
    line_color = "#c77dff",
    label_name = "cos",
    price_scale_id = LWC_RIGHT,
    plugins = [
        lwc_trend_line(
            220,
            -0.7,
            250,
            1.3;
            line_color = "#ff6700",
        ),
    ],
)

lwc_save("trend_line_example.html", chart)

Crosshair bar

LightweightCharts.Plugins.lwc_crosshair_highlight_barFunction
lwc_crosshair_highlight_bar(; kw...) -> LWCPlugin

Adds additional highlighting to the cursor crosshairs.

Keyword arguments

Name::TypeDefault (Possible values)Description
color::String"rgba(0, 0, 0, 0.2)"Crosshair highlight color.
source

Examples

using LightweightCharts

t_values = round(Int64, time()) .+ collect(1:300)
x_values = map(x -> cos(x / 10), 1:300)

chart = lwc_line(
    t_values,
    x_values;
    line_color = "#0a9396",
    label_name = "cos",
    price_scale_id = LWC_RIGHT,
    plugins = [
        lwc_crosshair_highlight_bar(;
            color = "#94d2bd",
        ),
    ],
)

lwc_save("crosshair_bar_example.html", chart)