Hi Joern,
You can look for chart elements by their unique id - it will stay the same even if the document is serialized / deserialized:
Guid m_LastClickedSeriesId;
NChart chart = nChartControl1.Charts[0];
NBarSeries bar1 = new NBarSeries();
bar1.Values.Add(10);
bar1.Values.Add(20);
bar1.Values.Add(30);
chart.Series.Add(bar1);
NBarSeries bar2 = new NBarSeries();
bar2.Values.Add(10);
bar2.Values.Add(20);
bar2.Values.Add(40);
bar2.MultiBarMode = MultiBarMode.Clustered;
chart.Series.Add(bar2);
nChartControl1.MouseDown += new MouseEventHandler(nChartControl1_MouseDown);
nChartControl1.Refresh();
void nChartControl1_MouseDown(object sender, MouseEventArgs e)
{
NHitTestResult result = nChartControl1.HitTest(e.X, e.Y);
if (result.ChartElement == ChartElement.DataPoint)
{
m_LastClickedSeriesId = result.Series.UniqueId;
}
}
private void HighlightLastClickedBar()
{
NBarSeries series = nChartControl1.Document.GetElementFromUniqueId(m_LastClickedSeriesId) as NBarSeries;
if (series != null)
{
series.FillStyle = new NColorFillStyle(Color.Red);
nChartControl1.Refresh();
}
}
The above example shows how to store the unique id of the last clicked series and then to search / highlight.
Hope this helps - let us know if you meet any problems.
Best Regards,
Nevron Support Team