Hello,
The easiest way is to use the InsertDataPointAt and RemoveDataPointAt methods of the series. The following examples demonstrates how to insert a bar at index 1.
private void Form1_Load(object sender, EventArgs e)
{
NChart chart = nChartControl1.Charts[0];
NBarSeries bar = new NBarSeries();
chart.Series.Add(bar);
bar.Values.Add(10);
bar.Values.Add(20);
bar.Values.Add(15);
bar.FillStyles[0] = new NColorFillStyle(Color.Green);
bar.FillStyles[1] = new NColorFillStyle(Color.Orange);
bar.FillStyles[2] = new NColorFillStyle(Color.Pink);
}
private void button1_Click(object sender, EventArgs e)
{
NDataPoint dp = new NDataPoint();
dp[DataPointValue.Y] = 2;
dp.ValidFillStyle = true;
NBarSeries bar = (NBarSeries)(nChartControl1.Charts[0].Series[0]);
bar.InsertDataPointAt(1, dp);
nChartControl1.Refresh();
}
If you want to specify an individual fill style for the new bar you can use something like the following:
dp[DataPointValue.FillStyle] = new NColorFillStyle(Color.Red);
In case you don't specify a fill style you still have to set the ValidFillStyle property of the NDataPoint object to true like in the example above. This will ensure that all fill styles will match their respective values after the new value is inserted.
You have to proceed like this with all other indexed attribute series like BorderStyles, MarkerStyles etc. (whichever you are using).
Best Regards,
Nevron Support Team