In NOV Chart for .NET hit testing is achieved by subscribing to one of the mouse events exposed by the NChartElement class. This class is similar to the Input element class in NOV UI and for more information you can visit the Input Elements topic. The following code snippet shows how to implement an interactive pie chart:
C# |
Copy Code
|
---|---|
NChartView chartView = new NChartView(); // create a dock panel with label and chart NDockPanel dockPanel = new NDockPanel(); chartView.Surface.Content = dockPanel; // crete a docked label NLabel label = new NLabel(); label.Text = "Interactive Pie Chart"; label.Margins = new NMargins(10); NDockLayout.SetDockArea(label, ENDockArea.Top); dockPanel.AddChild(label); // create a new cartesian chart NPieChart pieChart = new NPieChart(); NDockLayout.SetDockArea(pieChart, ENDockArea.Center); dockPanel.AddChild(pieChart); NPieSeries pieSeries = new NPieSeries(); pieChart.Series.Add(pieSeries); pieSeries.DataPoints.Add(CreateDataPoint(10)); pieSeries.DataPoints.Add(CreateDataPoint(20)); pieSeries.DataPoints.Add(CreateDataPoint(30)); ... private NPieDataPoint CreateDataPoint(double value) { NPieDataPoint pieDataPoint = new NPieDataPoint(value); pieDataPoint.MouseDown += new Function<NMouseButtonEventArgs>(pieDataPoint_MouseDown); return pieDataPoint; } void pieDataPoint_MouseDown(NMouseButtonEventArgs arg) { NPieDataPoint pieDataPoint = (NPieDataPoint)arg.TargetNode; pieDataPoint.Fill = new NColorFill(NColor.Red); } |