Hi Neil,
You can achieve this by using the custom values labels - the following code snippets shows a simple point with two dynamic cursors that display the current cursor value at its respective axis:
private void Form1_Load(object sender, EventArgs e)
{
NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
chart.Dock = DockStyle.Fill;
chart.BoundsMode = BoundsMode.Stretch;
chart.MinDockZoneMargins = new NMarginsL(45, 0, 0, 30);
// sample data
double[] pointYValues = new double[] { 10, 20, 30 };
double[] pointXValues = new double[] { 10, 20, 30 };
NPointSeries point = new NPointSeries();
point.UseXValues = true;
chart.Series.Add(point);
for (int i = 0; i < pointYValues.Length; i++)
{
point.Values.Add(pointYValues[i]);
point.XValues.Add(pointXValues[i]);
}
NAxisCursor cursor1 = new NAxisCursor();
cursor1.BeginEndAxis = (int)StandardAxis.PrimaryY;
cursor1.SynchronizeOnMouseAction = MouseAction.Move;
cursor1.ValueSnapper = new NAxisRulerClampSnapper();
cursor1.ValueChanged += new EventHandler(cursor1_ValueChanged);
chart.Axis(StandardAxis.PrimaryX).Cursors.Add(cursor1);
NAxisCursor cursor2 = new NAxisCursor();
cursor2.BeginEndAxis = (int)StandardAxis.PrimaryX;
cursor2.SynchronizeOnMouseAction = MouseAction.Move;
cursor2.ValueSnapper = new NAxisRulerClampSnapper();
cursor2.ValueChanged += new EventHandler(cursor2_ValueChanged);
chart.Axis(StandardAxis.PrimaryY).Cursors.Add(cursor2);
nChartControl1.Controller.Tools.Add(new NSelectorTool());
nChartControl1.Controller.Tools.Add(new NDataCursorTool());
}
void cursor1_ValueChanged(object sender, EventArgs e)
{
NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
NStandardScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NStandardScaleConfigurator;
scale.CustomLabels.Clear();
NCustomValueLabel label = new NCustomValueLabel();
label.Value = ((NAxisCursor)sender).Value;
label.Text = label.Value.ToString("N2");
scale.CustomLabels.Add(label);
nChartControl1.Refresh();
}
void cursor2_ValueChanged(object sender, EventArgs e)
{
NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
NStandardScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NStandardScaleConfigurator;
scale.CustomLabels.Clear();
NCustomValueLabel label = new NCustomValueLabel();
label.Value = ((NAxisCursor)sender).Value;
label.Text = label.Value.ToString("N2");
scale.CustomLabels.Add(label);
nChartControl1.Refresh();
}
Note that the left and bottom axis zones have fixed min width:
chart.MinDockZoneMargins =
new NMarginsL(45, 0, 0, 30);this is done to prevent the chart from bouncing off the edges when the cursor values change.
Hope this helps - let us know if you have any questions...
Best Regards,
Nevron Support Team