Hi Alina,
In general you need to two more things to make this work:
1. Add a NDataCursorTool to the chart controller.
2. Specify active chart.
The following code shows how to achieve this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Nevron.Chart;
using Nevron.GraphicsCore;
using Nevron.Chart.WinForm;
namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
NChart _cartesianChart;
private void Form1_Load(object sender, EventArgs e)
{
_cartesianChart = (NCartesianChart)nChartControl1.Charts[0];
NBarSeries bar = new NBarSeries();
bar.Values.Add(10);
bar.Values.Add(20);
bar.Values.Add(30);
_cartesianChart.Series.Add(bar);
nChartControl1.MouseMove +=new MouseEventHandler(nChartControl1_MouseMove);
nChartControl1.MouseLeave +=new EventHandler(nChartControl1_MouseLeave);
nChartControl1.Controller.Selection.SelectedObjects.Add(_cartesianChart);
nChartControl1.Controller.Tools.Add(new NDataCursorTool());
}
public void nChartControl1_MouseMove(object sender, MouseEventArgs e)
{
NAxis xAxis = _cartesianChart.Axis((int)StandardAxis.PrimaryX);
if (xAxis.Cursors.Count == 0)
{
NAxisCursor cursor = new NAxisCursor();
cursor.BeginEndAxis = (int)StandardAxis.PrimaryY;
cursor.StrokeStyle = new NStrokeStyle(1, Color.Red);
cursor.SynchronizeOnMouseAction = MouseAction.Move;
cursor.ValueSnapper = new NAxisRulerClampSnapper();
xAxis.Cursors.Add(cursor);
}
NAxis yAxis = _cartesianChart.Axis((int)StandardAxis.PrimaryY);
if (yAxis.Cursors.Count == 0)
{
NAxisCursor cursor = new NAxisCursor();
cursor.BeginEndAxis = (int)StandardAxis.PrimaryX;
cursor.StrokeStyle = new NStrokeStyle(1, Color.Red);
cursor.SynchronizeOnMouseAction = MouseAction.Move;
cursor.ValueSnapper = new NAxisRulerClampSnapper();
yAxis.Cursors.Add(cursor);
}
_cartesianChart.Refresh();
}
public void nChartControl1_MouseLeave(object sender, EventArgs e)
{
_cartesianChart.Axis(StandardAxis.PrimaryX).Cursors.Clear();
_cartesianChart.Axis(StandardAxis.PrimaryY).Cursors.Clear();
nChartControl1.Invalidate();
}
}
}
Let us know if you meet any problems.
Best Regards,
Nevron Support Team