Skip to content

Label: incorrect horizontal alignment for multiline strings #3859

@karlipl

Description

@karlipl

Question: Hi, I have a barplot with a multiline label. Is there a way to center each row of the label?
image
I would like the following result:
-------Row top
--Row in the middle
-----Row bottom

ScottPlot Version: ScottPlot 5.0.34

Code Sample:

Bar[] bars =
{
        new()
        {
            Position = 1,
            Value = 60000,
            BorderColor = Colors.White,
            FillColor = Color.FromHex("E56646"),
            ValueBase = 0,
            Label = $"Row top\nRow in the middle\nRow bottom",
            CenterLabel = true
        },
        new ()
        {
            Position = 1,
            Value = 60000 + 40000,
            BorderColor = Colors.White,
            FillColor = Color.FromHex("68BC5A"),
            ValueBase = 60000,
            Label = $"Row top\nRow in the middle\nRow bottom",
            CenterLabel = true
        }
    };

var barPlot = plot.Add.Bars(bars);

barPlot.ValueLabelStyle.ForeColor = Colors.White;
barPlot.ValueLabelStyle.Bold = true;
barPlot.ValueLabelStyle.FontSize = 16;

This is just a snippet of my code. I could provide a minimum full example if needed.

I would really appreciate some help.

Regards
Karl

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions