Reputation: 1
I have a lot of annotations in a chart I need to keep track of. So I was trying to use Annotation Groups. I've been using the AnchorX property to anchor the annotations to data points, and it has worked fine for me. However, I get some really weird results when I try and use an annotation group.
I suspect it has something to do with relative vs axes coordinates, but the Microsoft documentation does a horrible job at explaining the difference between them.
Based on this answer, I managed to make the annotations actually show by setting the size and everything, but it still doesn't explain the coordinate system within the group.
AnnotationGroup group = new AnnotationGroup()
{
AxisX = chart1.ChartAreas[0].AxisX,
AxisY = chart1.ChartAreas[0].AxisY,
ClipToChartArea = chart1.ChartAreas[0].Name,
IsSizeAlwaysRelative = false,
AnchorX = 50,
AnchorY = 50,
Width = 50,
Height = 50
};
var textAnnotation = new TextAnnotation
{
AnchorX = 50,
AnchorY = 50,
//Name = _phaseName,
Text = "P",
//Tag = phase,
AllowTextEditing = true,
Font = new System.Drawing.Font("Arial", 24),
IsSizeAlwaysRelative = false,
Alignment = ContentAlignment.MiddleCenter,
ClipToChartArea = chart1.ChartAreas[0].Name,
AllowAnchorMoving = true,
Visible = true,
IsMultiline = false
};
group.Annotations.Add(textAnnotation);
chart1.Annotations.Add(group);
I tried making a 100x100 chart and putting the group in the middle. Made the size of the group 50x50. Then putting the annotation in (50,50) I was hoping it would be in the middle of the group, but what I get is pretty inconsistent. I am really confused and don't understand if relative means pixel-based or if it's based on something else.
Thank you.
Upvotes: 0
Views: 20