Profile Picture

Insert and remove line values

Posted By Ereona 12 Years Ago
Author
Message
Ereona
Posted 12 Years Ago
View Quick Profile
Forum Member

Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 43, Visits: 1
Thank you for helpful answer.

Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
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



Ereona
Posted 12 Years Ago
View Quick Profile
Forum Member

Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 43, Visits: 1
Hello.
I need to add a value to NLineSeries at specified index. I use line.XValues.Insert(int index, object value) and line.Values.Insert(int index, object value). But I have a problem with indexed collections related with series (MarkerStyles, Tags etc). They didn't shift corresponding values index change. The same problem with removing at specified index. Is it possible to syncronize indexed collections with data points? I.e. I want to bind (for example) the concrete marker style to concrete data point not depending on data point index in series. At this moment I see only one decision: shift values of each indexed collection in cycle (line.MarkerStyles[i] = line.MarkerStyles[i + 1]; ). But it is not optimally. Could you give me some advice?



Similar Topics


Reading This Topic