Hi, i'm trying to use PolygonAnnotation to draw a Polygon within a chart where i have four points that i would like to use as vertex.
These Points are putted at runtime in a Bubble Series
System.Windows.Forms.DataVisualization.Charting.Series serieSA = chartCartesian.Series.FindByName("SeriesSafetyArea");
DataPoint dpA = new DataPoint(radarConfigured.SafetyArea.PointA.X,new Double[]{radarConfigured.SafetyArea.PointA.Y, -20});
DataPoint dpB = new DataPoint(radarConfigured.SafetyArea.PointB.X, new Double[]{radarConfigured.SafetyArea.PointB.Y, -20});
DataPoint dpC = new DataPoint(radarConfigured.SafetyArea.PointC.X, new Double[] { radarConfigured.SafetyArea.PointC.Y, -20 });
DataPoint dpD = new DataPoint(radarConfigured.SafetyArea.PointD.X, new Double[] { radarConfigured.SafetyArea.PointD.Y, -20 });
dpA.Label = "A";
dpB.Label = "B";
dpC.Label = "C";
dpD.Label = "D";
serieSA.Points.Add(dpA);
serieSA.Points.Add(dpB);
serieSA.Points.Add(dpC);
serieSA.Points.Add(dpD);
I would like to obtain a figure like a rectangle using these points. i've tried usign this code
What I have tried:
safetyAreaAnnotation = new PolygonAnnotation();
safetyAreaAnnotation.ClipToChartArea = chartCartesian.ChartAreas[0].Name;
PointF[] points = new PointF[4];
points[0].X = (float)dpA.XValue;
points[0].Y = (float)dpA.YValues[0] ;
points[1].X = (float)dpB.XValue;
points[1].Y = (float)dpB.YValues[0];
points[2].X = (float)dpC.XValue;
points[2].Y = (float)dpC.YValues[0];
points[3].X = (float)dpD.XValue;
points[3].Y = (float)dpD.YValues[0];
byte[] type = new byte[4];
type[0] = (byte)PathPointType.Start;
type[1] = (byte)PathPointType.Line;
type[2] = (byte)PathPointType.Line;
type[3] = (byte)PathPointType.CloseSubpath;
safetyAreaAnnotation.GraphicsPath=new System.Drawing.Drawing2D.GraphicsPath(points,type);
safetyAreaAnnotation.AxisX = chartCartesian.ChartAreas[0].AxisX;
safetyAreaAnnotation.AxisY = chartCartesian.ChartAreas[0].AxisY;
safetyAreaAnnotation.AnchorDataPoint = serieSA.Points[0];
chartCartesian.Annotations.Add(safetyAreaAnnotation);
But it doesn't work. Nothing is displayed in my chart. Maybe i should use something different to draw this polygon?