Hi Amit,
> Will it be same for Flex Chart as well
As there are a lot of differences in the APIs of FlexChart and C1Chart, this leads to differences in their implementation. To gain more insight into the implementation and features of FlexChart, you can consult the documentation link provided: https://www.grapecity.com/componentone/docs/win/online-flexchart/overview.html
For insertion and deletion, you will first need to capture the mouse click position as shown in the following code:
private void C1Chart1_MouseDown(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
_pt = Control.MousePosition;
}
}
> Insertion - the point is hardcoded, but is it possible to select the point from the chart itself and insert.
You can achieve the desired behavior by referring to the following code:
private void addBtn_Click(object sender, EventArgs e)
{
var currentSeries = c1Chart1.ChartGroups[0].ChartData.SeriesList[0];
var pt = c1Chart1.PointToClient(_pt);
if (currentSeries != null && currentSeries.PointData.Length > 0)
{
double x = 0, y = 0;
if (currentSeries.Group.CoordToDataCoord(pt.X, pt.Y, ref x, ref y))
{
currentSeries.X.CopyDataIn((currentSeries.X.CopyDataOut() as double[]).Concat(new double[] { x }).ToArray());
currentSeries.Y.CopyDataIn((currentSeries.Y.CopyDataOut() as double[]).Concat(new double[] { y }).ToArray());
}
c1Chart1.Update();
}
}
> Deletion - I believe this is removing the last point from the array, but what if we want to select a specific point from the chart and than delete it.
You can achieve the desired behavior by referring to the following code:
private void deleteBtn_Click(object sender, EventArgs e)
{
var pt = c1Chart1.PointToClient(_pt);
int pntInd = 0, dist = 0;
var currentSeries = c1Chart1.ChartGroups[0].ChartData.SeriesList[0];
if (currentSeries != null)
{
if(currentSeries.PointData.Length > 0)
{
if(currentSeries.Group.CoordToPointIndex(pt.X, pt.Y, PlotElementEnum.Points, 0, ref pntInd, ref dist))
{
if(dist < 10)
{
currentSeries.PointData.RemoveAt(pntInd);
}
}
c1Chart1.Update();
}
}
}
Kindly refer to the attached sample for full implementation. (C1ChartApplication_Mod.zip)
Thanks & Regards,
Aastha