How to configure annotations to appear in plot area only


Author
Message
Vladimir Bershadsky
Vladimir Bershadsky
Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)
Group: Forum Members
Posts: 15, Visits: 1

Hi,

1. Tell me please how do I configure annotations to be shown within plot area bounds, or at least to disappear from sight when anchor point is not visible in current page view? You can see my problem in attached picture (Annotation.jpg). I used this code to create annotation:

         NRectangularCallout annotation = new NRectangularCallout();         annotation.Anchor = anchor;         annotation.Text = text;         annotation.AlwaysInsideParent = false;          annotation.ArrowBasePercent = 0F;         annotation.ArrowLength = new NLength(10F, NRelativeUnit.ParentPercentage);          annotation.FillStyle = new NColorFillStyle(Color.FromArgb(255,255,200));         annotation.PositionMode = CalloutPositionMode.AlignToText;         annotation.Orientation = 270F;         annotation.UseAutomaticSize = true;
   chartControl.Panels.Add(annotation);
2. Is it possible to use Offset Tool to drag and move annotations? 
Thank you very much in advance,
Vladimir
 
 

Attachments
Annotation.jpg (703 views, 50.00 KB)
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Vladimir,

1. What is the type of anchor you currently use? If it is a scale point anchor then you can specify that the annotation is not displayed using the Mode property (AxisValueAnchorMode.Clip) otherwise you can override the anchor IsVisible method and return false if the anchor is not visible.

2. No currently we don't have such functionality.

Let us know if you have any questions or meet any problems.



Best Regards,
Nevron Support Team


Vladimir Bershadsky
Vladimir Bershadsky
Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)
Group: Forum Members
Posts: 15, Visits: 1

Hi,

1. I use data point anchor (NDataPointAnchor). Can you please explain me how do I override the anchor IsVisible method?

2. It's OK, actually. I have already achieved necessary functionality by building custom DragTool.

Thank you.

Vladimir


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Vladimir,

The following code shows how to override the IsVisible method of the data point achor:

  [Serializable]
  class NMyAnchor : NDataPointAnchor
  {
   /// <summary>
   /// Default constructor
   /// </summary>
   public NMyAnchor()
   {

   }
   /// <summary>
   /// Initializer constructor
   /// </summary>
   /// <param name="chart"></param>
   /// <param name="line"></param>
   /// <param name="series"></param>
   /// <param name="dataPointIndex"></param>
   /// <param name="contentAlignment"></param>
   /// <param name="depthAlignment"></param>
   public NMyAnchor(NSeriesBase series, int dataPointIndex, ContentAlignment contentAlignment, StringAlignment depthAlignment)
    : base(series, dataPointIndex, contentAlignment, depthAlignment)
   {
   }
   /// <summary>
   /// Returns true if the anchor point is visible
   /// </summary>
   /// <returns></returns>
   public override bool IsVisible()
   {
    if (!base.IsVisible())
     return false;

    double xValue;

    NLineSeries line = Series as NLineSeries;
    NChart chart = line.Chart;

    if (line.UseXValues)
    {
     xValue = (double)line.XValues[DataPointIndex];
    }
    else
    {
     xValue = DataPointIndex;     
    }

    double yValue = (double)line.Values[DataPointIndex];

    return chart.Axis(StandardAxis.PrimaryX).Scale.RulerRange.Contains(xValue) &&
      chart.Axis(StandardAxis.PrimaryY).Scale.RulerRange.Contains(yValue);
   }
  }

  private void Form1_Load(object sender, EventArgs e)
  {
   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
   chart.RangeSelections.Add(new NRangeSelection());

   chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;
   chart.Axis(StandardAxis.PrimaryY).ScrollBar.Visible = true;

   NLineSeries line = new NLineSeries();
   line.DataLabelStyle.Visible = false;

   for (int i = 0; i < 100; i++)
   {
    line.Values.Add(i);
   }

   chart.Series.Add(line);

   NMyAnchor anchor = new NMyAnchor(line, 50, ContentAlignment.MiddleCenter, StringAlignment.Center);

   NRectangularCallout annotation = new NRectangularCallout();
   annotation.Text = "Annotated Data Point";
   annotation.Anchor = anchor;
   annotation.UseAutomaticSize = true;

   chart.ChildPanels.Add(annotation);

   nChartControl1.Controller.Tools.Add(new NSelectorTool());
   nChartControl1.Controller.Tools.Add(new NAxisScrollTool());
   nChartControl1.Controller.Tools.Add(new NDataZoomTool());
  }

Let us know if you meet any problems.



Best Regards,
Nevron Support Team


Vladimir Bershadsky
Vladimir Bershadsky
Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)
Group: Forum Members
Posts: 15, Visits: 1

Thank you very much! This is exactly what I needed.

Best regards,

Vladimir


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search