Nevron Forum

Questions about annotations

https://www.nevron.com/Forum/Topic5637.aspx

By Alina Voskova - Thursday, September 29, 2011

Hello.
1. I have NArrowCallout attached to the data point in the line series. It has the default EndCapStyle: Arrow with size 5x5. But I see that the arrow not points to the data point. I tried to set the Offset property, but I have not seen any changes.
2. Is it possible not render part of annotation (or the whole annotation) that is on the chart but outside the area bounded with axes?
By Nevron Support - Thursday, September 29, 2011

Hi Ereona,

1. I have NArrowCallout attached to the data point in the line series. It has the default EndCapStyle: Arrow with size 5x5. But I see that the arrow not points to the data point. I tried to set the Offset property, but I have not seen any changes.

Can you post the code that configures the callout?

2. Is it possible not render part of annotation (or the whole annotation) that is on the chart but outside the area bounded with axes?
No - the chart cannot clip child panels at tis point. You can wordaround this by using custom painting (All examples\Custom Painting). There you can set a clip region based on the plot bounds of the chart.

By Alina Voskova - Monday, October 3, 2011

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;