Profile Picture

How to configure annotations to appear in plot area only

Posted By Vladimir Bershadsky 11 Years Ago

How to configure annotations to appear in plot area only

Author
Message
Vladimir Bershadsky
Posted 11 Years Ago
View Quick Profile
Junior Member

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
Last Active: 10 Years Ago
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 (670 views, 50.00 KB)
Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

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
Posted 11 Years Ago
View Quick Profile
Junior Member

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
Last Active: 10 Years Ago
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
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

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
Posted 11 Years Ago
View Quick Profile
Junior Member

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
Last Active: 10 Years Ago
Posts: 15, Visits: 1

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

Best regards,

Vladimir





Similar Topics


Reading This Topic