Hi Ben,
There is no embedded context menu functionality, but you can easily add one - the following example shows how to display a simple context menu when the user clicks on points in the chart:
struct DataItemTag
{
public DataItemTag(NSeriesBase series, int index)
{
Series = series;
Index = index;
}
public NSeriesBase Series;
public int Index;
}
private void Form1_Load(object sender, EventArgs e)
{
NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
chart.BoundsMode = BoundsMode.Stretch;
// 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]);
}
nChartControl1.MouseClick += new MouseEventHandler(nChartControl1_MouseClick);
}
void nChartControl1_MouseClick(object sender, MouseEventArgs e)
{
NHitTestResult result = nChartControl1.HitTest(e.X, e.Y);
if (result.ChartElement == ChartElement.DataPoint)
{
ContextMenu menu = new ContextMenu();
DataItemTag tag = new DataItemTag(result.Series, result.DataPointIndex);
MenuItem option1 = new MenuItem("Make Red");
option1.Click +=new EventHandler(option1_Click);
option1.Tag = tag;
menu.MenuItems.Add(option1);
MenuItem option2 = new MenuItem("Reset To Default");
option2.Click += new EventHandler(option2_Click);
option2.Tag = tag;
menu.MenuItems.Add(option2);
menu.Show(nChartControl1, new Point(e.X, e.Y));
}
}
void option1_Click(object sender, EventArgs e)
{
MenuItem item = (MenuItem)sender;
DataItemTag tag = (DataItemTag)item.Tag;
((NPointSeries)tag.Series).FillStyles[tag.Index] = new NColorFillStyle(Color.Red);
nChartControl1.Refresh();
}
void option2_Click(object sender, EventArgs e)
{
MenuItem item = (MenuItem)sender;
DataItemTag tag = (DataItemTag)item.Tag;
((NPointSeries)tag.Series).FillStyles.Remove(tag.Index);
nChartControl1.Refresh();
}
of course this sample can be extended further. Let us know if you have any questions or meet any problems.
Best Regards,
Nevron Support Team