Multiline RectangleArrow AnnotationXY

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
paultobey
Posts: 21
Joined: Mon Dec 09, 2013 7:27 pm

Multiline RectangleArrow AnnotationXY

Post by paultobey » Wed Feb 19, 2014 3:55 pm

Hi,

I have an XY chart that is working well. I create a "cursor" which the user can drag around to see data values from each series. Just below the X-axis, at this cursor position, I have an AnnotationXY to show the X value at the cursor position. This works fine but I'd like, for multi-day charts, to display 2 lines of text in the X value annotation rather than 1. The annotation is created as shown below:

AnnotationXY annotation = new AnnotationXY(Chart1.ViewXY,
Chart1.ViewXY.XAxes[0],
Chart1.ViewXY.YAxes[0]);
annotation.Style = AnnotationStyle.RectangleArrow;

// The user should not be able to move the annotation around.
annotation.MouseInteraction = false;
annotation.MoveByMouse = false;
annotation.AnchorAdjustByMouse = false;
annotation.ResizeByMouse = false;
annotation.RotateByMouse = false;
annotation.TargetMoveByMouse = false;

// Target is the actual data value location referenced by the annotation.
annotation.TargetCoordinateSystem = AnnotationTargetCoordinates.AxisValues;
annotation.TargetAxisValues.Y = Chart1.ViewXY.YAxes[0].Minimum; // We want the value to be on the X-axis for this marker.
annotation.TargetAxisValues.X = Chart1.ViewXY.XAxes[0].Minimum; // Set to left edge.

// Location is where the callout or text is located.
annotation.LocationCoordinateSystem = CoordinateSystem.RelativeCoordinatesToTarget;
annotation.LocationRelativeOffset.Y = DateAnnotationYOffsetFromCursor;
annotation.LocationRelativeOffset.X = DateAnnotationXOffsetFromCursor;

// Center text.
annotation.TextStyle.HorizAlign = AlignmentHorizontal.Center;
annotation.TextStyle.VerticalAlign = AlignmentVertical.Center;

// Color should be a color not used for series data.
annotation.ArrowLineStyle.Color = Colors.SkyBlue;
annotation.Fill.Color = Colors.SkyBlue;
annotation.Fill.GradientColor = Colors.SlateBlue;
annotation.Fill.Bitmap.Layout = BitmapFillLayout.Center;

// Size should be minimized.
annotation.Sizing = AnnotationXYSizing.Automatic;
annotation.AutoSizePadding = 5;

// Adjust where the connector line starts on the annotation body and what the start point looks like (no dot or arrow).
annotation.ArrowStyleBegin = ArrowStyle.None;
annotation.Anchor.X = 0.5F; // Center
annotation.Anchor.Y = 0; // Top

// Don't clip to the chart area.
annotation.ClipInsideGraph = false;
annotation.Visible = true;

return annotation;

When I change the annotation text to add a "\n" character between the 2 lines I want, I DO get 2 lines, but the second line is left-justified, not centered. Can you direct me? See picture attached.

Thanks,
Paul T.
Attachments
AnnotationXYCenterText.png
AnnotationXYCenterText.png (25.84 KiB) Viewed 7476 times

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Multiline RectangleArrow AnnotationXY

Post by ArctionPasi » Wed Feb 19, 2014 7:31 pm

The annotation text is left-aligned only. To make the bottom row middle-aligned, add spaces in the beginning of bottom row.
int spacesCount = (topRowLenght - bottomRowLength)/2.

Remember to use a mono-space font, so all characters are of equal width.
LightningChart Support Team, PT

paultobey
Posts: 21
Joined: Mon Dec 09, 2013 7:27 pm

Re: Multiline RectangleArrow AnnotationXY

Post by paultobey » Wed Feb 19, 2014 7:43 pm

Not an attractive option. I'll consider it. Please add this feature request.

Thanks,
Paul T.

Post Reply