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