ChartJs

Patchwork.ChartJsPlugin.ChartJsType
ChartJs(
    title::String,
    chart_type::String,
    data::Dict{String,Any};
    options::Dict{String,Any} = Dict{String,Any}()
)

Chart.js visualization plugin.

Creates interactive charts using Chart.js library. Supports multiple chart types with customizable options. Always use Dict{String,Any} for type parameters to avoid type inference issues.

Fields

  • title::String: Chart title displayed above the visualization
  • chart_type::String: Type of chart (line, bar, radar, doughnut, pie, polarArea, bubble, scatter)
  • data::Dict{String,Any}: Chart data configuration (labels and datasets)
  • options::Dict{String,Any}: Optional chart configuration options

Example: Bar Chart

Patchwork.ChartJs(
    "Sales by Quarter",
    "bar",
    Dict{String,Any}(
        "labels" => ["Q1", "Q2", "Q3", "Q4"],
        "datasets" => [
            Dict{String,Any}(
                "label" => "2024",
                "data" => [12, 19, 8, 15],
                "backgroundColor" => "rgba(54, 162, 235, 0.5)",
            ),
        ],
    ),
)

Example: Doughnut Chart

Patchwork.ChartJs(
    "Traffic Sources",
    "doughnut",
    Dict{String,Any}(
        "labels" => ["Direct", "Social", "Organic"],
        "datasets" => [
            Dict{String,Any}(
                "data" => [300, 150, 200],
                "backgroundColor" => ["#FF6384", "#36A2EB", "#FFCE56"],
            ),
        ],
    ),
)

Example: With Custom Options

Patchwork.ChartJs(
    "Time Series",
    "line",
    Dict{String,Any}(...),
    options = Dict{String,Any}(
        "plugins" => Dict(
            "legend" => Dict("position" => "top"),
        ),
    ),
)

See also: Highcharts, Plotly, Plugin

source