Skip to content

Title alignment #266

@bvenn

Description

@bvenn

Description

When defaults are applied the title is left aligned. To center the title the layout must be modified, which is not straight forward to do. It would be easier to set the alignment at Chart.withTitle

Chart.Point([1,2])
|> Chart.withTitle "Title1"
|> Chart.show


Chart.Point([1,2])
|> Chart.withLayout(
    Layout.init(
        Title=Title.init("Title2",X=0.5)
        )
    )
|> Chart.show

image

Solution

Add the X position option to Chart.withTitle. To clarify the usage, an Alignment type (center, left, right) would be beneficial, but eventually would break the Plotly.NET standards. Other Title options like Standoff, Side, and Y could be added as well.

static member withTitle(title, [<Optional; DefaultParameterValue(null)>] ?X, [<Optional; DefaultParameterValue(null)>] ?TitleFont) =
    (fun (ch: GenericChart) ->
        let layout =
            Layout() |> Layout.style (Title = Title.init (Text = title, ?X = X, ?Font = TitleFont))
        GenericChart.addLayout layout ch)

Question

I'm not sure what the Side is for when dealing with Titles. I tried some sides, but the title position did not change. Does it correspond to layout-title-pad?

HTML for Title=Title.init("Title2",Side=Side.Bottom):
"title":{"text":"Title2","side":{"Case":"Bottom"}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions