Assign different Anchor-Point to NRectangularCallout


https://www.nevron.com/Forum/Topic9488.aspx
Print Topic | Close Window

By joern kunze - 9 Years Ago
I use a NRectangularCallout together with a 2d-LineChart (just a couple of X-Y pairs) - the NRectangularCallout configuration:

    m_RectangularCallout.ArrowLength = new NLength(10, NRelativeUnit.ParentPercentage);
      m_RectangularCallout.StrokeStyle.Width = new NLength(1);  //disable Callout border: = 0
      m_RectangularCallout.UseAutomaticSize = true;
      m_RectangularCallout.Orientation = iLabelPos;
      m_RectangularCallout.Text = oLine.m_sLabel;

      _NevronChart.Panels.Add(m_RectangularCallout);

      // Anchor the callout to data point #0
      NDataPointAnchor anchor = new NDataPointAnchor(line, 0, ContentAlignment.MiddleCenter, StringAlignment.Center);
      m_RectangularCallout.Anchor = anchor;

This works as expected. But now I want to change the anchor for the Callout - I tried the following:

1- Approach: Anchor at DataPoint 2
 NDataPointAnchor anchor = new NDataPointAnchor(oNevronLineSeries, 1, ContentAlignment.MiddleCenter, StringAlignment.Center);

           oCallout.RecalcLayout(NevronChart.View.Context);

      oChart.Chart.RecalcLayout(NevronChart.View.Context);
      oChart.Chart.Refresh();


Unfortunatly, nothing happens at all. So how can I change the anchor for the Callout?
 
2. Approach: Using a ScaleAnchor:

           oCallout.Anchor = new NScalePointAnchor(oChart.Chart, 0, 0, 0, AxisValueAnchorMode.Show, new NVector3DD(42348.931761342596, 0.0, 0));

           oCallout.RecalcLayout(NevronChart.View.Context);
        
      oChart.Chart.RecalcLayout(NevronChart.View.Context);
      oChart.Chart.Refresh();

But same as approach 1: Nothing happens at all. So how do I change the anchor to a NScalePointAnchor?

Thanks for the help,
Best regards, Joern
By Nevron Support - 9 Years Ago
Hi Joern,

We could not replicate the problem - we tested with the following code:

  private void Form1_Load(object sender, EventArgs e)
   {
    // setup chart
    NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

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

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

    chart.Series.Add(line);

    callout = new NRectangularCallout();
    callout.Text = "Some text";
    callout.UseAutomaticSize = true;
    callout.Anchor = new NDataPointAnchor(line, 50, ContentAlignment.MiddleCenter, StringAlignment.Center);
    chart.ChildPanels.Add(callout);
   }

   NRectangularCallout callout;

   private void button1_Click(object sender, EventArgs e)
   {
    NLineSeries line = (NLineSeries)nChartControl1.Charts[0].Series[0];
    callout.Anchor = new NDataPointAnchor(line, 99, ContentAlignment.MiddleCenter, StringAlignment.Center);
    nChartControl1.Refresh();
   }

and the callout is repositioned properly.
By joern kunze - 9 Years Ago
thanks a lot - your example does work on my site as well - so I will try to find the difference with the real project to clarify this issue.