Hi Alexander,
That's a bit tricky as the legend item index is not exposed from the hit test result - you need to obtain the parent collection and find the item there:
private void Form1_Load(object sender, EventArgs e)
{
NChart chart = nChartControl1.Charts[0];
for (int i = 0; i < 10; i++)
{
NBarSeries bar = new NBarSeries();
bar.Values.Add(10);
chart.Series.Add(bar);
}
nChartControl1.MouseDown += new MouseEventHandler(nChartControl1_MouseDown);
}
void nChartControl1_MouseDown(object sender, MouseEventArgs e)
{
NHitTestResult result = nChartControl1.HitTest(e.X, e.Y);
if (result.ChartElement == ChartElement.LegendDataItem)
{
NLegendItemCellData cell = result.LegendDataItem;
NChartElementComposite parent = (NChartElementComposite)cell.ParentNode;
int index = parent.IndexOfChild(cell);
MessageBox.Show("Legend data item [" + index.ToString() + "]");
}
}
Best Regards,
Nevron Support Team