Layouts

Here you can find various examples that show how a user can combine different charts, plugins and panels together.

Panel

LightweightCharts.lwc_panelFunction
lwc_panel(charts::LWCChart...; kw...) -> LWCPanel

Creates a panel combining several charts.

Keyword arguments

Name::TypeDefault/Possible valuesDescription
x::Int64-999Panel's horizontal coordinates
y::Int64-999Panel's vertical coordinates
name::String"LightweightCharts ❤️ Julia"Panel name (will be displayed in the browser tab title).
min_y::Union{Real,Nothing}nothingLower bound on the y-axis.
left_min_y::Union{Real,Nothing}nothingLower bound on the left y-axis.
right_min_y::Union{Real,Nothing}nothingLower bound on the right y-axis.
max_y::Union{Real,Nothing}nothingUpper bound on the y-axis.
left_max_y::Union{Real,Nothing}nothingUpper bound on the left y-axis.
right_max_y::Union{Real,Nothing}nothingUpper bound on the right y-axis.
seconds_visible::BoolfalseSeconds visibility on the x-axis.
bar_spacing::Real6Distance between the stripes in pixels.
min_bar_spacing::Real0.5Minimum distance between the stripes in pixels.
copyright::BooltrueEnables a TradingView trademark symbol on the chart.
tooltip::BooltrueEnables tooltip for points.
tooltip_format::String"${label_name}: (${time}, ${value})"String formatting of tooltip text. Display the variables "title", "time" and "value" in the desired format.
min_charts_for_search10Minimum number of charts to search.
mode::LWC_PRICE_SCALE_MODE0Price scale mode.
crosshair_settings::CrosshairOptionsCrosshairOptions()Structure describing crosshair options.
cursor::LWC_CURSORLWC_CURSOR_DEFAULCursor type.
last_value_visible::BoolfalseShows the latest price label on the price scale.
title_visible::BoolfalseShows the chart name next to the latest price label.
default_legend_visible::BooltrueShows the legend box with data charts names and colors.
source

Example

using LightweightCharts

t_values = round(Int64, time()) .+ collect(1:500)
x_values = map(x -> rand(1:500), collect(1:500))

panel = lwc_panel(
    lwc_line(
        t_values,
        x_values .+ 500.0;
        label_name = "lwc_line",
        line_color = "#f35B04",
        line_visible = false,
        point_markers_visible = true,
        price_scale_id = LWC_RIGHT,
    ),
    lwc_histogram(
        t_values,
        x_values;
        label_name = "lwc_histogram",
        base = 250.0,
        color = "rgba(118, 120, 237, 0.5)",
        price_scale_id = LWC_RIGHT,
    );
    name = "Panel example",
    crosshair_settings = CrosshairOptions(;
        mode = LWC_CROSSHAIR_NORMAL,
        vert_line = CrosshairLineOptions(;
            style = LWC_CROSSHAIR_SOLID,
            color = "#C3BCDB44",
            label_background_color = "#9B7DFF",
            width = 8,
        ),
        horz_line = CrosshairLineOptions(;
            color = "#9B7DFF",
            label_background_color = "#9B7DFF",
        )
    ),
)

lwc_save("panel_example.html", panel)

Layout

LightweightCharts.lwc_layoutFunction
lwc_layout(panels::LWCPanel...; kw...) -> LWCLayout

Combines multiple panels into a common layout.

Keyword arguments

Name::TypeDefault (Possible) valuesDescription
name::String"LightweightCharts ❤️ Julia"Layout name (will be displayed in the browser tab title).
sync::BooltrueSynchronization of chart scrolling.
min_height::Integer300Minimum of layout height in px.
source

Example

using Dates, NanoDates
using LightweightCharts

layout = lwc_layout(
    lwc_panel(
        lwc_baseline(
            NanoDate("2024-01-01") .+ Second.(1:500),
            map(x -> rand(1:500), collect(1:500));
            label_name = "lwc_baseline",
            base_value = LWCBaseValue("price", 250),
            top_line_color = "#6a994e",
            top_fill_color1 = "#a7c957",
            bottom_line_color = "#e76f51",
            bottom_fill_color2 = "#f4a261",
            line_style = LWC_SOLID,
            line_type = LWC_CURVED,
            line_width = 3,
            precision = 4,
            price_scale_id = LWC_RIGHT,
        );
        tooltip = false,
        last_value_visible = true,
        title_visible = true,
        x = 1,
        y = 1,
    ),
    lwc_panel(
        lwc_area(
            NanoDate("2024-01-01") .+ Second.(1:500),
            map(x -> sin(x / 10), collect(1:500));
            label_name = "lwc_area",
            line_color = "#2ec4b6",
            top_color = "#cbf3f0",
            bottom_color = "rgba(133, 242, 240, 0)",
            line_style = LWC_SOLID,
            line_type = LWC_STEP,
            line_width = 2,
            precision = 3,
            price_scale_id = LWC_RIGHT,
        ),
        lwc_line(
            NanoDate("2024-01-01") .+ Second.(1:500),
            map(x -> cos(x / 10), collect(1:500));
            label_name = "lwc_line",
            line_color = "#ff7d00",
            line_style = LWC_SPARSE_DOTTED,
            line_type = LWC_SIMPLE,
            line_width = 3,
            price_scale_id = LWC_RIGHT,
        );
        tooltip_format = "\${label_name}: \${value}",
        default_legend_visible = true,
        x = 1,
        y = 2,
    );
    min_height = 480,
    name = "Layout example",
)

lwc_save("layout_example.html", layout)