Profile Picture

anchor annotation to legend data item

Posted By Filip Mergental 13 Years Ago
Author
Message
Filip Mergental
Posted 13 Years Ago
View Quick Profile
Junior Member

Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 16, Visits: 1
Hello, I have a problem with the anchor of annotation.

I have the Cartesian chart _chart and its legend with these properties:

NLegend legend = new NLegend();

legend.Dock = DockStyle.Top;
legend.Data.ExpandMode = LegendExpandMode.ColsOnly;
legend.FitAlignment = ContentAlignment.TopCenter;

_chart.DisplayOnLegend = legend;

And I have the annotation:
_annotation = new NRoundedRectangularCallout();
_annotation.FillStyle = new NColorFillStyle(Color.Yellow);
_annotation.UseAutomaticSize = true;


I want to show the annotation when I click to legend data item. But the position of annotation is wrong. I think the position corresponds
to legend FitAligment TopLeft. What am I doing wrong?


private void nChartControl_MouseDown(object sender, MouseEventArgs e)
{
NHitTestResult hitTestResult = nChartControl.HitTest(e.X, e.Y);
NLegend legend = _chart.DisplayOnLegend;

_annotation.Anchor = new NLegendDataItemAnchor(legend, hitTestResult.ObjectIndex);
_annotation.Text = "......";

nChartControl.Panels.Add(_annotation);
}

Thanks for your help,
Daniela

Attachments
anchor_annotation.png (67 views, 215.00 KB)
Nevron Support
Posted 13 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: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009

Hi Filip,

What is the version of the control you're currently using - we just tested with a relatively new version (11.12.14.12) and it was working Ok with the following test case:

  NChart _chart;
  NRoundedRectangularCallout _annotation;

  private void Form1_Load(object sender, EventArgs e)
  {
   _chart = nChartControl1.Charts[0];
   _chart.Dock = DockStyle.Fill;

   NPointSeries point = new NPointSeries();

   NLength pointSize = new NLength(8, NGraphicsUnit.Point);
   point.Size = pointSize;

   point.Values.Add(10);
   point.Values.Add(20);
   point.Values.Add(30);

   _chart.Series.Add(point);

   NLegend legend = nChartControl1.Legends[0];

   legend.Data.MarkSize = new NSizeL(pointSize, pointSize);
   legend.Dock = DockStyle.Top;
   legend.Data.ExpandMode = LegendExpandMode.ColsOnly;
   legend.FitAlignment = ContentAlignment.TopCenter;

   _annotation = new NRoundedRectangularCallout();
   _annotation.FillStyle = new NColorFillStyle(Color.Yellow);
   _annotation.UseAutomaticSize = true;
  }

  


  private void button1_Click(object sender, EventArgs e)
  {
   NLegend legend = _chart.DisplayOnLegend;

   _annotation.Anchor = new NLegendDataItemAnchor(legend, 0);
   _annotation.Text = "......";

   nChartControl1.Panels.Add(_annotation);

   nChartControl1.Refresh();
  }

Let us know if the problem persists with the new version as well...



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic