Skip to content

Fix label text position when offset specified#3898

Merged
swharden merged 3 commits intoScottPlot:mainfrom
bclehmann:fix/label-with-offset
Jun 5, 2024
Merged

Fix label text position when offset specified#3898
swharden merged 3 commits intoScottPlot:mainfrom
bclehmann:fix/label-with-offset

Conversation

@bclehmann
Copy link
Member

@bclehmann bclehmann commented Jun 3, 2024

This is just the patch from #3865 pushed to a new branch, as the creator of that PR closed it.

var plot = AvaPlot.Plot;
var color = Colors.Cyan;

var vLine = plot.Add.VerticalLine(1000, 1, color, LinePattern.Dashed);
vLine.LabelFontColor = Color.FromARGB(0xC0000000);
vLine.LabelBorderColor = color;
vLine.LabelBackgroundColor = Colors.Transparent;
vLine.LabelText = $"{Math.Round(1000f, 3)}Hz"; // Label the line with its position
vLine.LabelRotation = -90;
vLine.LabelAlignment = Alignment.MiddleRight;
vLine.LabelOffsetX = -20;
vLine.LabelOffsetY = -250;

Before:
image

After:
image

swharden and others added 2 commits June 5, 2024 08:26
Co-authored-by: ValeraTychov <[email protected]>
Co-authored-by: Benjamin Lehmann <[email protected]>
@swharden swharden enabled auto-merge (squash) June 5, 2024 12:30
@swharden swharden merged commit fd16ebd into ScottPlot:main Jun 5, 2024
@swharden swharden linked an issue Jun 5, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vertical line: label text position is incorrect

3 participants