|
Group: Forum Members
Posts: 43,
Visits: 1
|
Thanks for answers. My code to configure the annotation: //type is one of the following types: NArrowAnnotation, NArrowCallout, NOvalCallout, NRectangularCallout, NRoundedRectangularCallout, NCutEdgeRectangularCallout NAnnotation callout = Activator.CreateInstance(type) as NAnnotation; callout.UseAutomaticSize = true; //chartLine is NLineSeries callout.Anchor = new NDataPointAnchor(chartLine, 0, ContentAlignment.MiddleCenter, StringAlignment.Center); //line_descriptor is an object that configures annotation's properties int alpha = 255 - (int)(line_descriptor.AnnotationTransparency / 100.0 * 255); callout.FillStyle = new NColorFillStyle(Color.FromArgb(alpha, line_descriptor.AnnotationFillColor)); callout.Text = line_descriptor.AnnotationText; callout.Visible = line_descriptor.AnnotationVisible; callout.Orientation = line_descriptor.AnnotationAngle; if (callout is NCallout) { ((NCallout)callout).ArrowLength = new NLength(line_descriptor.AnnotationArrowLength, NRelativeUnit.ParentPercentage); } else if (callout is NArrowAnnotation) { NArrowAnnotation arrow = callout as NArrowAnnotation; arrow.ArrowHeadWidthPercent = line_descriptor.AnnotationArrowLength; } callout.TextStyle = new NTextStyle(line_descriptor.AnnotationTextFont, line_descriptor.AnnotationTextColor); callout.StrokeStyle = new NStrokeStyle(1, Color.Black, (LinePattern)((int)line_descriptor.AnnotationLineType)); if (callout is NArrowCallout) { NArrowCallout arrow = callout as NArrowCallout; arrow.EndCapStyle.Offset = new NLength(5); arrow.EnableBaseLine = false; arrow.BeginCapStyle.Style = CapStyle.None; } //and this code runs after adding values to line: int linePointsCount = chartLine.Values.Count; float positionPercent = line_descriptor.AnnotationPosition; int linePointIndex = (int)(((double)linePointsCount) * positionPercent / 101.0); ((NDataPointAnchor)callout.Anchor).DataPointIndex = linePointIndex;
|