Nevron Forum

Set NRoundedRectangularCallout position

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

By Elvira Aminova - Wednesday, December 18, 2013

Hello!

I use NRoundedRectangularCallout to mark last points of each line.

NRoundedRectangularCallout rectangularCallout = new NRoundedRectangularCallout();
rectangularCallout.ArrowLength = new NLength(15, NRelativeUnit.ParentPercentage);
rectangularCallout.ArrowBasePercent = 10;
rectangularCallout.FillStyle = new NColorFillStyle(Color.White);
rectangularCallout.UseAutomaticSize = true;
rectangularCallout.Orientation = 0;
rectangularCallout.Anchor = new NDataPointAnchor(line, line.Values.Count - 1, ContentAlignment.BottomCenter, StringAlignment.Center);

The result is on the picture "1.png". You can see that some callouts are overlaped.

I need something like this: see "2.png" (I manually change the callouts location).
Сallouts are one under the other and not overlap each other. How can I achieve this by code?
By Nevron Support - Wednesday, December 18, 2013

Hi Elvira,

The control does not support automatic overlapping resolve for callouts. You can however use a different approach and that is to place a data label at the end of each line - data labels have support for non overlapping (check out the Panels\Chart\Automatic Label Layout) example.
By Elvira Aminova - Wednesday, December 18, 2013

I probably found the solution.

Need to use rectangularCallout.Orientation - the angle between callout arrow and X-axis;
rectangularCallout.ArrowLength - the distance between data point on line and a callout.
By Elvira Aminova - Thursday, December 19, 2013

Thank you!

Using data labels will be a better solution.
By Elvira Aminova - Thursday, December 19, 2013

How can I change the horizontal alignment of data label?
There is only "VertAlign" property.

Need something like this:

NDataLabelStyle label = new NDataLabelStyle();
label.VertAlign = VertAlign.Center;
label.HorizontalAlign = HorizontalAlign.Right;
By Nevron Support - Thursday, December 19, 2013

Hi Elvira,

You can use the string format:

dtLabel.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Right;

Let us know if you meet any problems...
By Elvira Aminova - Friday, December 27, 2013

I use a string format:

NDataLabelStyle label = new NDataLabelStyle();
label.TextStyle.FontStyle.Style = FontStyle.Bold;
label.TextStyle.FillStyle = new NColorFillStyle(Color.Crimson);
label.VertAlign = VertAlign.Center;
label.ArrowLength = new NLength(10);
label.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Left;

But labels were overlapped and arrows length equals to 0 (see 3.png).

Then I set EnableLabelAdjustment property to prevent overlapping:
cartesianChart.LabelLayout.EnableLabelAdjustment = true;

Now labels are not overlapping but horizontal alignment isn't left (see 4.png).
What can I do to get something like this (see 5.png)
By Nevron Support - Monday, January 20, 2014

Hi,

If the automatic label layout is disabled, the labels cannot be placed to the left or to the right of a data point. So, the EnableInitialPositioning property must be set to true:


   chart.LabelLayout.EnableInitialPositioning = true;
   chart.LabelLayout.EnableLabelAdjustment = true; // this is not mandatory


Then you can specify the allowed label locations for each series. In the code below only Left and Right are set, but you can allow more locations (note that the order determines their priority).


   series.DataLabelStyle.Visible = true;
   series.LabelLayout.LabelLocations = new LabelLocation[]
   {
      LabelLocation.Left,
      LabelLocation.Right
   };