Hi. I want to remove some trendline, I've tried doing it like this in the codebehind:
Infragistics.Controls.Charts.ValueOverlay overlay = new Infragistics.Controls.Charts.ValueOverlay();overlay.Brush = Brushes.Green;overlay.BorderThickness = new Thickness(3);overlay.Thickness = 3;overlay.Axis = this.xmYAxis;overlay.Value = 80.00;this.xmDataChart.Series.Remove(overlay);
But the Trendline wasn't deleted?
I set the Trendline with this code:
Infragistics.Controls.Charts.ValueOverlay overlay = new Infragistics.Controls.Charts.ValueOverlay(); overlay.Brush = Brushes.Green; overlay.BorderThickness = new Thickness(3); overlay.Thickness = 3; overlay.Axis = this.xmYAxis;overlay.Value = 80.00;this.xmDataChart.Series.Add(overlay);
Thanks for your help
Hello,
I have been looking into your requirement and from your code snippet it appears that you are creating a new instance of the ValueOverlay and trying to remove another that has the same properties. If you do it like so:
ValueOverlay overlay = new ValueOverlay();
overlay.Brush = Brushes.Green;
overlay.BorderThickness = new Thickness(3);
overlay.Thickness = 3;
overlay.Axis = this.xmYAxis;
overlay.Value = 80.00;
this.chart1.Series.Add(overlay);
this.chart1.Series.Remove(overlay);
it works, however if you use a new instance it is still a different instance even though it has the same name. What I can suggest is either preserving the instance until you need to remove it from the collection, or iterate through the Series and when the proper instance is found remove it by index using the RemoveAt method.
Please let me know, if you require any further clarification on the matter.
Hello Petar,
where can I find the value from the second trendline with value 85.00?
SetTrendline(80.00);SetTrendline(85.00);SetTrendline(90.00);SetTrendline(94.00);SetTrendline(95.00);
for (int i = 0; i < this.xmDataChart.Series.Count(); i++){
// if(this.xmDataChart.Series[i]. ? ? ? ? == 85.00) { this.xmDataChart.Series.RemoveAt(i); }}
Thank you for your help.
Sincerely, Rainer
Hello Rainer,
I am just checking if you got this worked out, or you still require any assistance, or clarification on the matter.